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.

173 lines
6.0 KiB

12 years ago
  1. <?php
  2. require(__DATAGEN_CLASSES__ . '/OrderStatusHistoryGen.class.php');
  3. /**
  4. * The OrderStatusHistory class defined here contains any
  5. * customized code for the OrderStatusHistory class in the
  6. * Object Relational Model. It represents the "order_status_history" table
  7. * in the database, and extends from the code generated abstract OrderStatusHistoryGen
  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 OrderStatusHistory extends OrderStatusHistoryGen {
  16. /**
  17. * Default "to string" handler
  18. * Allows pages to _p()/echo()/print() this object, and to define the default
  19. * way this object would be outputted.
  20. *
  21. * Can also be called directly via $objOrderStatusHistory->__toString().
  22. *
  23. * @return string a nicely formatted string representation of this object
  24. */
  25. public function __toString() {
  26. return sprintf('Order Status: %s - %s', $this->strDate, $this->intOrderId);
  27. }
  28. public function __get($strName)
  29. {
  30. switch ($strName)
  31. {
  32. case 'Status':
  33. return ($this->intStatusId ? OrderStatusType::ToString($this->intStatusId) : null);
  34. default:
  35. try {
  36. return parent::__get($strName);
  37. } catch (QCallerException $objExc) {
  38. $objExc->IncrementOffset();
  39. throw $objExc;
  40. }
  41. }
  42. }
  43. public function __set($strName, $mixValue)
  44. {
  45. switch ($strName)
  46. {
  47. case 'Date':
  48. try {
  49. return ($this->strDate = QType::Cast($mixValue, QType::String));
  50. } catch (QInvalidCastException $objExc) {
  51. $objExc->IncrementOffset();
  52. throw $objExc;
  53. }
  54. default:
  55. try {
  56. return (parent::__set($strName, $mixValue));
  57. } catch (QCallerException $objExc) {
  58. $objExc->IncrementOffset();
  59. throw $objExc;
  60. }
  61. }
  62. }
  63. /**
  64. * Insert this OrderStatusHistory - this is to support setting the Date timestamp
  65. * @return void
  66. */
  67. public function InsertDated()
  68. {
  69. $objDatabase = OrderStatusHistory::GetDatabase();
  70. $strQuery = 'INSERT INTO `order_status_history` (
  71. `order_id`,
  72. `date`,
  73. `notes`,
  74. `status_id`
  75. ) VALUES (
  76. ' . $objDatabase->SqlVariable($this->intOrderId) . ',
  77. ' . $objDatabase->SqlVariable($this->strDate) . ',
  78. ' . $objDatabase->SqlVariable($this->strNotes) . ',
  79. ' . $objDatabase->SqlVariable($this->intStatusId) . '
  80. )';
  81. try {
  82. $objDatabase->NonQuery($strQuery);
  83. } catch (QCallerException $objExc) {
  84. $objExc->IncrementOffset();
  85. throw $objExc;
  86. }
  87. $this->intId = OrderStatusHistory::GetDatabase()->InsertId('order_status_history', 'id');
  88. $this->__blnRestored = true;
  89. $this->Reload();
  90. }
  91. // Override or Create New Load/Count methods
  92. // (For obvious reasons, these methods are commented out...
  93. // but feel free to use these as a starting point)
  94. /*
  95. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  96. // This will return an array of OrderStatusHistory objects
  97. return OrderStatusHistory::QueryArray(
  98. QQ::AndCondition(
  99. QQ::Equal(QQN::OrderStatusHistory()->Param1, $strParam1),
  100. QQ::GreaterThan(QQN::OrderStatusHistory()->Param2, $intParam2)
  101. ),
  102. $objOptionalClauses
  103. );
  104. }
  105. public static function LoadBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  106. // This will return a single OrderStatusHistory object
  107. return OrderStatusHistory::QuerySingle(
  108. QQ::AndCondition(
  109. QQ::Equal(QQN::OrderStatusHistory()->Param1, $strParam1),
  110. QQ::GreaterThan(QQN::OrderStatusHistory()->Param2, $intParam2)
  111. ),
  112. $objOptionalClauses
  113. );
  114. }
  115. public static function CountBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  116. // This will return a count of OrderStatusHistory objects
  117. return OrderStatusHistory::QueryCount(
  118. QQ::AndCondition(
  119. QQ::Equal(QQN::OrderStatusHistory()->Param1, $strParam1),
  120. QQ::Equal(QQN::OrderStatusHistory()->Param2, $intParam2)
  121. ),
  122. $objOptionalClauses
  123. );
  124. }
  125. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses) {
  126. // Performing the load manually (instead of using Qcodo Query)
  127. // Get the Database Object for this Class
  128. $objDatabase = OrderStatusHistory::GetDatabase();
  129. // Properly Escape All Input Parameters using Database->SqlVariable()
  130. $strParam1 = $objDatabase->SqlVariable($strParam1);
  131. $intParam2 = $objDatabase->SqlVariable($intParam2);
  132. // Setup the SQL Query
  133. $strQuery = sprintf('
  134. SELECT
  135. `order_status_history`.*
  136. FROM
  137. `order_status_history` AS `order_status_history`
  138. WHERE
  139. param_1 = %s AND
  140. param_2 < %s',
  141. $strParam1, $intParam2);
  142. // Perform the Query and Instantiate the Result
  143. $objDbResult = $objDatabase->Query($strQuery);
  144. return OrderStatusHistory::InstantiateDbResult($objDbResult);
  145. }
  146. */
  147. // Override or Create New Properties and Variables
  148. // For performance reasons, these variables and __set and __get override methods
  149. // are commented out. But if you wish to implement or override any
  150. // of the data generated properties, please feel free to uncomment them.
  151. /*
  152. protected $strSomeNewProperty;
  153. */
  154. }
  155. ?>