A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
5.0 KiB

12 years ago
  1. <?php
  2. require(__DATAGEN_CLASSES__ . '/PersonGen.class.php');
  3. /**
  4. * The Person class defined here contains any
  5. * customized code for the Person class in the
  6. * Object Relational Model. It represents the "person" table
  7. * in the database, and extends from the code generated abstract PersonGen
  8. * class, which contains all the basic CRUD-type functionality as well as
  9. * basic methods to handle relationships and index-based loading.
  10. *
  11. * @package Quasi
  12. * @subpackage ORM
  13. *
  14. */
  15. class Person extends PersonGen {
  16. /**
  17. * Protected member variable that maps to the database PK Identity column person.id
  18. * @var integer intId
  19. */
  20. protected $intId;
  21. const IdDefault = null;
  22. /**
  23. * Protected member variable that maps to the database column person.address_id
  24. * @var integer intAddressId
  25. */
  26. protected $intAddressId;
  27. const AddressIdDefault = 1;
  28. /**
  29. * Protected member variable that maps to the database column person.is_virtual
  30. * @var boolean blnIsVirtual
  31. */
  32. protected $blnIsVirtual;
  33. const IsVirtualDefault = false;
  34. /**
  35. * Default "to string" handler
  36. * Allows pages to _p()/echo()/print() this object, and to define the default
  37. * way this object would be outputted.
  38. *
  39. * Can also be called directly via $objPerson->__toString().
  40. *
  41. * @return string a nicely formatted string representation of this object
  42. */
  43. public function __toString() {
  44. return $this->FirstName . ' ' . $this->LastName;
  45. }
  46. public function __get($strName)
  47. {
  48. switch ($strName)
  49. {
  50. case 'FullName':
  51. return $this->FirstName . ' ' . $this->LastName;
  52. case 'ProperName':
  53. $strToReturn = '';
  54. if('' != $this->NamePrefix )
  55. $strToReturn .= $this->NamePrefix . ' ';
  56. $strToReturn .= $this->FirstName . ' ';
  57. if('' != $this->MiddleName )
  58. $strToReturn .= $this->MiddleName . ' ';
  59. $strToReturn .= $this->LastName. ' ';
  60. if('' != $this->NameSuffix )
  61. $strToReturn .= $this->NameSuffix . ' ';
  62. return $strToReturn;
  63. default:
  64. try {
  65. return parent::__get($strName);
  66. } catch (QCallerException $objExc) {
  67. $objExc->IncrementOffset();
  68. throw $objExc;
  69. }
  70. }
  71. }
  72. public function __set($strName, $mixValue)
  73. {
  74. switch ($strName)
  75. {
  76. default:
  77. try {
  78. return (parent::__set($strName, $mixValue));
  79. } catch (QCallerException $objExc) {
  80. $objExc->IncrementOffset();
  81. throw $objExc;
  82. }
  83. }
  84. }
  85. // Override or Create New Load/Count methods
  86. // (For obvious reasons, these methods are commented out...
  87. // but feel free to use these as a starting point)
  88. /*
  89. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  90. // This will return an array of Person objects
  91. return Person::QueryArray(
  92. QQ::AndCondition(
  93. QQ::Equal(QQN::Person()->Param1, $strParam1),
  94. QQ::GreaterThan(QQN::Person()->Param2, $intParam2)
  95. ),
  96. $objOptionalClauses
  97. );
  98. }
  99. public static function LoadBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  100. // This will return a single Person object
  101. return Person::QuerySingle(
  102. QQ::AndCondition(
  103. QQ::Equal(QQN::Person()->Param1, $strParam1),
  104. QQ::GreaterThan(QQN::Person()->Param2, $intParam2)
  105. ),
  106. $objOptionalClauses
  107. );
  108. }
  109. public static function CountBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  110. // This will return a count of Person objects
  111. return Person::QueryCount(
  112. QQ::AndCondition(
  113. QQ::Equal(QQN::Person()->Param1, $strParam1),
  114. QQ::Equal(QQN::Person()->Param2, $intParam2)
  115. ),
  116. $objOptionalClauses
  117. );
  118. }
  119. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses) {
  120. // Performing the load manually (instead of using Qcodo Query)
  121. // Get the Database Object for this Class
  122. $objDatabase = Person::GetDatabase();
  123. // Properly Escape All Input Parameters using Database->SqlVariable()
  124. $strParam1 = $objDatabase->SqlVariable($strParam1);
  125. $intParam2 = $objDatabase->SqlVariable($intParam2);
  126. // Setup the SQL Query
  127. $strQuery = sprintf('
  128. SELECT
  129. `person`.*
  130. FROM
  131. `person` AS `person`
  132. WHERE
  133. param_1 = %s AND
  134. param_2 < %s',
  135. $strParam1, $intParam2);
  136. // Perform the Query and Instantiate the Result
  137. $objDbResult = $objDatabase->Query($strQuery);
  138. return Person::InstantiateDbResult($objDbResult);
  139. }
  140. */
  141. }
  142. ?>