Quick PEAR::DB Calls : PEAR « Utility Function « PHP






Quick PEAR::DB Calls

 
include_once('DB.php');
    $db = DB::connect("mysql://user:password@localhost/phpdb");

    if (DB::isError($db)) {
            print $db->getMessage( );
            exit;
    } else {
            $maxage = $db->getOne("SELECT MAX(Age) FROM people;");
            print "The highest age is $maxage<br />";
            $allnames = $db->getCol("SELECT Name FROM people;");
            print implode(', ', $allnames) . '<br />';
            $onecol = $db->getRow("SELECT * FROM people WHERE Name = 'Ildiko';");
            var_dump($onecol);
    }

    $db->disconnect( );
  
  








Related examples in the same category

1.Advanced PEAR::DB: Prepared Statements
2.PEAR::DB