2009年6月30日星期二

[fw-db] Model/Mapper to populate form

Hi.
I should get data to populate a form for
the model/mapper I ended up with this code
 //mapper public function populate($id)     {         $result = $this->getDbTable()->find($id);         return $result->toArray();     } // model  function populate($id)     {         return $this->getMapper()->populate($id);              } 
It's a quick way but imho not very OOP (it break the logic of model/mapper) I mean the populate method should return a user objetc like this
 //mapper public function find($id, Model_UserModel $user)     {         $result = $this->getDbTable()->find($id);         if (0 === count($result)) {             return null;         }         $row = $result->current();         $user->setId($row->id)                     ->setAcl_role_id($row->acl_role_id)                     ->setUname($row->uname)                     ->setSurname($row->surname)                     ->setUsername($row->username)                     ->setPassword($row->password)                     ->setEmail($row->email)                     ->setCreated($row->created)                     ->setLogin($row->login)                     ->setActive($row->active);     } //model  public function find($id)     {         $this->getMapper()->find($id, $this);         return $this;     } 
or not ? Thanks in advance. Bye

View this message in context: Model/Mapper to populate form
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: