client.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace MGModule\DNSManager2\models\whmcs\client;
  3. use MGModule\DNSManager2 as main;
  4. /**
  5. * Client Model
  6. *
  7. * @author Michal Czech <michael@modulesgarden.com>
  8. */
  9. class client extends \MGModule\DNSManager2\mgLibs\models\orm{
  10. static $tableStructure = array(
  11. 'name' => 'tblclients'
  12. );
  13. static $fieldDeclaration = array(
  14. 'id'
  15. ,'firstname'
  16. ,'lastname'
  17. ,'email'
  18. );
  19. public $id;
  20. public $firstname;
  21. public $lastname;
  22. public $email;
  23. /**
  24. * Load Client
  25. *
  26. * @author Michal Czech <michael@modulesgarden.com>
  27. * @param int $id
  28. * @param array $data
  29. */
  30. function __construct($id = 0,$data = array())
  31. {
  32. $this->id = $id;
  33. if($id && empty($data))
  34. {
  35. $data = main\mgLibs\MySQL\query::select(
  36. self::$fieldDeclaration,
  37. self::$tableStructure['name'],
  38. array(
  39. 'id' => $id
  40. )
  41. );
  42. }
  43. if(!empty($data))
  44. {
  45. $this->fillProperties($data);
  46. }
  47. }
  48. }