Re: Re: DB_DataObject fetch methods

From: Date: Wed, 10 Mar 2004 23:20:48 +0000
Subject: Re: Re: DB_DataObject fetch methods
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-26272@lists.php.net to get a copy of this message
On 10 Mar 2004, at 22:48, Alan Knowles wrote:
           $records[$key] = $dataobject->__clone () ;
** note this has changed to
           $records[$key] = clone($dataobject);
in the next release (due to the PHP5 cloning method changing)
Good point... I'll get this updated... thanks.
I'm not 100% sure on adding a class like the one you attached. - it may seem simpler, but my initial feeling is that you are sacraficing a significant amount of code readiblity. - especially by doing magic things with keys.
I think you're right, but we wrote this for a specific use is a couple of our applications, and it's was really just a first hit at doing something like this. The magic with keys was part of that because we were passing arrays of objects to smarty forms and wanted an easy way to reference the elements. We haven't yet looked at adding something to this class to handle doing something like... $recordset =& DataSelection::factory('thetable'); $recordset->setFrom ($_POST) ; $recordset->update () ; Although I could see a couple of applications where this would be useful. I was thinking about ways of handling record sets like this for a while, and I don't think I've necessarily come up with the best solution yet, but for simple stuff, this has been fairly useful.
for the fetch method - the intention was to add something like: DB_DataObject::factory('thetable',array(
      'condition' => .....,
      'select' =>
     ....
) I've not had time to look into the details of this.. - like how to implement inserts/updates/deletes using this factory + array...
It's definitely an interesting idea, but I haven't thought it through well enough to come up with a nice way of doing it. The code I posted came more from refactoring some of the code we had where we were using DB_DataObject, and I'm not sure it's the best way, but I'm open to suggestion. Best, Mark -- Mark Mitchenall, Standingwave Ltd (Complete Hosting and Development Services) Tel := +44 (0)20 8452 3031 Email := mark@standingwave.co.uk mark@mitchenall.com Home := http://www.standingwave.co.uk http://www.mitchenall.com

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