Re: Db_DataObjects Ideas

From: Date: Mon, 20 Oct 2003 08:44:29 +0000
Subject: Re: Db_DataObjects Ideas
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-22840@lists.php.net to get a copy of this message
Yavor Shahpasov wrote:
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);
Actually this data could be pulled from the Database really (eg. query the table structure on the fly).. - the current code base is leaning towards that.. - in that if tables(), cant load the config, the intention was to fallback and call the generator to ask for details on the database.. Putting the config in the database makes little sense.. - but you can always use PEAR's Config class to assign the data from a database. = the purpose of using PEAR::getStaticProperty is to make the config design independant from the class..
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.
This would be possible eventually, the intention is for factory to have a 2nd arg: something like: $person = DB_DataObject::factory('person', array(
	'dsn'        => 'mysql:/......',
'autocreate' => true, 'call' => array( array('get',$id), array('setFrom',$_POST), array('update'), ) ); All a matter of time :) Regards alan
Yavor
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

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