Db_DataObjects Ideas
| From: | Yavor Shahpasov | Date: | Mon, 20 Oct 2003 07:22:53 +0000 |
| Subject: | Db_DataObjects Ideas | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-22836@lists.php.net to get a copy of this message | ||
First of all, I like db objects a lot they are a great time saver.
there is one thing about them I don't like
* $config = parse_ini_file('example.ini',true);
* $options = &PEAR::setStaticProperty('DB_DataObject','options');
* $options = $config['DB_DataObject'];
Is it possible to change the way the config works to have config data in the target database, both for table meta data and generic options.
it can be easily implemented with two tables
[_Db_DataObjects_config]
classname, confname, confvalue
[_Db_DataObjects_tables]
tablename,fieldname,type
I think it makes a lot more sence to have meta data in the db rather in flat ini files. These would be queried only once and values would the set just like now using &PEAR::setStaticProperty the first time a db_object is requested. A db object would be called as follows
$db = DB::connect($dsn);
$person = new PersonObject($db);
A second thing I was thinking of, it would be nice it it had a light mode, meaning no file classes for objects need to be created. Using the metadata for a table you could do this
$person = DB_DataObject::factory('person', $db);
the above would return a db object, with fields populated accordingly. Am not saying drop the class generation. it is a nice feature to be able to add extra logic to the classes, but sometimes, you just need quick access to the dataobjects without the hassle of table generation.
Yavor
--
Yavor Shahpasov
yavo@siava.org