One thing with pdo, every time you do a statement you have to tell if what mod to use for fetch. You can do this either directly by passing a value like PDO::FETCH_ASSOC to your fetch statements or to setFetchMode for each query result.
Now if your like me and use the same exact mode 99% of the time this can get a little annoying, The following blog by the developer goes into a little detail on why this is and methods you can extend PDO to change this if you so need.
http://netevil.org/node.php?nid=703&SC=1#comments
Well ran into a project where I would need to get the status of a mysql table often, so wanted to make some reusable code for this, realize this also might be a good time to tackle the whole pdo issue, so here you go a solid example of how to extend PDO to stop having to use setFetchMode every query or extend it some more to change your needs. Even a commented out way to extend PDOStatement as well but Im not using it just yet
private $fetch_mode = PDO::FETCH_ASSOC;
function __construct($dsn, $user = NULL, $pass = NULL, $options = NULL) {
parent::__construct($dsn, $user, $pass, $options);
}
function setFetchMode($fetch_mode) {
$this->fetch_mode = $fetch_mode;
}
function tableStatus($table) {
$query = 'SHOW TABLE STATUS LIKE "'.$table.'"';
$stmt = parent::prepare($query);
$result = $stmt->execute();
$rtval = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $rtval;
}
function query($sql) {
// Not sure yet if we truly need to extend PDOStatement
# $stmt = parent::prepare($sql, array(PDO::ATTR_STATEMENT_CLASS=>array('Extend_PDOStatement')));
# $stmt->execute();
$stmt = parent::query($sql);
if($stmt) {
$stmt->setFetchMode($this->fetch_mode);
}
return $stmt;
}
}
class Extend_PDOStatement extends PDOStatement {
}

