The DBA functions abstract communications with databases that conform to the style of Berkeley DB database systems. Rather than storing complex records, a DBM database simply stores key/value pairs. This is similar to an associative array. The functions in this section replace a set of functions that allow just one type of DBM database. These new functions allow for choosing the underlying system from within your PHP code rather than compiling PHP for a single DBM implementation. You choose a type of database when you open a connection, and the rest of the functions perform accordingly. Sascha Schumann added these functions to PHP.
The dba_close function closes a link to a database. The link argument is an integer returned by the dba_open or dba_popen functions. If you choose not to close a database connection, PHP will close it for you.
boolean dba_delete(string key, integer link)
The dba_delete function removes an entry from a database. You must supply both the key and a valid link to a database, as supplied by dba_open or dba_popen. The success of the delete is returned as a boolean.
boolean dba_exists(string key, integer link)
The dba_exists function tests for the presence of a key. The link argument must be an integer returned by the dba_open or dba_popen functions. The description of dba_delete has an example of using dba_exists.
string dba_fetch(string key, integer link)
Use the dba_fetch function to retrieve a record.
string dba_firstkey(integer link)
The dba_firstkey function returns the first key in the database. If the database is empty, FALSE will be returned. As the example for dba_fetch shows, dba_firstkey and dba_nextkey may be used to traverse the entire database.
boolean dba_insert(string key, string value, integer link)
Use dba_insert to add a record to the database. The success of the insert is returned. Trying to insert a record that already exists is not allowed. If you need to update a record, use dba_replace.
string dba_nextkey(integer link)
The dba_nextkey function returns the next key from the database. When there are no keys left, false is returned. The description of dba_fetch shows a typical use of dba_nextkey and dba_firstkey together.
integer dba_open(string filename, string mode, string type, ...)
Use dba_open to establish a link to a dbm-style database. A positive integer will be returned if the open is successful, FALSE if it fails. The filename argument is simply the path to a database. The mode argument can be one of four characters that control input and output of data.
The type argument chooses the underlying database engine. You may also supply any number of optional arguments that will be passed directly to the underlying engine.
When your script finishes executing, the database link will close automatically. You may choose to close it sooner with dba_close, and this may save some small amount of memory. Contrast this function to dba_popen, which attempts to reuse links.
boolean dba_optimize(integer link)
Use dba_optimize to optimize a database, which usually consists of eliminating gaps between records created by deletes. This function returns TRUE on success. Some underlying engines do not support optimizations, in which case this function will have no effect.
integer dba_popen(string filename, string mode, string type, ...)
The dba_popen function behaves identically to dba_open with one difference: Links are not closed. They remain with the process until the process ends. When you call dba_popen, it first tries to find an existing link. Failing that, it will create a new link. You never call dba_close on a link returned by dba_popen. Since the links are pooled on per-process basis, this functionality offers no benefit when using PHP as a stand-alone executable. When used as an Apache module, there may be some small performance benefit due to the unique way Apache uses child processes.
boolean dba_replace(string key, string value, integer link)
Use dba_replace to update the value of an existing record. As with the other DBA functions, a valid link as returned by dba_open or dba_popen should be used for the link argument. See the description of dba_insert for an example using dba_replace.
boolean dba_sync(integer link)
The dba_sync function will synchronize the view of the database in memory and its image on the disk. As you insert records, they may be cached in memory by the underlying engine. Other processes reading from the database will not see these new records until synchronization.
PHP Related Interview Questions
|PHP Interview Questions||MySQL Interview Questions|
|PHP+MySQL Interview Questions||Drupal Interview Questions|
|MYSQL DBA Interview Questions||PHP5 Interview Questions|
|WordPress Interview Questions||Joomla Interview Questions|
|CakePHP Interview Questions||CodeIgniter Interview Questions|
|PHP7 Interview Questions|
An Introduction To Php
Variables, Operators, And Expressions
Classes And Objects
I/o And Disk Access
Time, Date, And Configuration Functions
Parsing And String Evaluation
Sorting Searching And Random Numbers
Integration With Html
Efficiency And Debugging
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.