note 89809 deleted from intro.sqlite3 by aharvey

From: Date: Mon, 10 Sep 2012 01:24:41 +0000
Subject: note 89809 deleted from intro.sqlite3 by aharvey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190605@lists.php.net to get a copy of this message
Note Submitter: pomax at nihongoresources dot com ---- If you use PHP5, the currently advised approach to natively (ie, without using a third party library) interfacing with sqlite3 databases is through the use of a PDO object: <?php $dbh = new PDO('sqlite:yourdatabase.db'); ?> Any execution of functions and commands supported by sqlite3 can then be called through the PDO query and exec functions. For instance, a broad select would be achieved as follows: <?php foreach($dbh->query('SELECT * FROM table WHERE column = criterium') as $row) {  foreach($row as $key=>$val)   {    // PDO has no built in fetch_assoc equivalent    if(!is_numeric($key)) print "$key: $val\n";   } } ?> when done consulting or administrating a database that relies on PDO access, it is generally a good idea to either issue a <?php $dbh = null; ?> or <?php unset($dbh); ?> statement, as the PDO class does not come with a function for closing a connection, and so any PDO connection will sit idle until you explicitly dispose of it.

« previous php.notes (#190605) next »