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.

831 lines
33 KiB

  1. <?php
  2. /**
  3. * The abstract ShippingRateGen class defined here is
  4. * code-generated and contains all the basic CRUD-type functionality as well as
  5. * basic methods to handle relationships and index-based loading.
  6. *
  7. * To use, you should use the ShippingRate subclass which
  8. * extends this ShippingRateGen class.
  9. *
  10. * Because subsequent re-code generations will overwrite any changes to this
  11. * file, you should leave this file unaltered to prevent yourself from losing
  12. * any information or code changes. All customizations should be done by
  13. * overriding existing or implementing new methods, properties and variables
  14. * in the ShippingRate class.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage GeneratedDataObjects
  18. * @property-read integer $Id the value for intId (Read-Only PK)
  19. * @property-read string $CreationDate the value for strCreationDate (Read-Only Timestamp)
  20. * @property double $Rate the value for fltRate (Not Null)
  21. * @property integer $ZoneId the value for intZoneId (Unique)
  22. * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
  23. */
  24. class ShippingRateGen extends QBaseClass
  25. {
  26. ///////////////////////////////////////////////////////////////////////
  27. // PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
  28. ///////////////////////////////////////////////////////////////////////
  29. /////////// Object properties ////////////
  30. /**
  31. * Protected member variable that maps to the database PK Identity column shipping_rate.id
  32. * @var integer intId
  33. *
  34. */
  35. protected $intId = null;
  36. /**
  37. * Protected member variable that maps to the database column shipping_rate.creation_date
  38. * @var string strCreationDate
  39. *
  40. */
  41. protected $strCreationDate = null;
  42. /**
  43. * Protected member variable that maps to the database column shipping_rate.rate
  44. * @var double fltRate
  45. *
  46. */
  47. protected $fltRate = null;
  48. /**
  49. * Protected member variable that maps to the database column shipping_rate.zone_id
  50. * @var integer intZoneId
  51. *
  52. */
  53. protected $intZoneId = null;
  54. /**
  55. * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
  56. * columns from the run-time database query result for this object). Used by InstantiateDbRow and
  57. * GetVirtualAttribute.
  58. * @var string[] $__strVirtualAttributeArray
  59. */
  60. protected $__strVirtualAttributeArray = array();
  61. /**
  62. * Protected internal member variable that specifies whether or not this object is Restored from the database.
  63. * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
  64. * @var bool __blnRestored;
  65. */
  66. protected $__blnRestored;
  67. ///////////////////////////////
  68. // PROTECTED MEMBER OBJECTS
  69. ///////////////////////////////
  70. ///////////////////////////////
  71. // CLASS-WIDE LOAD AND COUNT METHODS
  72. ///////////////////////////////
  73. /**
  74. * Static method to retrieve the Database object that owns this class.
  75. * @return QDatabaseBase reference to the Database object that can query this class
  76. */
  77. public static function GetDatabase() {
  78. return QApplication::$Database[1];
  79. }
  80. /**
  81. * Load a ShippingRate from PK Info
  82. * @param integer $intId
  83. * @return ShippingRate
  84. */
  85. public static function Load($intId) {
  86. // Use QuerySingle to Perform the Query
  87. return ShippingRate::QuerySingle(
  88. QQ::Equal(QQN::ShippingRate()->Id, $intId)
  89. );
  90. }
  91. /**
  92. * Load all ShippingRates
  93. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  94. * @return ShippingRate[]
  95. */
  96. public static function LoadAll($objOptionalClauses = null) {
  97. // Call ShippingRate::QueryArray to perform the LoadAll query
  98. try {
  99. return ShippingRate::QueryArray(QQ::All(), $objOptionalClauses);
  100. } catch (QCallerException $objExc) {
  101. $objExc->IncrementOffset();
  102. throw $objExc;
  103. }
  104. }
  105. /**
  106. * Count all ShippingRates
  107. * @return int
  108. */
  109. public static function CountAll() {
  110. // Call ShippingRate::QueryCount to perform the CountAll query
  111. return ShippingRate::QueryCount(QQ::All());
  112. }
  113. ///////////////////////////////
  114. // QCODO QUERY-RELATED METHODS
  115. ///////////////////////////////
  116. /**
  117. * Internally called method to assist with calling Qcodo Query for this class
  118. * on load methods.
  119. * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
  120. * @param QQCondition $objConditions any conditions on the query, itself
  121. * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
  122. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
  123. * @param boolean $blnCountOnly only select a rowcount
  124. * @return string the query statement
  125. */
  126. protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
  127. // Get the Database Object for this Class
  128. $objDatabase = ShippingRate::GetDatabase();
  129. // Create/Build out the QueryBuilder object with ShippingRate-specific SELET and FROM fields
  130. $objQueryBuilder = new QQueryBuilder($objDatabase, 'shipping_rate');
  131. ShippingRate::GetSelectFields($objQueryBuilder);
  132. $objQueryBuilder->AddFromItem('shipping_rate');
  133. // Set "CountOnly" option (if applicable)
  134. if ($blnCountOnly)
  135. $objQueryBuilder->SetCountOnlyFlag();
  136. // Apply Any Conditions
  137. if ($objConditions)
  138. try {
  139. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  140. } catch (QCallerException $objExc) {
  141. $objExc->IncrementOffset();
  142. throw $objExc;
  143. }
  144. // Iterate through all the Optional Clauses (if any) and perform accordingly
  145. if ($objOptionalClauses) {
  146. if ($objOptionalClauses instanceof QQClause)
  147. $objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
  148. else if (is_array($objOptionalClauses))
  149. foreach ($objOptionalClauses as $objClause)
  150. $objClause->UpdateQueryBuilder($objQueryBuilder);
  151. else
  152. throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
  153. }
  154. // Get the SQL Statement
  155. $strQuery = $objQueryBuilder->GetStatement();
  156. // Prepare the Statement with the Query Parameters (if applicable)
  157. if ($mixParameterArray) {
  158. if (is_array($mixParameterArray)) {
  159. if (count($mixParameterArray))
  160. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  161. // Ensure that there are no other Unresolved Named Parameters
  162. if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
  163. throw new QCallerException('Unresolved named parameters in the query');
  164. } else
  165. throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
  166. }
  167. // Return the Objects
  168. return $strQuery;
  169. }
  170. /**
  171. * Static Qcodo Query method to query for a single ShippingRate object.
  172. * Uses BuildQueryStatment to perform most of the work.
  173. * @param QQCondition $objConditions any conditions on the query, itself
  174. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  175. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  176. * @return ShippingRate the queried object
  177. */
  178. public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  179. // Get the Query Statement
  180. try {
  181. $strQuery = ShippingRate::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  182. } catch (QCallerException $objExc) {
  183. $objExc->IncrementOffset();
  184. throw $objExc;
  185. }
  186. // Perform the Query, Get the First Row, and Instantiate a new ShippingRate object
  187. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  188. return ShippingRate::InstantiateDbRow($objDbResult->GetNextRow(), null, null, null, $objQueryBuilder->ColumnAliasArray);
  189. }
  190. /**
  191. * Static Qcodo Query method to query for an array of ShippingRate objects.
  192. * Uses BuildQueryStatment to perform most of the work.
  193. * @param QQCondition $objConditions any conditions on the query, itself
  194. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  195. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  196. * @return ShippingRate[] the queried objects as an array
  197. */
  198. public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  199. // Get the Query Statement
  200. try {
  201. $strQuery = ShippingRate::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  202. } catch (QCallerException $objExc) {
  203. $objExc->IncrementOffset();
  204. throw $objExc;
  205. }
  206. // Perform the Query and Instantiate the Array Result
  207. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  208. return ShippingRate::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
  209. }
  210. /**
  211. * Static Qcodo Query method to query for a count of ShippingRate objects.
  212. * Uses BuildQueryStatment to perform most of the work.
  213. * @param QQCondition $objConditions any conditions on the query, itself
  214. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  215. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  216. * @return integer the count of queried objects as an integer
  217. */
  218. public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  219. // Get the Query Statement
  220. try {
  221. $strQuery = ShippingRate::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
  222. } catch (QCallerException $objExc) {
  223. $objExc->IncrementOffset();
  224. throw $objExc;
  225. }
  226. // Perform the Query and return the row_count
  227. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  228. // Figure out if the query is using GroupBy
  229. $blnGrouped = false;
  230. if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
  231. if ($objClause instanceof QQGroupBy) {
  232. $blnGrouped = true;
  233. break;
  234. }
  235. }
  236. if ($blnGrouped)
  237. // Groups in this query - return the count of Groups (which is the count of all rows)
  238. return $objDbResult->CountRows();
  239. else {
  240. // No Groups - return the sql-calculated count(*) value
  241. $strDbRow = $objDbResult->FetchRow();
  242. return QType::Cast($strDbRow[0], QType::Integer);
  243. }
  244. }
  245. /* public static function QueryArrayCached($strConditions, $mixParameterArray = null) {
  246. // Get the Database Object for this Class
  247. $objDatabase = ShippingRate::GetDatabase();
  248. // Lookup the QCache for This Query Statement
  249. $objCache = new QCache('query', 'shipping_rate_' . serialize($strConditions));
  250. if (!($strQuery = $objCache->GetData())) {
  251. // Not Found -- Go ahead and Create/Build out a new QueryBuilder object with ShippingRate-specific fields
  252. $objQueryBuilder = new QQueryBuilder($objDatabase);
  253. ShippingRate::GetSelectFields($objQueryBuilder);
  254. ShippingRate::GetFromFields($objQueryBuilder);
  255. // Ensure the Passed-in Conditions is a string
  256. try {
  257. $strConditions = QType::Cast($strConditions, QType::String);
  258. } catch (QCallerException $objExc) {
  259. $objExc->IncrementOffset();
  260. throw $objExc;
  261. }
  262. // Create the Conditions object, and apply it
  263. $objConditions = eval('return ' . $strConditions . ';');
  264. // Apply Any Conditions
  265. if ($objConditions)
  266. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  267. // Get the SQL Statement
  268. $strQuery = $objQueryBuilder->GetStatement();
  269. // Save the SQL Statement in the Cache
  270. $objCache->SaveData($strQuery);
  271. }
  272. // Prepare the Statement with the Parameters
  273. if ($mixParameterArray)
  274. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  275. // Perform the Query and Instantiate the Array Result
  276. $objDbResult = $objDatabase->Query($strQuery);
  277. return ShippingRate::InstantiateDbResult($objDbResult);
  278. }*/
  279. /**
  280. * Updates a QQueryBuilder with the SELECT fields for this ShippingRate
  281. * @param QQueryBuilder $objBuilder the Query Builder object to update
  282. * @param string $strPrefix optional prefix to add to the SELECT fields
  283. */
  284. public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
  285. if ($strPrefix) {
  286. $strTableName = $strPrefix;
  287. $strAliasPrefix = $strPrefix . '__';
  288. } else {
  289. $strTableName = 'shipping_rate';
  290. $strAliasPrefix = '';
  291. }
  292. $objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
  293. $objBuilder->AddSelectItem($strTableName, 'creation_date', $strAliasPrefix . 'creation_date');
  294. $objBuilder->AddSelectItem($strTableName, 'rate', $strAliasPrefix . 'rate');
  295. $objBuilder->AddSelectItem($strTableName, 'zone_id', $strAliasPrefix . 'zone_id');
  296. }
  297. ///////////////////////////////
  298. // INSTANTIATION-RELATED METHODS
  299. ///////////////////////////////
  300. /**
  301. * Instantiate a ShippingRate from a Database Row.
  302. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  303. * is calling this ShippingRate::InstantiateDbRow in order to perform
  304. * early binding on referenced objects.
  305. * @param DatabaseRowBase $objDbRow
  306. * @param string $strAliasPrefix
  307. * @param string $strExpandAsArrayNodes
  308. * @param QBaseClass $objPreviousItem
  309. * @param string[] $strColumnAliasArray
  310. * @return ShippingRate
  311. */
  312. public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array()) {
  313. // If blank row, return null
  314. if (!$objDbRow)
  315. return null;
  316. // Create a new instance of the ShippingRate object
  317. $objToReturn = new ShippingRate();
  318. $objToReturn->__blnRestored = true;
  319. $strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
  320. $objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
  321. $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date';
  322. $objToReturn->strCreationDate = $objDbRow->GetColumn($strAliasName, 'VarChar');
  323. $strAliasName = array_key_exists($strAliasPrefix . 'rate', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'rate'] : $strAliasPrefix . 'rate';
  324. $objToReturn->fltRate = $objDbRow->GetColumn($strAliasName, 'Float');
  325. $strAliasName = array_key_exists($strAliasPrefix . 'zone_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'zone_id'] : $strAliasPrefix . 'zone_id';
  326. $objToReturn->intZoneId = $objDbRow->GetColumn($strAliasName, 'Integer');
  327. // Instantiate Virtual Attributes
  328. foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
  329. $strVirtualPrefix = $strAliasPrefix . '__';
  330. $strVirtualPrefixLength = strlen($strVirtualPrefix);
  331. if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
  332. $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
  333. }
  334. // Prepare to Check for Early/Virtual Binding
  335. if (!$strAliasPrefix)
  336. $strAliasPrefix = 'shipping_rate__';
  337. return $objToReturn;
  338. }
  339. /**
  340. * Instantiate an array of ShippingRates from a Database Result
  341. * @param DatabaseResultBase $objDbResult
  342. * @param string $strExpandAsArrayNodes
  343. * @param string[] $strColumnAliasArray
  344. * @return ShippingRate[]
  345. */
  346. public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
  347. $objToReturn = array();
  348. if (!$strColumnAliasArray)
  349. $strColumnAliasArray = array();
  350. // If blank resultset, then return empty array
  351. if (!$objDbResult)
  352. return $objToReturn;
  353. // Load up the return array with each row
  354. if ($strExpandAsArrayNodes) {
  355. $objLastRowItem = null;
  356. while ($objDbRow = $objDbResult->GetNextRow()) {
  357. $objItem = ShippingRate::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
  358. if ($objItem) {
  359. $objToReturn[] = $objItem;
  360. $objLastRowItem = $objItem;
  361. }
  362. }
  363. } else {
  364. while ($objDbRow = $objDbResult->GetNextRow())
  365. $objToReturn[] = ShippingRate::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
  366. }
  367. return $objToReturn;
  368. }
  369. ///////////////////////////////////////////////////
  370. // INDEX-BASED LOAD METHODS (Single Load and Array)
  371. ///////////////////////////////////////////////////
  372. /**
  373. * Load a single ShippingRate object,
  374. * by Id Index(es)
  375. * @param integer $intId
  376. * @return ShippingRate
  377. */
  378. public static function LoadById($intId) {
  379. return ShippingRate::QuerySingle(
  380. QQ::Equal(QQN::ShippingRate()->Id, $intId)
  381. );
  382. }
  383. /**
  384. * Load a single ShippingRate object,
  385. * by ZoneId Index(es)
  386. * @param integer $intZoneId
  387. * @return ShippingRate
  388. */
  389. public static function LoadByZoneId($intZoneId) {
  390. return ShippingRate::QuerySingle(
  391. QQ::Equal(QQN::ShippingRate()->ZoneId, $intZoneId)
  392. );
  393. }
  394. ////////////////////////////////////////////////////
  395. // INDEX-BASED LOAD METHODS (Array via Many to Many)
  396. ////////////////////////////////////////////////////
  397. //////////////////////////
  398. // SAVE, DELETE AND RELOAD
  399. //////////////////////////
  400. /**
  401. * Save this ShippingRate
  402. * @param bool $blnForceInsert
  403. * @param bool $blnForceUpdate
  404. * @return int
  405. */
  406. public function Save($blnForceInsert = false, $blnForceUpdate = false) {
  407. // Get the Database Object for this Class
  408. $objDatabase = ShippingRate::GetDatabase();
  409. $mixToReturn = null;
  410. try {
  411. if ((!$this->__blnRestored) || ($blnForceInsert)) {
  412. // Perform an INSERT query
  413. $objDatabase->NonQuery('
  414. INSERT INTO `shipping_rate` (
  415. `rate`,
  416. `zone_id`
  417. ) VALUES (
  418. ' . $objDatabase->SqlVariable($this->fltRate) . ',
  419. ' . $objDatabase->SqlVariable($this->intZoneId) . '
  420. )
  421. ');
  422. // Update Identity column and return its value
  423. $mixToReturn = $this->intId = $objDatabase->InsertId('shipping_rate', 'id');
  424. } else {
  425. // Perform an UPDATE query
  426. // First checking for Optimistic Locking constraints (if applicable)
  427. if (!$blnForceUpdate) {
  428. // Perform the Optimistic Locking check
  429. $objResult = $objDatabase->Query('
  430. SELECT
  431. `creation_date`
  432. FROM
  433. `shipping_rate`
  434. WHERE
  435. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  436. ');
  437. $objRow = $objResult->FetchArray();
  438. if ($objRow[0] != $this->strCreationDate)
  439. throw new QOptimisticLockingException('ShippingRate');
  440. }
  441. // Perform the UPDATE query
  442. $objDatabase->NonQuery('
  443. UPDATE
  444. `shipping_rate`
  445. SET
  446. `rate` = ' . $objDatabase->SqlVariable($this->fltRate) . ',
  447. `zone_id` = ' . $objDatabase->SqlVariable($this->intZoneId) . '
  448. WHERE
  449. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  450. ');
  451. }
  452. } catch (QCallerException $objExc) {
  453. $objExc->IncrementOffset();
  454. throw $objExc;
  455. }
  456. // Update __blnRestored and any Non-Identity PK Columns (if applicable)
  457. $this->__blnRestored = true;
  458. // Update Local Timestamp
  459. $objResult = $objDatabase->Query('
  460. SELECT
  461. `creation_date`
  462. FROM
  463. `shipping_rate`
  464. WHERE
  465. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  466. ');
  467. $objRow = $objResult->FetchArray();
  468. $this->strCreationDate = $objRow[0];
  469. // Return
  470. return $mixToReturn;
  471. }
  472. /**
  473. * Delete this ShippingRate
  474. * @return void
  475. */
  476. public function Delete() {
  477. if ((is_null($this->intId)))
  478. throw new QUndefinedPrimaryKeyException('Cannot delete this ShippingRate with an unset primary key.');
  479. // Get the Database Object for this Class
  480. $objDatabase = ShippingRate::GetDatabase();
  481. // Perform the SQL Query
  482. $objDatabase->NonQuery('
  483. DELETE FROM
  484. `shipping_rate`
  485. WHERE
  486. `id` = ' . $objDatabase->SqlVariable($this->intId) . '');
  487. }
  488. /**
  489. * Delete all ShippingRates
  490. * @return void
  491. */
  492. public static function DeleteAll() {
  493. // Get the Database Object for this Class
  494. $objDatabase = ShippingRate::GetDatabase();
  495. // Perform the Query
  496. $objDatabase->NonQuery('
  497. DELETE FROM
  498. `shipping_rate`');
  499. }
  500. /**
  501. * Truncate shipping_rate table
  502. * @return void
  503. */
  504. public static function Truncate() {
  505. // Get the Database Object for this Class
  506. $objDatabase = ShippingRate::GetDatabase();
  507. // Perform the Query
  508. $objDatabase->NonQuery('
  509. TRUNCATE `shipping_rate`');
  510. }
  511. /**
  512. * Reload this ShippingRate from the database.
  513. * @return void
  514. */
  515. public function Reload() {
  516. // Make sure we are actually Restored from the database
  517. if (!$this->__blnRestored)
  518. throw new QCallerException('Cannot call Reload() on a new, unsaved ShippingRate object.');
  519. // Reload the Object
  520. $objReloaded = ShippingRate::Load($this->intId);
  521. // Update $this's local variables to match
  522. $this->strCreationDate = $objReloaded->strCreationDate;
  523. $this->fltRate = $objReloaded->fltRate;
  524. $this->ZoneId = $objReloaded->ZoneId;
  525. }
  526. ////////////////////
  527. // GETTORS AND SETTORS
  528. ////////////////////
  529. /**
  530. * Lookup a VirtualAttribute value (if applicable). Returns NULL if none found.
  531. * @param string $strName
  532. * @return string
  533. */
  534. public function GetVirtualAttribute($strName)
  535. {
  536. if (array_key_exists($strName, $this->__strVirtualAttributeArray))
  537. return $this->__strVirtualAttributeArray[$strName];
  538. return null;
  539. }
  540. /**
  541. * Override method to perform a property "Get"
  542. * This will get the value of $strName
  543. *
  544. * @param string $strName Name of the property to get
  545. * @return mixed
  546. */
  547. public function __get($strName)
  548. {
  549. switch ($strName)
  550. {
  551. ///////////////////
  552. // Member Variables
  553. ///////////////////
  554. case 'Id':
  555. /**
  556. * Gets the value for intId (Read-Only PK)
  557. * @return integer
  558. */
  559. return $this->intId;
  560. case 'CreationDate':
  561. /**
  562. * Gets the value for strCreationDate (Read-Only Timestamp)
  563. * @return string
  564. */
  565. return $this->strCreationDate;
  566. case 'Rate':
  567. /**
  568. * Gets the value for fltRate (Not Null)
  569. * @return double
  570. */
  571. return $this->fltRate;
  572. case 'ZoneId':
  573. /**
  574. * Gets the value for intZoneId (Unique)
  575. * @return integer
  576. */
  577. return $this->intZoneId;
  578. ///////////////////
  579. // Member Objects
  580. ///////////////////
  581. ////////////////////////////
  582. // Virtual Object References (Many to Many and Reverse References)
  583. // (If restored via a "Many-to" expansion)
  584. ////////////////////////////
  585. case '__Restored':
  586. return $this->__blnRestored;
  587. default:
  588. try {
  589. return parent::__get($strName);
  590. } catch (QCallerException $objExc) {
  591. $objExc->IncrementOffset();
  592. throw $objExc;
  593. }
  594. }
  595. }
  596. /**
  597. * Override method to perform a property "Set"
  598. * This will set the property $strName to be $mixValue
  599. *
  600. * @param string $strName Name of the property to set
  601. * @param string $mixValue New value of the property
  602. * @return mixed
  603. */
  604. public function __set($strName, $mixValue) {
  605. switch ($strName) {
  606. ///////////////////
  607. // Member Variables
  608. ///////////////////
  609. case 'Rate':
  610. /**
  611. * Sets the value for fltRate (Not Null)
  612. * @param double $mixValue
  613. * @return double
  614. */
  615. try {
  616. return ($this->fltRate = QType::Cast($mixValue, QType::Float));
  617. } catch (QCallerException $objExc) {
  618. $objExc->IncrementOffset();
  619. throw $objExc;
  620. }
  621. case 'ZoneId':
  622. /**
  623. * Sets the value for intZoneId (Unique)
  624. * @param integer $mixValue
  625. * @return integer
  626. */
  627. try {
  628. return ($this->intZoneId = QType::Cast($mixValue, QType::Integer));
  629. } catch (QCallerException $objExc) {
  630. $objExc->IncrementOffset();
  631. throw $objExc;
  632. }
  633. ///////////////////
  634. // Member Objects
  635. ///////////////////
  636. default:
  637. try {
  638. return parent::__set($strName, $mixValue);
  639. } catch (QCallerException $objExc) {
  640. $objExc->IncrementOffset();
  641. throw $objExc;
  642. }
  643. }
  644. }
  645. ///////////////////////////////
  646. // ASSOCIATED OBJECTS' METHODS
  647. ///////////////////////////////
  648. }
  649. /////////////////////////////////////
  650. // ADDITIONAL CLASSES for QCODO QUERY
  651. /////////////////////////////////////
  652. class QQNodeShippingRate extends QQNode {
  653. protected $strTableName = 'shipping_rate';
  654. protected $strPrimaryKey = 'id';
  655. protected $strClassName = 'ShippingRate';
  656. public function __get($strName) {
  657. switch ($strName) {
  658. case 'Id':
  659. return new QQNode('id', 'Id', 'integer', $this);
  660. case 'CreationDate':
  661. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  662. case 'Rate':
  663. return new QQNode('rate', 'Rate', 'double', $this);
  664. case 'ZoneId':
  665. return new QQNode('zone_id', 'ZoneId', 'integer', $this);
  666. case '_PrimaryKeyNode':
  667. return new QQNode('id', 'Id', 'integer', $this);
  668. default:
  669. try {
  670. return parent::__get($strName);
  671. } catch (QCallerException $objExc) {
  672. $objExc->IncrementOffset();
  673. throw $objExc;
  674. }
  675. }
  676. }
  677. }
  678. class QQReverseReferenceNodeShippingRate extends QQReverseReferenceNode {
  679. protected $strTableName = 'shipping_rate';
  680. protected $strPrimaryKey = 'id';
  681. protected $strClassName = 'ShippingRate';
  682. public function __get($strName) {
  683. switch ($strName) {
  684. case 'Id':
  685. return new QQNode('id', 'Id', 'integer', $this);
  686. case 'CreationDate':
  687. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  688. case 'Rate':
  689. return new QQNode('rate', 'Rate', 'double', $this);
  690. case 'ZoneId':
  691. return new QQNode('zone_id', 'ZoneId', 'integer', $this);
  692. case '_PrimaryKeyNode':
  693. return new QQNode('id', 'Id', 'integer', $this);
  694. default:
  695. try {
  696. return parent::__get($strName);
  697. } catch (QCallerException $objExc) {
  698. $objExc->IncrementOffset();
  699. throw $objExc;
  700. }
  701. }
  702. }
  703. }
  704. ?>