On Thu, Aug 21, 2008 at 7:23 PM, Brion Vibber
<brion(a)wikimedia.org> wrote:
In my opinion that would be a bit horrifyingly
scary. ;) Domain-specific
knowledge is better placed in domain-specific classes...
Well, having pgsql and all the other BOOL-supporting DBMSes forced to
use integer types just because devs are too lazy to make sure things
work properly on all databases is exactly the sort of thing the
abstraction layer is meant to prevent. Each database should be able
to properly use its own features. Introducing domain-specific
knowledge is kind of icky, but I can't think of any other way to do
it.
Of course this logic could be properly factored out of Database.php.
For instance, we could add another argument to the constructor (or add
a mutator, which could allow extensions to join the fun) that would
allow you to pass in an array of fieldname => type mappings. Then
whatever instantiates the Database object we use could pass that in
when it constructs the object.
Don't all DBMSes interpret 1 as true and 0 as
false? Then why don't we
just check if something is a bool and convert it to 1 or 0? Problem
solved (I think).
Roan Kattouw (Catrope)