Advertisement
Guest User

Untitled

a guest
Jun 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. class UserRepo {
  2. findById($id) {
  3. ...
  4. }
  5. save($user) {
  6. if (!$user instanceof User) {
  7. // исключение
  8. }
  9. }
  10. }
  11.  
  12. $user = $this->userRepo->findById($id);
  13. echo $user->name;
  14.  
  15. $user = $this->userRepo->findById($id);
  16. $user->name = 'fail';
  17. $user->save();
  18.  
  19. $data = [данные нового юзера];
  20. // создать
  21. $user = $this->userRepo->save($data);
  22.  
  23. // обновить
  24. $user = $this->userRepo->save($data, $model);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement