A QCodo powered CMS
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.

154 lines
4.2 KiB

  1. <?php
  2. require(__DATAGEN_CLASSES__ . '/MenuGen.class.php');
  3. /**
  4. * The Menu class defined here contains any
  5. * customized code for the Menu class in the
  6. * Object Relational Model. It represents the "menu" table
  7. * in the database, and extends from the code generated abstract MenuGen
  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 Quinta
  12. * @subpackage Models
  13. *
  14. */
  15. class Menu extends MenuGen {
  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 $objMenu->__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) ? MenuType::$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 Menu objects
  49. return Menu::QueryArray(
  50. QQ::AndCondition(
  51. QQ::Equal(QQN::Menu()->Param1, $strParam1),
  52. QQ::GreaterThan(QQN::Menu()->Param2, $intParam2)
  53. ),
  54. $objOptionalClauses
  55. );
  56. }
  57. public static function LoadBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  58. // This will return a single Menu object
  59. return Menu::QuerySingle(
  60. QQ::AndCondition(
  61. QQ::Equal(QQN::Menu()->Param1, $strParam1),
  62. QQ::GreaterThan(QQN::Menu()->Param2, $intParam2)
  63. ),
  64. $objOptionalClauses
  65. );
  66. }
  67. public static function CountBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  68. // This will return a count of Menu objects
  69. return Menu::QueryCount(
  70. QQ::AndCondition(
  71. QQ::Equal(QQN::Menu()->Param1, $strParam1),
  72. QQ::Equal(QQN::Menu()->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 = Menu::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`.*
  88. FROM
  89. `menu` AS `menu`
  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 Menu::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. ?>