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.

155 lines
4.5 KiB

13 years ago
  1. <?php
  2. require(__DATAGEN_CLASSES__ . '/MenuItemGen.class.php');
  3. /**
  4. * The MenuItem class defined here contains any
  5. * customized code for the MenuItem class in the
  6. * Object Relational Model. It represents the "menu_item" table
  7. * in the database, and extends from the code generated abstract MenuItemGen
  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 MenuItem extends MenuItemGen {
  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 $objMenuItem->__toString().
  22. *
  23. * @return string a nicely formatted string representation of this object
  24. */
  25. public function __toString() {
  26. return sprintf('%s', $this->Name);
  27. }
  28. public function __get($strName)
  29. {
  30. switch ($strName)
  31. {
  32. case 'Type':
  33. return ($this->TypeId) ? MenuItemType::$NameArray[$this->TypeId] : null;
  34. default:
  35. try {
  36. return parent::__get($strName);
  37. } catch (QCallerException $objExc) {
  38. $objExc->IncrementOffset();
  39. throw $objExc;
  40. }
  41. }
  42. }
  43. // Override or Create New Load/Count methods
  44. // (For obvious reasons, these methods are commented out...
  45. // but feel free to use these as a starting point)
  46. /*
  47. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  48. // This will return an array of MenuItem objects
  49. return MenuItem::QueryArray(
  50. QQ::AndCondition(
  51. QQ::Equal(QQN::MenuItem()->Param1, $strParam1),
  52. QQ::GreaterThan(QQN::MenuItem()->Param2, $intParam2)
  53. ),
  54. $objOptionalClauses
  55. );
  56. }
  57. public static function LoadBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  58. // This will return a single MenuItem object
  59. return MenuItem::QuerySingle(
  60. QQ::AndCondition(
  61. QQ::Equal(QQN::MenuItem()->Param1, $strParam1),
  62. QQ::GreaterThan(QQN::MenuItem()->Param2, $intParam2)
  63. ),
  64. $objOptionalClauses
  65. );
  66. }
  67. public static function CountBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  68. // This will return a count of MenuItem objects
  69. return MenuItem::QueryCount(
  70. QQ::AndCondition(
  71. QQ::Equal(QQN::MenuItem()->Param1, $strParam1),
  72. QQ::Equal(QQN::MenuItem()->Param2, $intParam2)
  73. ),
  74. $objOptionalClauses
  75. );
  76. }
  77. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses) {
  78. // Performing the load manually (instead of using Qcodo Query)
  79. // Get the Database Object for this Class
  80. $objDatabase = MenuItem::GetDatabase();
  81. // Properly Escape All Input Parameters using Database->SqlVariable()
  82. $strParam1 = $objDatabase->SqlVariable($strParam1);
  83. $intParam2 = $objDatabase->SqlVariable($intParam2);
  84. // Setup the SQL Query
  85. $strQuery = sprintf('
  86. SELECT
  87. `menu_item`.*
  88. FROM
  89. `menu_item` AS `menu_item`
  90. WHERE
  91. param_1 = %s AND
  92. param_2 < %s',
  93. $strParam1, $intParam2);
  94. // Perform the Query and Instantiate the Result
  95. $objDbResult = $objDatabase->Query($strQuery);
  96. return MenuItem::InstantiateDbResult($objDbResult);
  97. }
  98. */
  99. // Override or Create New Properties and Variables
  100. // For performance reasons, these variables and __set and __get override methods
  101. // are commented out. But if you wish to implement or override any
  102. // of the data generated properties, please feel free to uncomment them.
  103. /*
  104. protected $strSomeNewProperty;
  105. public function __get($strName) {
  106. switch ($strName) {
  107. case 'SomeNewProperty': return $this->strSomeNewProperty;
  108. default:
  109. try {
  110. return parent::__get($strName);
  111. } catch (QCallerException $objExc) {
  112. $objExc->IncrementOffset();
  113. throw $objExc;
  114. }
  115. }
  116. }
  117. public function __set($strName, $mixValue) {
  118. switch ($strName) {
  119. case 'SomeNewProperty':
  120. try {
  121. return ($this->strSomeNewProperty = QType::Cast($mixValue, QType::String));
  122. } catch (QInvalidCastException $objExc) {
  123. $objExc->IncrementOffset();
  124. throw $objExc;
  125. }
  126. default:
  127. try {
  128. return (parent::__set($strName, $mixValue));
  129. } catch (QCallerException $objExc) {
  130. $objExc->IncrementOffset();
  131. throw $objExc;
  132. }
  133. }
  134. }
  135. */
  136. }
  137. ?>