[WIP] Fix pg boolean conversion

Merge of complementary PR's #527 and #564 + some fixes. Contributing it as an result of the (extended) phpconference.nl 2014 hackathon. 
Updating the actual param and return type is not possible, since all types of variables can be entered and the output can both be an integer (or a string in some inherited classes) OR the original input value if this was not a boolean or an array of it. So I kept the types but added some extra comments about this.