note 89809 added to intro.sqlite3

From: Date: Tue, 24 Mar 2009 10:28:52 +0000
Subject: note 89809 added to intro.sqlite3
Groups: php.notes 
Request: Send a blank email to php-notes+get-152372@lists.php.net to get a copy of this message
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: $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: 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 $dbh = null; or 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. ---- Server IP: 89.248.170.61 Probable Submitter: 130.161.177.94 ---- Manual Page -- http://www.php.net/manual/en/intro.sqlite3.php Edit -- https://master.php.net/note/edit/89809 Del: integrated -- https://master.php.net/note/delete/89809/integrated Del: useless -- https://master.php.net/note/delete/89809/useless Del: bad code -- https://master.php.net/note/delete/89809/bad+code Del: spam -- https://master.php.net/note/delete/89809/spam Del: non-english -- https://master.php.net/note/delete/89809/non-english Del: in docs -- https://master.php.net/note/delete/89809/in+docs Del: other reasons-- https://master.php.net/note/delete/89809 Reject -- https://master.php.net/note/reject/89809 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152372) next »