Converts boolean parameters before binding to query.

PHP converts the boolean "false" value to the empty string. This patch
prepares any parameters sent to `ORM::_execute` by "pre-converting"
boolean values to either "1" or "0" so that these values are bound
properly.

A "more correct" solution would be to use `$statement->bindParam` with
`$data_type = PDO::PARAM_BOOL`. However, this solution cannot be tested
with the current setup, because the tests do their own string
substitution.

Potentially, there are other types that PDO won't convert properly –
PDO::PARAM_NULL or PostgreSQL array types, for example.
Uses table alias in WHERE

If a table alias is used for the main table, it's not valid according
to the SQL standard to refer to it by it's "real name" (see
http://www.postgresql.org/docs/8.2/static/queries-table-expressions.html
#QUERIES-TABLE-ALIASES). This causes problems when doing JOIN with a
table alias for the "main table", since previous code always used table
name. Now, we check for a table alias.
Merge branch 'vicvicvic-wherealias' into vicvicvic-custom
Merge branch 'vicvicvic-custom'