Page 1 of 1

PDO Opinion?

Posted: Mon Aug 07, 2006 7:01 am
by Ollie Saunders
Has anyone used PDO?
If so what did you think?
What it is good for / not good for?

Posted: Mon Aug 07, 2006 11:42 am
by dibyendrah
taken from http://omniti.com/

Code: Select all

try {
  $db = new PDO($dsn,  $user, $password);
} catch (PDOException $e) {
  echo 'Connect failed:'. $e->getMessage();
}

$stmt = $db->prepare("select * from country where name like 'Aus%'");
$stmt->execute();
while ($row = $stmt->fetch()) 
    print_r($row);

Posted: Mon Aug 07, 2006 1:18 pm
by Christopher
PDO is very nice and improving. The prepared statements and exception handling are two good reasons to use it. However it has some quirks, like not making the number of records in a result set available because its buffering setting and that not all DBs support it.