Home PHP PHP PDO
PHP PDO Print E-mail
Thursday, 19 August 2010 09:50
// PDO exception
// Database exception
set_exception_handler("PDOExeption");
function get_db()
{
// Open database
            return (open_PDO("db_name", "user", "pass")); 
}
function open_PDO($db_name, $user, $pass)
{
// Open Database met PDO class
    $dbh = new PDO("mysql:host=localhost;dbname=". $db_name, $user, $pass); 
// important - see code above: set_exception_handler 
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 
    return $dbh;
}
function PDOExeption($e)
{
    echo 'Caught exception: ',  $e->getMessage() , "\n";
}
 
 
 

Mobielstartpagina.nl

Visit our mobile portal page:

http://www.mobielstartpagina.nl

or

http://www.mobielstartpagina.nl/iPhone

on your smartphone!

Tech news and updates by PCWorld. Focused on computers and consumer electronics, topics include computer hardware, software, wireless, digital entertainment, security and anti-virus and gadgets.