Assertion and DB wrapper fix

@robotpony 

This will merge recent improvements to assertion handling and the PDO wrapper into the 1.2 branch.