On Sun, May 19, 2013 at 9:28 PM, Charles Curley <[email protected]> wrote: > I have an existing program in PHP. I just upgraded the > server from Debian 6 to 7. In the process, that upgraded php from 5.3.3 > to 5.4.4. So far so good. But that means the old PHP interface to > sqlite went away. So I'm trying to update from the old PHP sqlite > interface to PDO. > > try { > ($dbh = new PDO("sqlite:$dbPath")); > } catch (PDOException $exception) { > printf("Failed to connect to the database. Error: %s", > $exception->getMessage()); > } > > $query = "select rating, comment, categories from ratings where billType = > '$billType' and billNumber = '$billNumber'"; > print ("<p>$query</p>\n"); > > $entry = $dbh->query($query); > > print "\nRetrieved " . $entry->rowCount() . " row(s).\n"; > > --------------------------------------------------
Using PDO gives you lots of other good things too. Especially prepared statements. These not only improve performance when executed multiple times, but gives you much better protection against SQL Injection attacks. It's also very easy to implement. http://us2.php.net/manual/en/pdo.prepared-statements.php ----------------------------- $query = $dbh->prepare("select rating, comment, categories from ratings where billType = ? and billNumber = ?"); $entry = $query->execute(array($billType,$billNumber)); /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
