␡
- Beneath the Abstraction
- Opening a Database
- Adding Data to the Database
- Amending Elements in a Database
- Reading from a Database
- Determining Whether an Item Exists in a Database
- Deleting an Item from a Database
- Adding Complex Data Structures to a Database
- An Example
- Summary
- Q&A
- Workshop
This chapter is from the book
Determining Whether an Item Exists in a Database
Before reading or setting an element in a database, it is sometimes useful to know whether the element exists. You can do this with the dba_exists() function. dba_exists() requires the name of the element for which you are testing and a valid DBA resource. It returns true if the element exists.
if ( dba_exists("Tricorder", $dbh ) ) print dba_fetch( "Tricorder", $dbh );