IDEA(dbal): A set of interfaces for constructing queries

These interfaces allow us to construct most basic queries within Elgg
in a programmatic and safe way. Have not attempted to find out where
the more complicated entities queries could be converted to this,
but it does seem pretty generic and able to handle quite a range, so
I would be remiss not to try.

The major downside of all this of course is that it would be mostly custom
implementation. The main attempt at "innovation" is using pass-by-reference
to alias tables instead of strings. This guarantees that all aliases are unique
and allows you to refer to columns/tables in the query by references rather
than strings.

I didn't look outside of doctrine for a query builder interface but if you know any others that might be close to this, that would be appreciated. Hopefully there is enough documentation here to give the gist of the API and generate some good discussion.