Advertisement
Guest User

Untitled

a guest
Apr 27th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. /** @table invoice_user */
  4. class UserRepository extends \YetORM\Repository
  5. {
  6.  
  7.     public function create($data)
  8.     {
  9.     $this->begin();
  10.     $row = $this->getTable()->insert($data);
  11.     $this->commit();
  12.  
  13.     return new User($row);
  14.     }
  15.  
  16.     public function persist(User $user)
  17.     {
  18.     $this->begin();
  19.     $rows = $user->toActiveRow()->update();
  20.     $this->commit();
  21.  
  22.     return $rows;
  23.     }
  24.  
  25.     public function findByUser($id)
  26.     {
  27.     $user = $this->getTable()->where('user_id', $id)->fetch();
  28.     if (!$user)
  29.         return NULL;
  30.     return new User($user);
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement