Guest User

Untitled

a guest
Jun 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. class arUser extends ADOdb_Active_Record{}
  4.  
  5. class User{
  6. static $user_table;
  7. var $record;
  8. function __construct($condition = false)
  9. {
  10. self::$user_table = new arUser('users');
  11. if($condition)
  12. {
  13. $this->record = self::$user_table->find($condition);
  14. }
  15. }
  16.  
  17. function __get($property)
  18. {
  19. return $this->record[$property];
  20. }
  21.  
  22. function __set($property, $value)
  23. {
  24. $this->record[0][$property] = $value;
  25. }
  26.  
  27. static function getById($user_id)
  28. {
  29. $condition = "id = $user_id";
  30. return new User($condition);
  31. }
  32.  
  33. static function getByHandle($handle)
  34. {
  35. $condition = "handle = '".$handle."'";
  36. return new User($condition);
  37. }
  38. }
  39. ?>
Add Comment
Please, Sign In to add comment