Re: MDB2 and Data Type Abstraction

From: Date: Wed, 05 May 2004 00:16:15 +0000
Subject: Re: MDB2 and Data Type Abstraction
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-28796@lists.php.net to get a copy of this message
Paul M Jones wrote:
Hi, Justin,
Basically, I was looking for some kind of automatic datatype abstraction. In other words, I've created an XML schema for my DB, which creates it for me. I like that. But now that I want to query, that all seems to go away. To get the types back correctly (date conversions, etc) I have to specify the types in the call...even though I already specified it for the table in the XML file. Basically what I'm looking for is to specify a table, give an assoc array of values, and have my record inserted or updated. This is part of what DB_DataObject does, but I'm looking for something a bit simpler.
DB_Table might have answers for you, or at least partial answers. DB_Table does a poor-man's data type abstraction, but does it automatically. It does not use an XML format, although it would be possible for me to make it do so. Instead, you define your columns within the DB_Table object as class properties. Thus, DB_Table knows exactly what your columns are when you retrieve them, and can validate them for their type when you insert/update them. DB_Table can also create forms from the column properties (via HTML_QuickForm) with one call to DB_Table::getForm(). DB_Table lets you build baseline queries, then you can call them with ad-hoc filters, orders, and limits, and retrieve as an array or a result. DB_Table wraps DB, so everything you already know about DB should still hold. DB_Table is above all simple and straightforward; I think it might be worth a look. The full and complete documentation, with user comments turned on, is here:
    http://wiki.ciaweb.net/yawiki/index.php?area=DB_Table
Hope this helps; let me know if you have questions or comments.
I knew of DB_Table from the lists. It seems to do what I'm talking about, but I'm looking for MDB funcitonality. I would much rather start using MDB now as it will be the new version of DB (or so I've heard). I like the datatype abstraction built into it and want to use it, but if I have to give the types with every call it adds a while lot of complexity to calls that simply don't have to be there. Also, the reason I mentioned DB_DataObject was because of the foreign key support. That's something I like a lot (in fact, I've added some code to DB_DataObject_FormBuilder to make them work better...not that anyone probably uses any of it). I guess I'll just make something myself. -- paperCrane <Justin Patrin>

« previous php.pear.dev (#28796) next »