Re: MDB2 and Data Type Abstraction
| From: | Paul M Jones | Date: | Tue, 04 May 2004 23:08:37 +0000 |
| Subject: | Re: MDB2 and Data Type Abstraction | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28794@lists.php.net to get a copy of this message | ||
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_TableHope this helps; let me know if you have questions or comments. -- Paul M. Jones Savant: the simple alternative to Smarty for PHP. http://phpsavant.com/ DB_Table: build RDBMS tables and XHTML forms in one PHP class. http://wiki.ciaweb.net/yawiki/index.php?area=DB_Table Yawiki: your collaborative online documentation system. http://wiki.ciaweb.net/yawiki/index.php?area=Yawiki