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.

133 lines
4.3 KiB

12 years ago
  1. <?php
  2. require(__DATAGEN_CLASSES__ . '/ContentBlockGen.class.php');
  3. /**
  4. * The ContentBlock class defined here contains any
  5. * customized code for the ContentBlock class in the
  6. * Object Relational Model. It represents the "content_block" table
  7. * in the database, and extends from the code generated abstract ContentBlockGen
  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 ContentBlock extends ContentBlockGen {
  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 $objContentBlock->__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 'Location':
  33. return ($this->LocationId) ? BlockLocationType::$NameArray[$this->LocationId] : 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 'SomeNewProperty':
  48. // try {
  49. // return ($this->strSomeNewProperty = 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. // Override or Create New Load/Count methods
  64. // (For obvious reasons, these methods are commented out...
  65. // but feel free to use these as a starting point)
  66. /*
  67. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  68. // This will return an array of ContentBlock objects
  69. return ContentBlock::QueryArray(
  70. QQ::AndCondition(
  71. QQ::Equal(QQN::ContentBlock()->Param1, $strParam1),
  72. QQ::GreaterThan(QQN::ContentBlock()->Param2, $intParam2)
  73. ),
  74. $objOptionalClauses
  75. );
  76. }
  77. public static function LoadBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  78. // This will return a single ContentBlock object
  79. return ContentBlock::QuerySingle(
  80. QQ::AndCondition(
  81. QQ::Equal(QQN::ContentBlock()->Param1, $strParam1),
  82. QQ::GreaterThan(QQN::ContentBlock()->Param2, $intParam2)
  83. ),
  84. $objOptionalClauses
  85. );
  86. }
  87. public static function CountBySample($strParam1, $intParam2, $objOptionalClauses = null) {
  88. // This will return a count of ContentBlock objects
  89. return ContentBlock::QueryCount(
  90. QQ::AndCondition(
  91. QQ::Equal(QQN::ContentBlock()->Param1, $strParam1),
  92. QQ::Equal(QQN::ContentBlock()->Param2, $intParam2)
  93. ),
  94. $objOptionalClauses
  95. );
  96. }
  97. public static function LoadArrayBySample($strParam1, $intParam2, $objOptionalClauses) {
  98. // Performing the load manually (instead of using Qcodo Query)
  99. // Get the Database Object for this Class
  100. $objDatabase = ContentBlock::GetDatabase();
  101. // Properly Escape All Input Parameters using Database->SqlVariable()
  102. $strParam1 = $objDatabase->SqlVariable($strParam1);
  103. $intParam2 = $objDatabase->SqlVariable($intParam2);
  104. // Setup the SQL Query
  105. $strQuery = sprintf('
  106. SELECT
  107. `content_block`.*
  108. FROM
  109. `content_block` AS `content_block`
  110. WHERE
  111. param_1 = %s AND
  112. param_2 < %s',
  113. $strParam1, $intParam2);
  114. // Perform the Query and Instantiate the Result
  115. $objDbResult = $objDatabase->Query($strQuery);
  116. return ContentBlock::InstantiateDbResult($objDbResult);
  117. }
  118. */
  119. }
  120. ?>