PDO Opinion?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

PDO Opinion?

Post by Ollie Saunders »

Has anyone used PDO?
If so what did you think?
What it is good for / not good for?
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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);
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post 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.
(#10850)
Post Reply