professional-php-08-DB-connect.php / php
<?php require_once('DB.php'); //postgres@localhost/mydb'; conn = DB::connect(conn)) { //you would probably want to do something a bit more graceful here print("Unable to connect to the database using the DSN conn->getMessage()); } //get all results as an associative array sql = "SELECT * FROM mytable"; conn->getAll(//returns all rows. Only use with small recordsets // Always check that data is not an error if (DB::isError(sql"); die (data); //close the connection ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.