Pear-DB → PDO migration

I think this patch is huge enough to suggest we should have a peer review...