Re: DB_DataObject - sugestion new feature
| From: | Marcos Neves | Date: | Thu, 26 Feb 2004 13:01:11 +0000 |
| Subject: | Re: DB_DataObject - sugestion new feature | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-25881@lists.php.net to get a copy of this message | ||
this works?
function getClientsActive(){
$this = DB_DataObject:factory('sometable');
// ...
}
At 21:02 26/2/2004 +0800, Alan Knowles wrote:
function getClientsActive(){$c = __CLASS__; $x = new $c; foreach(get_object_vars($x) as $k=>$v) { $this->$k = $v; } ....} although quite often I would just do something simple like this.. function getClientsActive(){$c = __CLASS__; $x = new $c; $x->get('id',20); return $x->name;} Regards Alan Marcos Neves wrote:I agree, API fat is bad! I think your suggestion is good to code outside the class. I still use that. How could I reset the class from inside a method? I'm really using DB_DataObject as my model tier, so I atach some funcions to that to perform business operations, and many of that operations must have the class as it born, since any where, or propertie setted affect the query. example: function getClientsActive(){-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com$this->reset(); // do code} At 10:27 26/2/2004 +0800, Alan Knowles wrote:I think it's been suggested before. - I'm not keen to make the API any fatter than necessary.. - in this case $db = DB_DataObject:factory('sometable'); $db->.... do stuff... $db = DB_DataObject:factory('sometable'); $db->.... do stuff... works perfectly well, and is clearer to spot that $db has been totally cleaned (rather than below the reset method call is slightly easier to miss when you are reading the code...) Regards Alan Marcos Neves wrote:what about a method that reset the DataObject? like this: $db = factory.... do something.... $db->reset(); do other things... where reset() is a method that back $db to his initial state doing something like this: function reset(){-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php$this->selectAdd(); $this->selectAdd("*"); $this->whereAdd(); $this->orderBy(); $this->limit(); // and clear internal data $this->id = null; $this->name = null;}