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.

139 lines
4.1 KiB

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