WIP [Ticket/10513] Add binary escape functions to fix PostgreSQL varbinary failing.

Other DBMSes need checking.

http://tracker.phpbb.com/browse/PHPBB3-10513