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.

3225 lines
146 KiB

  1. <?php
  2. /**
  3. * The abstract OrderGen 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 Order subclass which
  8. * extends this OrderGen 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 Order class.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage GeneratedDataObjects
  18. * @property-read integer $Id the value for intId (Read-Only PK)
  19. * @property integer $AccountId the value for intAccountId (Not Null)
  20. * @property-read string $CreationDate the value for strCreationDate (Read-Only Timestamp)
  21. * @property-read string $LastModification the value for strLastModification (Read-Only Timestamp)
  22. * @property QDateTime $CompletionDate the value for dttCompletionDate
  23. * @property double $ProductTotalCost the value for fltProductTotalCost
  24. * @property double $ShippingCost the value for fltShippingCost
  25. * @property double $ShippingCharged the value for fltShippingCharged
  26. * @property double $HandlingCost the value for fltHandlingCost
  27. * @property double $HandlingCharged the value for fltHandlingCharged
  28. * @property double $Tax the value for fltTax
  29. * @property double $ProductTotalCharged the value for fltProductTotalCharged
  30. * @property string $Notes the value for strNotes
  31. * @property integer $ShippingMethodId the value for intShippingMethodId
  32. * @property integer $PaymentMethodId the value for intPaymentMethodId
  33. * @property integer $StatusId the value for intStatusId (Not Null)
  34. * @property integer $TypeId the value for intTypeId
  35. * @property Account $Account the value for the Account object referenced by intAccountId (Not Null)
  36. * @property ShippingMethod $ShippingMethod the value for the ShippingMethod object referenced by intShippingMethodId
  37. * @property PaymentMethod $PaymentMethod the value for the PaymentMethod object referenced by intPaymentMethodId
  38. * @property-read AuthorizeNetTransaction $_AuthorizeNetTransaction the value for the private _objAuthorizeNetTransaction (Read-Only) if set due to an expansion on the authorize_net_transaction.order_id reverse relationship
  39. * @property-read AuthorizeNetTransaction[] $_AuthorizeNetTransactionArray the value for the private _objAuthorizeNetTransactionArray (Read-Only) if set due to an ExpandAsArray on the authorize_net_transaction.order_id reverse relationship
  40. * @property-read OrderAddress $_OrderAddress the value for the private _objOrderAddress (Read-Only) if set due to an expansion on the order_address.order_id reverse relationship
  41. * @property-read OrderAddress[] $_OrderAddressArray the value for the private _objOrderAddressArray (Read-Only) if set due to an ExpandAsArray on the order_address.order_id reverse relationship
  42. * @property-read OrderChange $_OrderChange the value for the private _objOrderChange (Read-Only) if set due to an expansion on the order_change.order_id reverse relationship
  43. * @property-read OrderChange[] $_OrderChangeArray the value for the private _objOrderChangeArray (Read-Only) if set due to an ExpandAsArray on the order_change.order_id reverse relationship
  44. * @property-read OrderItem $_OrderItem the value for the private _objOrderItem (Read-Only) if set due to an expansion on the order_item.order_id reverse relationship
  45. * @property-read OrderItem[] $_OrderItemArray the value for the private _objOrderItemArray (Read-Only) if set due to an ExpandAsArray on the order_item.order_id reverse relationship
  46. * @property-read OrderStatusHistory $_OrderStatusHistory the value for the private _objOrderStatusHistory (Read-Only) if set due to an expansion on the order_status_history.order_id reverse relationship
  47. * @property-read OrderStatusHistory[] $_OrderStatusHistoryArray the value for the private _objOrderStatusHistoryArray (Read-Only) if set due to an ExpandAsArray on the order_status_history.order_id reverse relationship
  48. * @property-read PaypalTransaction $_PaypalTransaction the value for the private _objPaypalTransaction (Read-Only) if set due to an expansion on the paypal_transaction.order_id reverse relationship
  49. * @property-read PaypalTransaction[] $_PaypalTransactionArray the value for the private _objPaypalTransactionArray (Read-Only) if set due to an ExpandAsArray on the paypal_transaction.order_id reverse relationship
  50. * @property-read TrackingNumber $_TrackingNumber the value for the private _objTrackingNumber (Read-Only) if set due to an expansion on the tracking_number.order_id reverse relationship
  51. * @property-read TrackingNumber[] $_TrackingNumberArray the value for the private _objTrackingNumberArray (Read-Only) if set due to an ExpandAsArray on the tracking_number.order_id reverse relationship
  52. * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
  53. */
  54. class OrderGen extends QBaseClass
  55. {
  56. ///////////////////////////////////////////////////////////////////////
  57. // PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
  58. ///////////////////////////////////////////////////////////////////////
  59. /////////// Object properties ////////////
  60. /**
  61. * Protected member variable that maps to the database PK Identity column order.id
  62. * @var integer intId
  63. *
  64. */
  65. protected $intId = null;
  66. /**
  67. * Protected member variable that maps to the database column order.account_id
  68. * @var integer intAccountId
  69. *
  70. */
  71. protected $intAccountId = null;
  72. /**
  73. * Protected member variable that maps to the database column order.creation_date
  74. * @var string strCreationDate
  75. *
  76. */
  77. protected $strCreationDate = null;
  78. /**
  79. * Protected member variable that maps to the database column order.last_modification
  80. * @var string strLastModification
  81. *
  82. */
  83. protected $strLastModification = null;
  84. /**
  85. * Protected member variable that maps to the database column order.completion_date
  86. * @var QDateTime dttCompletionDate
  87. *
  88. */
  89. protected $dttCompletionDate = null;
  90. /**
  91. * Protected member variable that maps to the database column order.product_total_cost
  92. * @var double fltProductTotalCost
  93. *
  94. */
  95. protected $fltProductTotalCost = null;
  96. /**
  97. * Protected member variable that maps to the database column order.shipping_cost
  98. * @var double fltShippingCost
  99. *
  100. */
  101. protected $fltShippingCost = null;
  102. /**
  103. * Protected member variable that maps to the database column order.shipping_charged
  104. * @var double fltShippingCharged
  105. *
  106. */
  107. protected $fltShippingCharged = null;
  108. /**
  109. * Protected member variable that maps to the database column order.handling_cost
  110. * @var double fltHandlingCost
  111. *
  112. */
  113. protected $fltHandlingCost = null;
  114. /**
  115. * Protected member variable that maps to the database column order.handling_charged
  116. * @var double fltHandlingCharged
  117. *
  118. */
  119. protected $fltHandlingCharged = null;
  120. /**
  121. * Protected member variable that maps to the database column order.tax
  122. * @var double fltTax
  123. *
  124. */
  125. protected $fltTax = null;
  126. /**
  127. * Protected member variable that maps to the database column order.product_total_charged
  128. * @var double fltProductTotalCharged
  129. *
  130. */
  131. protected $fltProductTotalCharged = null;
  132. /**
  133. * Protected member variable that maps to the database column order.notes
  134. * @var string strNotes
  135. *
  136. */
  137. protected $strNotes = null;
  138. /**
  139. * Protected member variable that maps to the database column order.shipping_method_id
  140. * @var integer intShippingMethodId
  141. *
  142. */
  143. protected $intShippingMethodId = null;
  144. /**
  145. * Protected member variable that maps to the database column order.payment_method_id
  146. * @var integer intPaymentMethodId
  147. *
  148. */
  149. protected $intPaymentMethodId = null;
  150. /**
  151. * Protected member variable that maps to the database column order.status_id
  152. * @var integer intStatusId
  153. *
  154. */
  155. protected $intStatusId = null;
  156. /**
  157. * Protected member variable that maps to the database column order.type_id
  158. * @var integer intTypeId
  159. *
  160. */
  161. protected $intTypeId = null;
  162. /**
  163. * Private member variable that stores a reference to a single AuthorizeNetTransaction object
  164. * (of type AuthorizeNetTransaction), if this Order object was restored with
  165. * an expansion on the authorize_net_transaction association table.
  166. * @var AuthorizeNetTransaction _objAuthorizeNetTransaction;
  167. */
  168. private $_objAuthorizeNetTransaction;
  169. /**
  170. * Private member variable that stores a reference to an array of AuthorizeNetTransaction objects
  171. * (of type AuthorizeNetTransaction[]), if this Order object was restored with
  172. * an ExpandAsArray on the authorize_net_transaction association table.
  173. * @var AuthorizeNetTransaction[] _objAuthorizeNetTransactionArray;
  174. */
  175. private $_objAuthorizeNetTransactionArray = array();
  176. /**
  177. * Private member variable that stores a reference to a single OrderAddress object
  178. * (of type OrderAddress), if this Order object was restored with
  179. * an expansion on the order_address association table.
  180. * @var OrderAddress _objOrderAddress;
  181. */
  182. private $_objOrderAddress;
  183. /**
  184. * Private member variable that stores a reference to an array of OrderAddress objects
  185. * (of type OrderAddress[]), if this Order object was restored with
  186. * an ExpandAsArray on the order_address association table.
  187. * @var OrderAddress[] _objOrderAddressArray;
  188. */
  189. private $_objOrderAddressArray = array();
  190. /**
  191. * Private member variable that stores a reference to a single OrderChange object
  192. * (of type OrderChange), if this Order object was restored with
  193. * an expansion on the order_change association table.
  194. * @var OrderChange _objOrderChange;
  195. */
  196. private $_objOrderChange;
  197. /**
  198. * Private member variable that stores a reference to an array of OrderChange objects
  199. * (of type OrderChange[]), if this Order object was restored with
  200. * an ExpandAsArray on the order_change association table.
  201. * @var OrderChange[] _objOrderChangeArray;
  202. */
  203. private $_objOrderChangeArray = array();
  204. /**
  205. * Private member variable that stores a reference to a single OrderItem object
  206. * (of type OrderItem), if this Order object was restored with
  207. * an expansion on the order_item association table.
  208. * @var OrderItem _objOrderItem;
  209. */
  210. private $_objOrderItem;
  211. /**
  212. * Private member variable that stores a reference to an array of OrderItem objects
  213. * (of type OrderItem[]), if this Order object was restored with
  214. * an ExpandAsArray on the order_item association table.
  215. * @var OrderItem[] _objOrderItemArray;
  216. */
  217. private $_objOrderItemArray = array();
  218. /**
  219. * Private member variable that stores a reference to a single OrderStatusHistory object
  220. * (of type OrderStatusHistory), if this Order object was restored with
  221. * an expansion on the order_status_history association table.
  222. * @var OrderStatusHistory _objOrderStatusHistory;
  223. */
  224. private $_objOrderStatusHistory;
  225. /**
  226. * Private member variable that stores a reference to an array of OrderStatusHistory objects
  227. * (of type OrderStatusHistory[]), if this Order object was restored with
  228. * an ExpandAsArray on the order_status_history association table.
  229. * @var OrderStatusHistory[] _objOrderStatusHistoryArray;
  230. */
  231. private $_objOrderStatusHistoryArray = array();
  232. /**
  233. * Private member variable that stores a reference to a single PaypalTransaction object
  234. * (of type PaypalTransaction), if this Order object was restored with
  235. * an expansion on the paypal_transaction association table.
  236. * @var PaypalTransaction _objPaypalTransaction;
  237. */
  238. private $_objPaypalTransaction;
  239. /**
  240. * Private member variable that stores a reference to an array of PaypalTransaction objects
  241. * (of type PaypalTransaction[]), if this Order object was restored with
  242. * an ExpandAsArray on the paypal_transaction association table.
  243. * @var PaypalTransaction[] _objPaypalTransactionArray;
  244. */
  245. private $_objPaypalTransactionArray = array();
  246. /**
  247. * Private member variable that stores a reference to a single TrackingNumber object
  248. * (of type TrackingNumber), if this Order object was restored with
  249. * an expansion on the tracking_number association table.
  250. * @var TrackingNumber _objTrackingNumber;
  251. */
  252. private $_objTrackingNumber;
  253. /**
  254. * Private member variable that stores a reference to an array of TrackingNumber objects
  255. * (of type TrackingNumber[]), if this Order object was restored with
  256. * an ExpandAsArray on the tracking_number association table.
  257. * @var TrackingNumber[] _objTrackingNumberArray;
  258. */
  259. private $_objTrackingNumberArray = array();
  260. /**
  261. * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
  262. * columns from the run-time database query result for this object). Used by InstantiateDbRow and
  263. * GetVirtualAttribute.
  264. * @var string[] $__strVirtualAttributeArray
  265. */
  266. protected $__strVirtualAttributeArray = array();
  267. /**
  268. * Protected internal member variable that specifies whether or not this object is Restored from the database.
  269. * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
  270. * @var bool __blnRestored;
  271. */
  272. protected $__blnRestored;
  273. ///////////////////////////////
  274. // PROTECTED MEMBER OBJECTS
  275. ///////////////////////////////
  276. /**
  277. * Protected member variable that contains the object pointed by the reference
  278. * in the database column order.account_id.
  279. *
  280. * NOTE: Always use the Account property getter to correctly retrieve this Account object.
  281. * (Because this class implements late binding, this variable reference MAY be null.)
  282. * @var Account objAccount
  283. */
  284. protected $objAccount;
  285. /**
  286. * Protected member variable that contains the object pointed by the reference
  287. * in the database column order.shipping_method_id.
  288. *
  289. * NOTE: Always use the ShippingMethod property getter to correctly retrieve this ShippingMethod object.
  290. * (Because this class implements late binding, this variable reference MAY be null.)
  291. * @var ShippingMethod objShippingMethod
  292. */
  293. protected $objShippingMethod;
  294. /**
  295. * Protected member variable that contains the object pointed by the reference
  296. * in the database column order.payment_method_id.
  297. *
  298. * NOTE: Always use the PaymentMethod property getter to correctly retrieve this PaymentMethod object.
  299. * (Because this class implements late binding, this variable reference MAY be null.)
  300. * @var PaymentMethod objPaymentMethod
  301. */
  302. protected $objPaymentMethod;
  303. ///////////////////////////////
  304. // CLASS-WIDE LOAD AND COUNT METHODS
  305. ///////////////////////////////
  306. /**
  307. * Static method to retrieve the Database object that owns this class.
  308. * @return QDatabaseBase reference to the Database object that can query this class
  309. */
  310. public static function GetDatabase() {
  311. return QApplication::$Database[1];
  312. }
  313. /**
  314. * Load a Order from PK Info
  315. * @param integer $intId
  316. * @return Order
  317. */
  318. public static function Load($intId) {
  319. // Use QuerySingle to Perform the Query
  320. return Order::QuerySingle(
  321. QQ::Equal(QQN::Order()->Id, $intId)
  322. );
  323. }
  324. /**
  325. * Load all Orders
  326. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  327. * @return Order[]
  328. */
  329. public static function LoadAll($objOptionalClauses = null) {
  330. // Call Order::QueryArray to perform the LoadAll query
  331. try {
  332. return Order::QueryArray(QQ::All(), $objOptionalClauses);
  333. } catch (QCallerException $objExc) {
  334. $objExc->IncrementOffset();
  335. throw $objExc;
  336. }
  337. }
  338. /**
  339. * Count all Orders
  340. * @return int
  341. */
  342. public static function CountAll() {
  343. // Call Order::QueryCount to perform the CountAll query
  344. return Order::QueryCount(QQ::All());
  345. }
  346. ///////////////////////////////
  347. // QCODO QUERY-RELATED METHODS
  348. ///////////////////////////////
  349. /**
  350. * Internally called method to assist with calling Qcodo Query for this class
  351. * on load methods.
  352. * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
  353. * @param QQCondition $objConditions any conditions on the query, itself
  354. * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
  355. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
  356. * @param boolean $blnCountOnly only select a rowcount
  357. * @return string the query statement
  358. */
  359. protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
  360. // Get the Database Object for this Class
  361. $objDatabase = Order::GetDatabase();
  362. // Create/Build out the QueryBuilder object with Order-specific SELET and FROM fields
  363. $objQueryBuilder = new QQueryBuilder($objDatabase, 'order');
  364. Order::GetSelectFields($objQueryBuilder);
  365. $objQueryBuilder->AddFromItem('order');
  366. // Set "CountOnly" option (if applicable)
  367. if ($blnCountOnly)
  368. $objQueryBuilder->SetCountOnlyFlag();
  369. // Apply Any Conditions
  370. if ($objConditions)
  371. try {
  372. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  373. } catch (QCallerException $objExc) {
  374. $objExc->IncrementOffset();
  375. throw $objExc;
  376. }
  377. // Iterate through all the Optional Clauses (if any) and perform accordingly
  378. if ($objOptionalClauses) {
  379. if ($objOptionalClauses instanceof QQClause)
  380. $objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
  381. else if (is_array($objOptionalClauses))
  382. foreach ($objOptionalClauses as $objClause)
  383. $objClause->UpdateQueryBuilder($objQueryBuilder);
  384. else
  385. throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
  386. }
  387. // Get the SQL Statement
  388. $strQuery = $objQueryBuilder->GetStatement();
  389. // Prepare the Statement with the Query Parameters (if applicable)
  390. if ($mixParameterArray) {
  391. if (is_array($mixParameterArray)) {
  392. if (count($mixParameterArray))
  393. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  394. // Ensure that there are no other Unresolved Named Parameters
  395. if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
  396. throw new QCallerException('Unresolved named parameters in the query');
  397. } else
  398. throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
  399. }
  400. // Return the Objects
  401. return $strQuery;
  402. }
  403. /**
  404. * Static Qcodo Query method to query for a single Order object.
  405. * Uses BuildQueryStatment to perform most of the work.
  406. * @param QQCondition $objConditions any conditions on the query, itself
  407. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  408. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  409. * @return Order the queried object
  410. */
  411. public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  412. // Get the Query Statement
  413. try {
  414. $strQuery = Order::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  415. } catch (QCallerException $objExc) {
  416. $objExc->IncrementOffset();
  417. throw $objExc;
  418. }
  419. // Perform the Query, Get the First Row, and Instantiate a new Order object
  420. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  421. return Order::InstantiateDbRow($objDbResult->GetNextRow(), null, null, null, $objQueryBuilder->ColumnAliasArray);
  422. }
  423. /**
  424. * Static Qcodo Query method to query for an array of Order objects.
  425. * Uses BuildQueryStatment to perform most of the work.
  426. * @param QQCondition $objConditions any conditions on the query, itself
  427. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  428. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  429. * @return Order[] the queried objects as an array
  430. */
  431. public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  432. // Get the Query Statement
  433. try {
  434. $strQuery = Order::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  435. } catch (QCallerException $objExc) {
  436. $objExc->IncrementOffset();
  437. throw $objExc;
  438. }
  439. // Perform the Query and Instantiate the Array Result
  440. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  441. return Order::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
  442. }
  443. /**
  444. * Static Qcodo Query method to query for a count of Order objects.
  445. * Uses BuildQueryStatment to perform most of the work.
  446. * @param QQCondition $objConditions any conditions on the query, itself
  447. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  448. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  449. * @return integer the count of queried objects as an integer
  450. */
  451. public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  452. // Get the Query Statement
  453. try {
  454. $strQuery = Order::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
  455. } catch (QCallerException $objExc) {
  456. $objExc->IncrementOffset();
  457. throw $objExc;
  458. }
  459. // Perform the Query and return the row_count
  460. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  461. // Figure out if the query is using GroupBy
  462. $blnGrouped = false;
  463. if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
  464. if ($objClause instanceof QQGroupBy) {
  465. $blnGrouped = true;
  466. break;
  467. }
  468. }
  469. if ($blnGrouped)
  470. // Groups in this query - return the count of Groups (which is the count of all rows)
  471. return $objDbResult->CountRows();
  472. else {
  473. // No Groups - return the sql-calculated count(*) value
  474. $strDbRow = $objDbResult->FetchRow();
  475. return QType::Cast($strDbRow[0], QType::Integer);
  476. }
  477. }
  478. /* public static function QueryArrayCached($strConditions, $mixParameterArray = null) {
  479. // Get the Database Object for this Class
  480. $objDatabase = Order::GetDatabase();
  481. // Lookup the QCache for This Query Statement
  482. $objCache = new QCache('query', 'order_' . serialize($strConditions));
  483. if (!($strQuery = $objCache->GetData())) {
  484. // Not Found -- Go ahead and Create/Build out a new QueryBuilder object with Order-specific fields
  485. $objQueryBuilder = new QQueryBuilder($objDatabase);
  486. Order::GetSelectFields($objQueryBuilder);
  487. Order::GetFromFields($objQueryBuilder);
  488. // Ensure the Passed-in Conditions is a string
  489. try {
  490. $strConditions = QType::Cast($strConditions, QType::String);
  491. } catch (QCallerException $objExc) {
  492. $objExc->IncrementOffset();
  493. throw $objExc;
  494. }
  495. // Create the Conditions object, and apply it
  496. $objConditions = eval('return ' . $strConditions . ';');
  497. // Apply Any Conditions
  498. if ($objConditions)
  499. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  500. // Get the SQL Statement
  501. $strQuery = $objQueryBuilder->GetStatement();
  502. // Save the SQL Statement in the Cache
  503. $objCache->SaveData($strQuery);
  504. }
  505. // Prepare the Statement with the Parameters
  506. if ($mixParameterArray)
  507. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  508. // Perform the Query and Instantiate the Array Result
  509. $objDbResult = $objDatabase->Query($strQuery);
  510. return Order::InstantiateDbResult($objDbResult);
  511. }*/
  512. /**
  513. * Updates a QQueryBuilder with the SELECT fields for this Order
  514. * @param QQueryBuilder $objBuilder the Query Builder object to update
  515. * @param string $strPrefix optional prefix to add to the SELECT fields
  516. */
  517. public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
  518. if ($strPrefix) {
  519. $strTableName = $strPrefix;
  520. $strAliasPrefix = $strPrefix . '__';
  521. } else {
  522. $strTableName = 'order';
  523. $strAliasPrefix = '';
  524. }
  525. $objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
  526. $objBuilder->AddSelectItem($strTableName, 'account_id', $strAliasPrefix . 'account_id');
  527. $objBuilder->AddSelectItem($strTableName, 'creation_date', $strAliasPrefix . 'creation_date');
  528. $objBuilder->AddSelectItem($strTableName, 'last_modification', $strAliasPrefix . 'last_modification');
  529. $objBuilder->AddSelectItem($strTableName, 'completion_date', $strAliasPrefix . 'completion_date');
  530. $objBuilder->AddSelectItem($strTableName, 'product_total_cost', $strAliasPrefix . 'product_total_cost');
  531. $objBuilder->AddSelectItem($strTableName, 'shipping_cost', $strAliasPrefix . 'shipping_cost');
  532. $objBuilder->AddSelectItem($strTableName, 'shipping_charged', $strAliasPrefix . 'shipping_charged');
  533. $objBuilder->AddSelectItem($strTableName, 'handling_cost', $strAliasPrefix . 'handling_cost');
  534. $objBuilder->AddSelectItem($strTableName, 'handling_charged', $strAliasPrefix . 'handling_charged');
  535. $objBuilder->AddSelectItem($strTableName, 'tax', $strAliasPrefix . 'tax');
  536. $objBuilder->AddSelectItem($strTableName, 'product_total_charged', $strAliasPrefix . 'product_total_charged');
  537. $objBuilder->AddSelectItem($strTableName, 'notes', $strAliasPrefix . 'notes');
  538. $objBuilder->AddSelectItem($strTableName, 'shipping_method_id', $strAliasPrefix . 'shipping_method_id');
  539. $objBuilder->AddSelectItem($strTableName, 'payment_method_id', $strAliasPrefix . 'payment_method_id');
  540. $objBuilder->AddSelectItem($strTableName, 'status_id', $strAliasPrefix . 'status_id');
  541. $objBuilder->AddSelectItem($strTableName, 'type_id', $strAliasPrefix . 'type_id');
  542. }
  543. ///////////////////////////////
  544. // INSTANTIATION-RELATED METHODS
  545. ///////////////////////////////
  546. /**
  547. * Instantiate a Order from a Database Row.
  548. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  549. * is calling this Order::InstantiateDbRow in order to perform
  550. * early binding on referenced objects.
  551. * @param DatabaseRowBase $objDbRow
  552. * @param string $strAliasPrefix
  553. * @param string $strExpandAsArrayNodes
  554. * @param QBaseClass $objPreviousItem
  555. * @param string[] $strColumnAliasArray
  556. * @return Order
  557. */
  558. public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array()) {
  559. // If blank row, return null
  560. if (!$objDbRow)
  561. return null;
  562. // See if we're doing an array expansion on the previous item
  563. $strAlias = $strAliasPrefix . 'id';
  564. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  565. if (($strExpandAsArrayNodes) && ($objPreviousItem) &&
  566. ($objPreviousItem->intId == $objDbRow->GetColumn($strAliasName, 'Integer'))) {
  567. // We are. Now, prepare to check for ExpandAsArray clauses
  568. $blnExpandedViaArray = false;
  569. if (!$strAliasPrefix)
  570. $strAliasPrefix = 'order__';
  571. $strAlias = $strAliasPrefix . 'authorizenettransaction__id';
  572. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  573. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  574. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  575. if ($intPreviousChildItemCount = count($objPreviousItem->_objAuthorizeNetTransactionArray)) {
  576. $objPreviousChildItem = $objPreviousItem->_objAuthorizeNetTransactionArray[$intPreviousChildItemCount - 1];
  577. $objChildItem = AuthorizeNetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorizenettransaction__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  578. if ($objChildItem)
  579. $objPreviousItem->_objAuthorizeNetTransactionArray[] = $objChildItem;
  580. } else
  581. $objPreviousItem->_objAuthorizeNetTransactionArray[] = AuthorizeNetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorizenettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  582. $blnExpandedViaArray = true;
  583. }
  584. $strAlias = $strAliasPrefix . 'orderaddress__id';
  585. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  586. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  587. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  588. if ($intPreviousChildItemCount = count($objPreviousItem->_objOrderAddressArray)) {
  589. $objPreviousChildItem = $objPreviousItem->_objOrderAddressArray[$intPreviousChildItemCount - 1];
  590. $objChildItem = OrderAddress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderaddress__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  591. if ($objChildItem)
  592. $objPreviousItem->_objOrderAddressArray[] = $objChildItem;
  593. } else
  594. $objPreviousItem->_objOrderAddressArray[] = OrderAddress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderaddress__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  595. $blnExpandedViaArray = true;
  596. }
  597. $strAlias = $strAliasPrefix . 'orderchange__order_id';
  598. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  599. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  600. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  601. if ($intPreviousChildItemCount = count($objPreviousItem->_objOrderChangeArray)) {
  602. $objPreviousChildItem = $objPreviousItem->_objOrderChangeArray[$intPreviousChildItemCount - 1];
  603. $objChildItem = OrderChange::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderchange__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  604. if ($objChildItem)
  605. $objPreviousItem->_objOrderChangeArray[] = $objChildItem;
  606. } else
  607. $objPreviousItem->_objOrderChangeArray[] = OrderChange::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderchange__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  608. $blnExpandedViaArray = true;
  609. }
  610. $strAlias = $strAliasPrefix . 'orderitem__order_id';
  611. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  612. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  613. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  614. if ($intPreviousChildItemCount = count($objPreviousItem->_objOrderItemArray)) {
  615. $objPreviousChildItem = $objPreviousItem->_objOrderItemArray[$intPreviousChildItemCount - 1];
  616. $objChildItem = OrderItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderitem__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  617. if ($objChildItem)
  618. $objPreviousItem->_objOrderItemArray[] = $objChildItem;
  619. } else
  620. $objPreviousItem->_objOrderItemArray[] = OrderItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  621. $blnExpandedViaArray = true;
  622. }
  623. $strAlias = $strAliasPrefix . 'orderstatushistory__id';
  624. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  625. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  626. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  627. if ($intPreviousChildItemCount = count($objPreviousItem->_objOrderStatusHistoryArray)) {
  628. $objPreviousChildItem = $objPreviousItem->_objOrderStatusHistoryArray[$intPreviousChildItemCount - 1];
  629. $objChildItem = OrderStatusHistory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderstatushistory__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  630. if ($objChildItem)
  631. $objPreviousItem->_objOrderStatusHistoryArray[] = $objChildItem;
  632. } else
  633. $objPreviousItem->_objOrderStatusHistoryArray[] = OrderStatusHistory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderstatushistory__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  634. $blnExpandedViaArray = true;
  635. }
  636. $strAlias = $strAliasPrefix . 'paypaltransaction__id';
  637. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  638. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  639. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  640. if ($intPreviousChildItemCount = count($objPreviousItem->_objPaypalTransactionArray)) {
  641. $objPreviousChildItem = $objPreviousItem->_objPaypalTransactionArray[$intPreviousChildItemCount - 1];
  642. $objChildItem = PaypalTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'paypaltransaction__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  643. if ($objChildItem)
  644. $objPreviousItem->_objPaypalTransactionArray[] = $objChildItem;
  645. } else
  646. $objPreviousItem->_objPaypalTransactionArray[] = PaypalTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'paypaltransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  647. $blnExpandedViaArray = true;
  648. }
  649. $strAlias = $strAliasPrefix . 'trackingnumber__order_id';
  650. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  651. if ((array_key_exists($strAlias, $strExpandAsArrayNodes)) &&
  652. (!is_null($objDbRow->GetColumn($strAliasName)))) {
  653. if ($intPreviousChildItemCount = count($objPreviousItem->_objTrackingNumberArray)) {
  654. $objPreviousChildItem = $objPreviousItem->_objTrackingNumberArray[$intPreviousChildItemCount - 1];
  655. $objChildItem = TrackingNumber::InstantiateDbRow($objDbRow, $strAliasPrefix . 'trackingnumber__', $strExpandAsArrayNodes, $objPreviousChildItem, $strColumnAliasArray);
  656. if ($objChildItem)
  657. $objPreviousItem->_objTrackingNumberArray[] = $objChildItem;
  658. } else
  659. $objPreviousItem->_objTrackingNumberArray[] = TrackingNumber::InstantiateDbRow($objDbRow, $strAliasPrefix . 'trackingnumber__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  660. $blnExpandedViaArray = true;
  661. }
  662. // Either return false to signal array expansion, or check-to-reset the Alias prefix and move on
  663. if ($blnExpandedViaArray)
  664. return false;
  665. else if ($strAliasPrefix == 'order__')
  666. $strAliasPrefix = null;
  667. }
  668. // Create a new instance of the Order object
  669. $objToReturn = new Order();
  670. $objToReturn->__blnRestored = true;
  671. $strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
  672. $objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
  673. $strAliasName = array_key_exists($strAliasPrefix . 'account_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'account_id'] : $strAliasPrefix . 'account_id';
  674. $objToReturn->intAccountId = $objDbRow->GetColumn($strAliasName, 'Integer');
  675. $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date';
  676. $objToReturn->strCreationDate = $objDbRow->GetColumn($strAliasName, 'VarChar');
  677. $strAliasName = array_key_exists($strAliasPrefix . 'last_modification', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'last_modification'] : $strAliasPrefix . 'last_modification';
  678. $objToReturn->strLastModification = $objDbRow->GetColumn($strAliasName, 'VarChar');
  679. $strAliasName = array_key_exists($strAliasPrefix . 'completion_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'completion_date'] : $strAliasPrefix . 'completion_date';
  680. $objToReturn->dttCompletionDate = $objDbRow->GetColumn($strAliasName, 'DateTime');
  681. $strAliasName = array_key_exists($strAliasPrefix . 'product_total_cost', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'product_total_cost'] : $strAliasPrefix . 'product_total_cost';
  682. $objToReturn->fltProductTotalCost = $objDbRow->GetColumn($strAliasName, 'Float');
  683. $strAliasName = array_key_exists($strAliasPrefix . 'shipping_cost', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'shipping_cost'] : $strAliasPrefix . 'shipping_cost';
  684. $objToReturn->fltShippingCost = $objDbRow->GetColumn($strAliasName, 'Float');
  685. $strAliasName = array_key_exists($strAliasPrefix . 'shipping_charged', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'shipping_charged'] : $strAliasPrefix . 'shipping_charged';
  686. $objToReturn->fltShippingCharged = $objDbRow->GetColumn($strAliasName, 'Float');
  687. $strAliasName = array_key_exists($strAliasPrefix . 'handling_cost', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'handling_cost'] : $strAliasPrefix . 'handling_cost';
  688. $objToReturn->fltHandlingCost = $objDbRow->GetColumn($strAliasName, 'Float');
  689. $strAliasName = array_key_exists($strAliasPrefix . 'handling_charged', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'handling_charged'] : $strAliasPrefix . 'handling_charged';
  690. $objToReturn->fltHandlingCharged = $objDbRow->GetColumn($strAliasName, 'Float');
  691. $strAliasName = array_key_exists($strAliasPrefix . 'tax', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'tax'] : $strAliasPrefix . 'tax';
  692. $objToReturn->fltTax = $objDbRow->GetColumn($strAliasName, 'Float');
  693. $strAliasName = array_key_exists($strAliasPrefix . 'product_total_charged', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'product_total_charged'] : $strAliasPrefix . 'product_total_charged';
  694. $objToReturn->fltProductTotalCharged = $objDbRow->GetColumn($strAliasName, 'Float');
  695. $strAliasName = array_key_exists($strAliasPrefix . 'notes', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'notes'] : $strAliasPrefix . 'notes';
  696. $objToReturn->strNotes = $objDbRow->GetColumn($strAliasName, 'Blob');
  697. $strAliasName = array_key_exists($strAliasPrefix . 'shipping_method_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'shipping_method_id'] : $strAliasPrefix . 'shipping_method_id';
  698. $objToReturn->intShippingMethodId = $objDbRow->GetColumn($strAliasName, 'Integer');
  699. $strAliasName = array_key_exists($strAliasPrefix . 'payment_method_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'payment_method_id'] : $strAliasPrefix . 'payment_method_id';
  700. $objToReturn->intPaymentMethodId = $objDbRow->GetColumn($strAliasName, 'Integer');
  701. $strAliasName = array_key_exists($strAliasPrefix . 'status_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'status_id'] : $strAliasPrefix . 'status_id';
  702. $objToReturn->intStatusId = $objDbRow->GetColumn($strAliasName, 'Integer');
  703. $strAliasName = array_key_exists($strAliasPrefix . 'type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'type_id'] : $strAliasPrefix . 'type_id';
  704. $objToReturn->intTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
  705. // Instantiate Virtual Attributes
  706. foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
  707. $strVirtualPrefix = $strAliasPrefix . '__';
  708. $strVirtualPrefixLength = strlen($strVirtualPrefix);
  709. if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
  710. $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
  711. }
  712. // Prepare to Check for Early/Virtual Binding
  713. if (!$strAliasPrefix)
  714. $strAliasPrefix = 'order__';
  715. // Check for Account Early Binding
  716. $strAlias = $strAliasPrefix . 'account_id__id';
  717. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  718. if (!is_null($objDbRow->GetColumn($strAliasName)))
  719. $objToReturn->objAccount = Account::InstantiateDbRow($objDbRow, $strAliasPrefix . 'account_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  720. // Check for ShippingMethod Early Binding
  721. $strAlias = $strAliasPrefix . 'shipping_method_id__id';
  722. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  723. if (!is_null($objDbRow->GetColumn($strAliasName)))
  724. $objToReturn->objShippingMethod = ShippingMethod::InstantiateDbRow($objDbRow, $strAliasPrefix . 'shipping_method_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  725. // Check for PaymentMethod Early Binding
  726. $strAlias = $strAliasPrefix . 'payment_method_id__id';
  727. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  728. if (!is_null($objDbRow->GetColumn($strAliasName)))
  729. $objToReturn->objPaymentMethod = PaymentMethod::InstantiateDbRow($objDbRow, $strAliasPrefix . 'payment_method_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  730. // Check for AuthorizeNetTransaction Virtual Binding
  731. $strAlias = $strAliasPrefix . 'authorizenettransaction__id';
  732. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  733. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  734. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  735. $objToReturn->_objAuthorizeNetTransactionArray[] = AuthorizeNetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorizenettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  736. else
  737. $objToReturn->_objAuthorizeNetTransaction = AuthorizeNetTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'authorizenettransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  738. }
  739. // Check for OrderAddress Virtual Binding
  740. $strAlias = $strAliasPrefix . 'orderaddress__id';
  741. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  742. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  743. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  744. $objToReturn->_objOrderAddressArray[] = OrderAddress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderaddress__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  745. else
  746. $objToReturn->_objOrderAddress = OrderAddress::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderaddress__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  747. }
  748. // Check for OrderChange Virtual Binding
  749. $strAlias = $strAliasPrefix . 'orderchange__order_id';
  750. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  751. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  752. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  753. $objToReturn->_objOrderChangeArray[] = OrderChange::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderchange__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  754. else
  755. $objToReturn->_objOrderChange = OrderChange::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderchange__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  756. }
  757. // Check for OrderItem Virtual Binding
  758. $strAlias = $strAliasPrefix . 'orderitem__order_id';
  759. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  760. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  761. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  762. $objToReturn->_objOrderItemArray[] = OrderItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  763. else
  764. $objToReturn->_objOrderItem = OrderItem::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderitem__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  765. }
  766. // Check for OrderStatusHistory Virtual Binding
  767. $strAlias = $strAliasPrefix . 'orderstatushistory__id';
  768. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  769. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  770. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  771. $objToReturn->_objOrderStatusHistoryArray[] = OrderStatusHistory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderstatushistory__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  772. else
  773. $objToReturn->_objOrderStatusHistory = OrderStatusHistory::InstantiateDbRow($objDbRow, $strAliasPrefix . 'orderstatushistory__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  774. }
  775. // Check for PaypalTransaction Virtual Binding
  776. $strAlias = $strAliasPrefix . 'paypaltransaction__id';
  777. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  778. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  779. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  780. $objToReturn->_objPaypalTransactionArray[] = PaypalTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'paypaltransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  781. else
  782. $objToReturn->_objPaypalTransaction = PaypalTransaction::InstantiateDbRow($objDbRow, $strAliasPrefix . 'paypaltransaction__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  783. }
  784. // Check for TrackingNumber Virtual Binding
  785. $strAlias = $strAliasPrefix . 'trackingnumber__order_id';
  786. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  787. if (!is_null($objDbRow->GetColumn($strAliasName))) {
  788. if (($strExpandAsArrayNodes) && (array_key_exists($strAlias, $strExpandAsArrayNodes)))
  789. $objToReturn->_objTrackingNumberArray[] = TrackingNumber::InstantiateDbRow($objDbRow, $strAliasPrefix . 'trackingnumber__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  790. else
  791. $objToReturn->_objTrackingNumber = TrackingNumber::InstantiateDbRow($objDbRow, $strAliasPrefix . 'trackingnumber__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  792. }
  793. return $objToReturn;
  794. }
  795. /**
  796. * Instantiate an array of Orders from a Database Result
  797. * @param DatabaseResultBase $objDbResult
  798. * @param string $strExpandAsArrayNodes
  799. * @param string[] $strColumnAliasArray
  800. * @return Order[]
  801. */
  802. public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
  803. $objToReturn = array();
  804. if (!$strColumnAliasArray)
  805. $strColumnAliasArray = array();
  806. // If blank resultset, then return empty array
  807. if (!$objDbResult)
  808. return $objToReturn;
  809. // Load up the return array with each row
  810. if ($strExpandAsArrayNodes) {
  811. $objLastRowItem = null;
  812. while ($objDbRow = $objDbResult->GetNextRow()) {
  813. $objItem = Order::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
  814. if ($objItem) {
  815. $objToReturn[] = $objItem;
  816. $objLastRowItem = $objItem;
  817. }
  818. }
  819. } else {
  820. while ($objDbRow = $objDbResult->GetNextRow())
  821. $objToReturn[] = Order::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
  822. }
  823. return $objToReturn;
  824. }
  825. ///////////////////////////////////////////////////
  826. // INDEX-BASED LOAD METHODS (Single Load and Array)
  827. ///////////////////////////////////////////////////
  828. /**
  829. * Load a single Order object,
  830. * by Id Index(es)
  831. * @param integer $intId
  832. * @return Order
  833. */
  834. public static function LoadById($intId) {
  835. return Order::QuerySingle(
  836. QQ::Equal(QQN::Order()->Id, $intId)
  837. );
  838. }
  839. /**
  840. * Load an array of Order objects,
  841. * by AccountId Index(es)
  842. * @param integer $intAccountId
  843. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  844. * @return Order[]
  845. */
  846. public static function LoadArrayByAccountId($intAccountId, $objOptionalClauses = null) {
  847. // Call Order::QueryArray to perform the LoadArrayByAccountId query
  848. try {
  849. return Order::QueryArray(
  850. QQ::Equal(QQN::Order()->AccountId, $intAccountId),
  851. $objOptionalClauses);
  852. } catch (QCallerException $objExc) {
  853. $objExc->IncrementOffset();
  854. throw $objExc;
  855. }
  856. }
  857. /**
  858. * Count Orders
  859. * by AccountId Index(es)
  860. * @param integer $intAccountId
  861. * @return int
  862. */
  863. public static function CountByAccountId($intAccountId) {
  864. // Call Order::QueryCount to perform the CountByAccountId query
  865. return Order::QueryCount(
  866. QQ::Equal(QQN::Order()->AccountId, $intAccountId)
  867. );
  868. }
  869. /**
  870. * Load an array of Order objects,
  871. * by ShippingMethodId Index(es)
  872. * @param integer $intShippingMethodId
  873. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  874. * @return Order[]
  875. */
  876. public static function LoadArrayByShippingMethodId($intShippingMethodId, $objOptionalClauses = null) {
  877. // Call Order::QueryArray to perform the LoadArrayByShippingMethodId query
  878. try {
  879. return Order::QueryArray(
  880. QQ::Equal(QQN::Order()->ShippingMethodId, $intShippingMethodId),
  881. $objOptionalClauses);
  882. } catch (QCallerException $objExc) {
  883. $objExc->IncrementOffset();
  884. throw $objExc;
  885. }
  886. }
  887. /**
  888. * Count Orders
  889. * by ShippingMethodId Index(es)
  890. * @param integer $intShippingMethodId
  891. * @return int
  892. */
  893. public static function CountByShippingMethodId($intShippingMethodId) {
  894. // Call Order::QueryCount to perform the CountByShippingMethodId query
  895. return Order::QueryCount(
  896. QQ::Equal(QQN::Order()->ShippingMethodId, $intShippingMethodId)
  897. );
  898. }
  899. /**
  900. * Load an array of Order objects,
  901. * by PaymentMethodId Index(es)
  902. * @param integer $intPaymentMethodId
  903. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  904. * @return Order[]
  905. */
  906. public static function LoadArrayByPaymentMethodId($intPaymentMethodId, $objOptionalClauses = null) {
  907. // Call Order::QueryArray to perform the LoadArrayByPaymentMethodId query
  908. try {
  909. return Order::QueryArray(
  910. QQ::Equal(QQN::Order()->PaymentMethodId, $intPaymentMethodId),
  911. $objOptionalClauses);
  912. } catch (QCallerException $objExc) {
  913. $objExc->IncrementOffset();
  914. throw $objExc;
  915. }
  916. }
  917. /**
  918. * Count Orders
  919. * by PaymentMethodId Index(es)
  920. * @param integer $intPaymentMethodId
  921. * @return int
  922. */
  923. public static function CountByPaymentMethodId($intPaymentMethodId) {
  924. // Call Order::QueryCount to perform the CountByPaymentMethodId query
  925. return Order::QueryCount(
  926. QQ::Equal(QQN::Order()->PaymentMethodId, $intPaymentMethodId)
  927. );
  928. }
  929. /**
  930. * Load an array of Order objects,
  931. * by StatusId Index(es)
  932. * @param integer $intStatusId
  933. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  934. * @return Order[]
  935. */
  936. public static function LoadArrayByStatusId($intStatusId, $objOptionalClauses = null) {
  937. // Call Order::QueryArray to perform the LoadArrayByStatusId query
  938. try {
  939. return Order::QueryArray(
  940. QQ::Equal(QQN::Order()->StatusId, $intStatusId),
  941. $objOptionalClauses);
  942. } catch (QCallerException $objExc) {
  943. $objExc->IncrementOffset();
  944. throw $objExc;
  945. }
  946. }
  947. /**
  948. * Count Orders
  949. * by StatusId Index(es)
  950. * @param integer $intStatusId
  951. * @return int
  952. */
  953. public static function CountByStatusId($intStatusId) {
  954. // Call Order::QueryCount to perform the CountByStatusId query
  955. return Order::QueryCount(
  956. QQ::Equal(QQN::Order()->StatusId, $intStatusId)
  957. );
  958. }
  959. /**
  960. * Load an array of Order objects,
  961. * by TypeId Index(es)
  962. * @param integer $intTypeId
  963. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  964. * @return Order[]
  965. */
  966. public static function LoadArrayByTypeId($intTypeId, $objOptionalClauses = null) {
  967. // Call Order::QueryArray to perform the LoadArrayByTypeId query
  968. try {
  969. return Order::QueryArray(
  970. QQ::Equal(QQN::Order()->TypeId, $intTypeId),
  971. $objOptionalClauses);
  972. } catch (QCallerException $objExc) {
  973. $objExc->IncrementOffset();
  974. throw $objExc;
  975. }
  976. }
  977. /**
  978. * Count Orders
  979. * by TypeId Index(es)
  980. * @param integer $intTypeId
  981. * @return int
  982. */
  983. public static function CountByTypeId($intTypeId) {
  984. // Call Order::QueryCount to perform the CountByTypeId query
  985. return Order::QueryCount(
  986. QQ::Equal(QQN::Order()->TypeId, $intTypeId)
  987. );
  988. }
  989. ////////////////////////////////////////////////////
  990. // INDEX-BASED LOAD METHODS (Array via Many to Many)
  991. ////////////////////////////////////////////////////
  992. //////////////////////////
  993. // SAVE, DELETE AND RELOAD
  994. //////////////////////////
  995. /**
  996. * Save this Order
  997. * @param bool $blnForceInsert
  998. * @param bool $blnForceUpdate
  999. * @return int
  1000. */
  1001. public function Save($blnForceInsert = false, $blnForceUpdate = false) {
  1002. // Get the Database Object for this Class
  1003. $objDatabase = Order::GetDatabase();
  1004. $mixToReturn = null;
  1005. try {
  1006. if ((!$this->__blnRestored) || ($blnForceInsert)) {
  1007. // Perform an INSERT query
  1008. $objDatabase->NonQuery('
  1009. INSERT INTO `order` (
  1010. `account_id`,
  1011. `completion_date`,
  1012. `product_total_cost`,
  1013. `shipping_cost`,
  1014. `shipping_charged`,
  1015. `handling_cost`,
  1016. `handling_charged`,
  1017. `tax`,
  1018. `product_total_charged`,
  1019. `notes`,
  1020. `shipping_method_id`,
  1021. `payment_method_id`,
  1022. `status_id`,
  1023. `type_id`
  1024. ) VALUES (
  1025. ' . $objDatabase->SqlVariable($this->intAccountId) . ',
  1026. ' . $objDatabase->SqlVariable($this->dttCompletionDate) . ',
  1027. ' . $objDatabase->SqlVariable($this->fltProductTotalCost) . ',
  1028. ' . $objDatabase->SqlVariable($this->fltShippingCost) . ',
  1029. ' . $objDatabase->SqlVariable($this->fltShippingCharged) . ',
  1030. ' . $objDatabase->SqlVariable($this->fltHandlingCost) . ',
  1031. ' . $objDatabase->SqlVariable($this->fltHandlingCharged) . ',
  1032. ' . $objDatabase->SqlVariable($this->fltTax) . ',
  1033. ' . $objDatabase->SqlVariable($this->fltProductTotalCharged) . ',
  1034. ' . $objDatabase->SqlVariable($this->strNotes) . ',
  1035. ' . $objDatabase->SqlVariable($this->intShippingMethodId) . ',
  1036. ' . $objDatabase->SqlVariable($this->intPaymentMethodId) . ',
  1037. ' . $objDatabase->SqlVariable($this->intStatusId) . ',
  1038. ' . $objDatabase->SqlVariable($this->intTypeId) . '
  1039. )
  1040. ');
  1041. // Update Identity column and return its value
  1042. $mixToReturn = $this->intId = $objDatabase->InsertId('order', 'id');
  1043. } else {
  1044. // Perform an UPDATE query
  1045. // First checking for Optimistic Locking constraints (if applicable)
  1046. if (!$blnForceUpdate) {
  1047. // Perform the Optimistic Locking check
  1048. $objResult = $objDatabase->Query('
  1049. SELECT
  1050. `creation_date`
  1051. FROM
  1052. `order`
  1053. WHERE
  1054. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1055. ');
  1056. $objRow = $objResult->FetchArray();
  1057. if ($objRow[0] != $this->strCreationDate)
  1058. throw new QOptimisticLockingException('Order');
  1059. }
  1060. if (!$blnForceUpdate) {
  1061. // Perform the Optimistic Locking check
  1062. $objResult = $objDatabase->Query('
  1063. SELECT
  1064. `last_modification`
  1065. FROM
  1066. `order`
  1067. WHERE
  1068. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1069. ');
  1070. $objRow = $objResult->FetchArray();
  1071. if ($objRow[0] != $this->strLastModification)
  1072. throw new QOptimisticLockingException('Order');
  1073. }
  1074. // Perform the UPDATE query
  1075. $objDatabase->NonQuery('
  1076. UPDATE
  1077. `order`
  1078. SET
  1079. `account_id` = ' . $objDatabase->SqlVariable($this->intAccountId) . ',
  1080. `completion_date` = ' . $objDatabase->SqlVariable($this->dttCompletionDate) . ',
  1081. `product_total_cost` = ' . $objDatabase->SqlVariable($this->fltProductTotalCost) . ',
  1082. `shipping_cost` = ' . $objDatabase->SqlVariable($this->fltShippingCost) . ',
  1083. `shipping_charged` = ' . $objDatabase->SqlVariable($this->fltShippingCharged) . ',
  1084. `handling_cost` = ' . $objDatabase->SqlVariable($this->fltHandlingCost) . ',
  1085. `handling_charged` = ' . $objDatabase->SqlVariable($this->fltHandlingCharged) . ',
  1086. `tax` = ' . $objDatabase->SqlVariable($this->fltTax) . ',
  1087. `product_total_charged` = ' . $objDatabase->SqlVariable($this->fltProductTotalCharged) . ',
  1088. `notes` = ' . $objDatabase->SqlVariable($this->strNotes) . ',
  1089. `shipping_method_id` = ' . $objDatabase->SqlVariable($this->intShippingMethodId) . ',
  1090. `payment_method_id` = ' . $objDatabase->SqlVariable($this->intPaymentMethodId) . ',
  1091. `status_id` = ' . $objDatabase->SqlVariable($this->intStatusId) . ',
  1092. `type_id` = ' . $objDatabase->SqlVariable($this->intTypeId) . '
  1093. WHERE
  1094. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1095. ');
  1096. }
  1097. } catch (QCallerException $objExc) {
  1098. $objExc->IncrementOffset();
  1099. throw $objExc;
  1100. }
  1101. // Update __blnRestored and any Non-Identity PK Columns (if applicable)
  1102. $this->__blnRestored = true;
  1103. // Update Local Timestamp
  1104. $objResult = $objDatabase->Query('
  1105. SELECT
  1106. `creation_date`
  1107. FROM
  1108. `order`
  1109. WHERE
  1110. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1111. ');
  1112. $objRow = $objResult->FetchArray();
  1113. $this->strCreationDate = $objRow[0];
  1114. // Update Local Timestamp
  1115. $objResult = $objDatabase->Query('
  1116. SELECT
  1117. `last_modification`
  1118. FROM
  1119. `order`
  1120. WHERE
  1121. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1122. ');
  1123. $objRow = $objResult->FetchArray();
  1124. $this->strLastModification = $objRow[0];
  1125. // Return
  1126. return $mixToReturn;
  1127. }
  1128. /**
  1129. * Delete this Order
  1130. * @return void
  1131. */
  1132. public function Delete() {
  1133. if ((is_null($this->intId)))
  1134. throw new QUndefinedPrimaryKeyException('Cannot delete this Order with an unset primary key.');
  1135. // Get the Database Object for this Class
  1136. $objDatabase = Order::GetDatabase();
  1137. // Perform the SQL Query
  1138. $objDatabase->NonQuery('
  1139. DELETE FROM
  1140. `order`
  1141. WHERE
  1142. `id` = ' . $objDatabase->SqlVariable($this->intId) . '');
  1143. }
  1144. /**
  1145. * Delete all Orders
  1146. * @return void
  1147. */
  1148. public static function DeleteAll() {
  1149. // Get the Database Object for this Class
  1150. $objDatabase = Order::GetDatabase();
  1151. // Perform the Query
  1152. $objDatabase->NonQuery('
  1153. DELETE FROM
  1154. `order`');
  1155. }
  1156. /**
  1157. * Truncate order table
  1158. * @return void
  1159. */
  1160. public static function Truncate() {
  1161. // Get the Database Object for this Class
  1162. $objDatabase = Order::GetDatabase();
  1163. // Perform the Query
  1164. $objDatabase->NonQuery('
  1165. TRUNCATE `order`');
  1166. }
  1167. /**
  1168. * Reload this Order from the database.
  1169. * @return void
  1170. */
  1171. public function Reload() {
  1172. // Make sure we are actually Restored from the database
  1173. if (!$this->__blnRestored)
  1174. throw new QCallerException('Cannot call Reload() on a new, unsaved Order object.');
  1175. // Reload the Object
  1176. $objReloaded = Order::Load($this->intId);
  1177. // Update $this's local variables to match
  1178. $this->AccountId = $objReloaded->AccountId;
  1179. $this->strCreationDate = $objReloaded->strCreationDate;
  1180. $this->strLastModification = $objReloaded->strLastModification;
  1181. $this->dttCompletionDate = $objReloaded->dttCompletionDate;
  1182. $this->fltProductTotalCost = $objReloaded->fltProductTotalCost;
  1183. $this->fltShippingCost = $objReloaded->fltShippingCost;
  1184. $this->fltShippingCharged = $objReloaded->fltShippingCharged;
  1185. $this->fltHandlingCost = $objReloaded->fltHandlingCost;
  1186. $this->fltHandlingCharged = $objReloaded->fltHandlingCharged;
  1187. $this->fltTax = $objReloaded->fltTax;
  1188. $this->fltProductTotalCharged = $objReloaded->fltProductTotalCharged;
  1189. $this->strNotes = $objReloaded->strNotes;
  1190. $this->ShippingMethodId = $objReloaded->ShippingMethodId;
  1191. $this->PaymentMethodId = $objReloaded->PaymentMethodId;
  1192. $this->StatusId = $objReloaded->StatusId;
  1193. $this->TypeId = $objReloaded->TypeId;
  1194. }
  1195. ////////////////////
  1196. // GETTORS AND SETTORS
  1197. ////////////////////
  1198. /**
  1199. * Lookup a VirtualAttribute value (if applicable). Returns NULL if none found.
  1200. * @param string $strName
  1201. * @return string
  1202. */
  1203. public function GetVirtualAttribute($strName)
  1204. {
  1205. if (array_key_exists($strName, $this->__strVirtualAttributeArray))
  1206. return $this->__strVirtualAttributeArray[$strName];
  1207. return null;
  1208. }
  1209. /**
  1210. * Override method to perform a property "Get"
  1211. * This will get the value of $strName
  1212. *
  1213. * @param string $strName Name of the property to get
  1214. * @return mixed
  1215. */
  1216. public function __get($strName)
  1217. {
  1218. switch ($strName)
  1219. {
  1220. ///////////////////
  1221. // Member Variables
  1222. ///////////////////
  1223. case 'Id':
  1224. /**
  1225. * Gets the value for intId (Read-Only PK)
  1226. * @return integer
  1227. */
  1228. return $this->intId;
  1229. case 'AccountId':
  1230. /**
  1231. * Gets the value for intAccountId (Not Null)
  1232. * @return integer
  1233. */
  1234. return $this->intAccountId;
  1235. case 'CreationDate':
  1236. /**
  1237. * Gets the value for strCreationDate (Read-Only Timestamp)
  1238. * @return string
  1239. */
  1240. return $this->strCreationDate;
  1241. case 'LastModification':
  1242. /**
  1243. * Gets the value for strLastModification (Read-Only Timestamp)
  1244. * @return string
  1245. */
  1246. return $this->strLastModification;
  1247. case 'CompletionDate':
  1248. /**
  1249. * Gets the value for dttCompletionDate
  1250. * @return QDateTime
  1251. */
  1252. return $this->dttCompletionDate;
  1253. case 'ProductTotalCost':
  1254. /**
  1255. * Gets the value for fltProductTotalCost
  1256. * @return double
  1257. */
  1258. return $this->fltProductTotalCost;
  1259. case 'ShippingCost':
  1260. /**
  1261. * Gets the value for fltShippingCost
  1262. * @return double
  1263. */
  1264. return $this->fltShippingCost;
  1265. case 'ShippingCharged':
  1266. /**
  1267. * Gets the value for fltShippingCharged
  1268. * @return double
  1269. */
  1270. return $this->fltShippingCharged;
  1271. case 'HandlingCost':
  1272. /**
  1273. * Gets the value for fltHandlingCost
  1274. * @return double
  1275. */
  1276. return $this->fltHandlingCost;
  1277. case 'HandlingCharged':
  1278. /**
  1279. * Gets the value for fltHandlingCharged
  1280. * @return double
  1281. */
  1282. return $this->fltHandlingCharged;
  1283. case 'Tax':
  1284. /**
  1285. * Gets the value for fltTax
  1286. * @return double
  1287. */
  1288. return $this->fltTax;
  1289. case 'ProductTotalCharged':
  1290. /**
  1291. * Gets the value for fltProductTotalCharged
  1292. * @return double
  1293. */
  1294. return $this->fltProductTotalCharged;
  1295. case 'Notes':
  1296. /**
  1297. * Gets the value for strNotes
  1298. * @return string
  1299. */
  1300. return $this->strNotes;
  1301. case 'ShippingMethodId':
  1302. /**
  1303. * Gets the value for intShippingMethodId
  1304. * @return integer
  1305. */
  1306. return $this->intShippingMethodId;
  1307. case 'PaymentMethodId':
  1308. /**
  1309. * Gets the value for intPaymentMethodId
  1310. * @return integer
  1311. */
  1312. return $this->intPaymentMethodId;
  1313. case 'StatusId':
  1314. /**
  1315. * Gets the value for intStatusId (Not Null)
  1316. * @return integer
  1317. */
  1318. return $this->intStatusId;
  1319. case 'TypeId':
  1320. /**
  1321. * Gets the value for intTypeId
  1322. * @return integer
  1323. */
  1324. return $this->intTypeId;
  1325. ///////////////////
  1326. // Member Objects
  1327. ///////////////////
  1328. case 'Account':
  1329. /**
  1330. * Gets the value for the Account object referenced by intAccountId (Not Null)
  1331. * @return Account
  1332. */
  1333. try {
  1334. if ((!$this->objAccount) && (!is_null($this->intAccountId)))
  1335. $this->objAccount = Account::Load($this->intAccountId);
  1336. return $this->objAccount;
  1337. } catch (QCallerException $objExc) {
  1338. $objExc->IncrementOffset();
  1339. throw $objExc;
  1340. }
  1341. case 'ShippingMethod':
  1342. /**
  1343. * Gets the value for the ShippingMethod object referenced by intShippingMethodId
  1344. * @return ShippingMethod
  1345. */
  1346. try {
  1347. if ((!$this->objShippingMethod) && (!is_null($this->intShippingMethodId)))
  1348. $this->objShippingMethod = ShippingMethod::Load($this->intShippingMethodId);
  1349. return $this->objShippingMethod;
  1350. } catch (QCallerException $objExc) {
  1351. $objExc->IncrementOffset();
  1352. throw $objExc;
  1353. }
  1354. case 'PaymentMethod':
  1355. /**
  1356. * Gets the value for the PaymentMethod object referenced by intPaymentMethodId
  1357. * @return PaymentMethod
  1358. */
  1359. try {
  1360. if ((!$this->objPaymentMethod) && (!is_null($this->intPaymentMethodId)))
  1361. $this->objPaymentMethod = PaymentMethod::Load($this->intPaymentMethodId);
  1362. return $this->objPaymentMethod;
  1363. } catch (QCallerException $objExc) {
  1364. $objExc->IncrementOffset();
  1365. throw $objExc;
  1366. }
  1367. ////////////////////////////
  1368. // Virtual Object References (Many to Many and Reverse References)
  1369. // (If restored via a "Many-to" expansion)
  1370. ////////////////////////////
  1371. case '_AuthorizeNetTransaction':
  1372. /**
  1373. * Gets the value for the private _objAuthorizeNetTransaction (Read-Only)
  1374. * if set due to an expansion on the authorize_net_transaction.order_id reverse relationship
  1375. * @return AuthorizeNetTransaction
  1376. */
  1377. return $this->_objAuthorizeNetTransaction;
  1378. case '_AuthorizeNetTransactionArray':
  1379. /**
  1380. * Gets the value for the private _objAuthorizeNetTransactionArray (Read-Only)
  1381. * if set due to an ExpandAsArray on the authorize_net_transaction.order_id reverse relationship
  1382. * @return AuthorizeNetTransaction[]
  1383. */
  1384. return (array) $this->_objAuthorizeNetTransactionArray;
  1385. case '_OrderAddress':
  1386. /**
  1387. * Gets the value for the private _objOrderAddress (Read-Only)
  1388. * if set due to an expansion on the order_address.order_id reverse relationship
  1389. * @return OrderAddress
  1390. */
  1391. return $this->_objOrderAddress;
  1392. case '_OrderAddressArray':
  1393. /**
  1394. * Gets the value for the private _objOrderAddressArray (Read-Only)
  1395. * if set due to an ExpandAsArray on the order_address.order_id reverse relationship
  1396. * @return OrderAddress[]
  1397. */
  1398. return (array) $this->_objOrderAddressArray;
  1399. case '_OrderChange':
  1400. /**
  1401. * Gets the value for the private _objOrderChange (Read-Only)
  1402. * if set due to an expansion on the order_change.order_id reverse relationship
  1403. * @return OrderChange
  1404. */
  1405. return $this->_objOrderChange;
  1406. case '_OrderChangeArray':
  1407. /**
  1408. * Gets the value for the private _objOrderChangeArray (Read-Only)
  1409. * if set due to an ExpandAsArray on the order_change.order_id reverse relationship
  1410. * @return OrderChange[]
  1411. */
  1412. return (array) $this->_objOrderChangeArray;
  1413. case '_OrderItem':
  1414. /**
  1415. * Gets the value for the private _objOrderItem (Read-Only)
  1416. * if set due to an expansion on the order_item.order_id reverse relationship
  1417. * @return OrderItem
  1418. */
  1419. return $this->_objOrderItem;
  1420. case '_OrderItemArray':
  1421. /**
  1422. * Gets the value for the private _objOrderItemArray (Read-Only)
  1423. * if set due to an ExpandAsArray on the order_item.order_id reverse relationship
  1424. * @return OrderItem[]
  1425. */
  1426. return (array) $this->_objOrderItemArray;
  1427. case '_OrderStatusHistory':
  1428. /**
  1429. * Gets the value for the private _objOrderStatusHistory (Read-Only)
  1430. * if set due to an expansion on the order_status_history.order_id reverse relationship
  1431. * @return OrderStatusHistory
  1432. */
  1433. return $this->_objOrderStatusHistory;
  1434. case '_OrderStatusHistoryArray':
  1435. /**
  1436. * Gets the value for the private _objOrderStatusHistoryArray (Read-Only)
  1437. * if set due to an ExpandAsArray on the order_status_history.order_id reverse relationship
  1438. * @return OrderStatusHistory[]
  1439. */
  1440. return (array) $this->_objOrderStatusHistoryArray;
  1441. case '_PaypalTransaction':
  1442. /**
  1443. * Gets the value for the private _objPaypalTransaction (Read-Only)
  1444. * if set due to an expansion on the paypal_transaction.order_id reverse relationship
  1445. * @return PaypalTransaction
  1446. */
  1447. return $this->_objPaypalTransaction;
  1448. case '_PaypalTransactionArray':
  1449. /**
  1450. * Gets the value for the private _objPaypalTransactionArray (Read-Only)
  1451. * if set due to an ExpandAsArray on the paypal_transaction.order_id reverse relationship
  1452. * @return PaypalTransaction[]
  1453. */
  1454. return (array) $this->_objPaypalTransactionArray;
  1455. case '_TrackingNumber':
  1456. /**
  1457. * Gets the value for the private _objTrackingNumber (Read-Only)
  1458. * if set due to an expansion on the tracking_number.order_id reverse relationship
  1459. * @return TrackingNumber
  1460. */
  1461. return $this->_objTrackingNumber;
  1462. case '_TrackingNumberArray':
  1463. /**
  1464. * Gets the value for the private _objTrackingNumberArray (Read-Only)
  1465. * if set due to an ExpandAsArray on the tracking_number.order_id reverse relationship
  1466. * @return TrackingNumber[]
  1467. */
  1468. return (array) $this->_objTrackingNumberArray;
  1469. case '__Restored':
  1470. return $this->__blnRestored;
  1471. default:
  1472. try {
  1473. return parent::__get($strName);
  1474. } catch (QCallerException $objExc) {
  1475. $objExc->IncrementOffset();
  1476. throw $objExc;
  1477. }
  1478. }
  1479. }
  1480. /**
  1481. * Override method to perform a property "Set"
  1482. * This will set the property $strName to be $mixValue
  1483. *
  1484. * @param string $strName Name of the property to set
  1485. * @param string $mixValue New value of the property
  1486. * @return mixed
  1487. */
  1488. public function __set($strName, $mixValue) {
  1489. switch ($strName) {
  1490. ///////////////////
  1491. // Member Variables
  1492. ///////////////////
  1493. case 'AccountId':
  1494. /**
  1495. * Sets the value for intAccountId (Not Null)
  1496. * @param integer $mixValue
  1497. * @return integer
  1498. */
  1499. try {
  1500. $this->objAccount = null;
  1501. return ($this->intAccountId = QType::Cast($mixValue, QType::Integer));
  1502. } catch (QCallerException $objExc) {
  1503. $objExc->IncrementOffset();
  1504. throw $objExc;
  1505. }
  1506. case 'CompletionDate':
  1507. /**
  1508. * Sets the value for dttCompletionDate
  1509. * @param QDateTime $mixValue
  1510. * @return QDateTime
  1511. */
  1512. try {
  1513. return ($this->dttCompletionDate = QType::Cast($mixValue, QType::DateTime));
  1514. } catch (QCallerException $objExc) {
  1515. $objExc->IncrementOffset();
  1516. throw $objExc;
  1517. }
  1518. case 'ProductTotalCost':
  1519. /**
  1520. * Sets the value for fltProductTotalCost
  1521. * @param double $mixValue
  1522. * @return double
  1523. */
  1524. try {
  1525. return ($this->fltProductTotalCost = QType::Cast($mixValue, QType::Float));
  1526. } catch (QCallerException $objExc) {
  1527. $objExc->IncrementOffset();
  1528. throw $objExc;
  1529. }
  1530. case 'ShippingCost':
  1531. /**
  1532. * Sets the value for fltShippingCost
  1533. * @param double $mixValue
  1534. * @return double
  1535. */
  1536. try {
  1537. return ($this->fltShippingCost = QType::Cast($mixValue, QType::Float));
  1538. } catch (QCallerException $objExc) {
  1539. $objExc->IncrementOffset();
  1540. throw $objExc;
  1541. }
  1542. case 'ShippingCharged':
  1543. /**
  1544. * Sets the value for fltShippingCharged
  1545. * @param double $mixValue
  1546. * @return double
  1547. */
  1548. try {
  1549. return ($this->fltShippingCharged = QType::Cast($mixValue, QType::Float));
  1550. } catch (QCallerException $objExc) {
  1551. $objExc->IncrementOffset();
  1552. throw $objExc;
  1553. }
  1554. case 'HandlingCost':
  1555. /**
  1556. * Sets the value for fltHandlingCost
  1557. * @param double $mixValue
  1558. * @return double
  1559. */
  1560. try {
  1561. return ($this->fltHandlingCost = QType::Cast($mixValue, QType::Float));
  1562. } catch (QCallerException $objExc) {
  1563. $objExc->IncrementOffset();
  1564. throw $objExc;
  1565. }
  1566. case 'HandlingCharged':
  1567. /**
  1568. * Sets the value for fltHandlingCharged
  1569. * @param double $mixValue
  1570. * @return double
  1571. */
  1572. try {
  1573. return ($this->fltHandlingCharged = QType::Cast($mixValue, QType::Float));
  1574. } catch (QCallerException $objExc) {
  1575. $objExc->IncrementOffset();
  1576. throw $objExc;
  1577. }
  1578. case 'Tax':
  1579. /**
  1580. * Sets the value for fltTax
  1581. * @param double $mixValue
  1582. * @return double
  1583. */
  1584. try {
  1585. return ($this->fltTax = QType::Cast($mixValue, QType::Float));
  1586. } catch (QCallerException $objExc) {
  1587. $objExc->IncrementOffset();
  1588. throw $objExc;
  1589. }
  1590. case 'ProductTotalCharged':
  1591. /**
  1592. * Sets the value for fltProductTotalCharged
  1593. * @param double $mixValue
  1594. * @return double
  1595. */
  1596. try {
  1597. return ($this->fltProductTotalCharged = QType::Cast($mixValue, QType::Float));
  1598. } catch (QCallerException $objExc) {
  1599. $objExc->IncrementOffset();
  1600. throw $objExc;
  1601. }
  1602. case 'Notes':
  1603. /**
  1604. * Sets the value for strNotes
  1605. * @param string $mixValue
  1606. * @return string
  1607. */
  1608. try {
  1609. return ($this->strNotes = QType::Cast($mixValue, QType::String));
  1610. } catch (QCallerException $objExc) {
  1611. $objExc->IncrementOffset();
  1612. throw $objExc;
  1613. }
  1614. case 'ShippingMethodId':
  1615. /**
  1616. * Sets the value for intShippingMethodId
  1617. * @param integer $mixValue
  1618. * @return integer
  1619. */
  1620. try {
  1621. $this->objShippingMethod = null;
  1622. return ($this->intShippingMethodId = QType::Cast($mixValue, QType::Integer));
  1623. } catch (QCallerException $objExc) {
  1624. $objExc->IncrementOffset();
  1625. throw $objExc;
  1626. }
  1627. case 'PaymentMethodId':
  1628. /**
  1629. * Sets the value for intPaymentMethodId
  1630. * @param integer $mixValue
  1631. * @return integer
  1632. */
  1633. try {
  1634. $this->objPaymentMethod = null;
  1635. return ($this->intPaymentMethodId = QType::Cast($mixValue, QType::Integer));
  1636. } catch (QCallerException $objExc) {
  1637. $objExc->IncrementOffset();
  1638. throw $objExc;
  1639. }
  1640. case 'StatusId':
  1641. /**
  1642. * Sets the value for intStatusId (Not Null)
  1643. * @param integer $mixValue
  1644. * @return integer
  1645. */
  1646. try {
  1647. return ($this->intStatusId = QType::Cast($mixValue, QType::Integer));
  1648. } catch (QCallerException $objExc) {
  1649. $objExc->IncrementOffset();
  1650. throw $objExc;
  1651. }
  1652. case 'TypeId':
  1653. /**
  1654. * Sets the value for intTypeId
  1655. * @param integer $mixValue
  1656. * @return integer
  1657. */
  1658. try {
  1659. return ($this->intTypeId = QType::Cast($mixValue, QType::Integer));
  1660. } catch (QCallerException $objExc) {
  1661. $objExc->IncrementOffset();
  1662. throw $objExc;
  1663. }
  1664. ///////////////////
  1665. // Member Objects
  1666. ///////////////////
  1667. case 'Account':
  1668. /**
  1669. * Sets the value for the Account object referenced by intAccountId (Not Null)
  1670. * @param Account $mixValue
  1671. * @return Account
  1672. */
  1673. if (is_null($mixValue)) {
  1674. $this->intAccountId = null;
  1675. $this->objAccount = null;
  1676. return null;
  1677. } else {
  1678. // Make sure $mixValue actually is a Account object
  1679. try {
  1680. $mixValue = QType::Cast($mixValue, 'Account');
  1681. } catch (QInvalidCastException $objExc) {
  1682. $objExc->IncrementOffset();
  1683. throw $objExc;
  1684. }
  1685. // Make sure $mixValue is a SAVED Account object
  1686. if (is_null($mixValue->Id))
  1687. throw new QCallerException('Unable to set an unsaved Account for this Order');
  1688. // Update Local Member Variables
  1689. $this->objAccount = $mixValue;
  1690. $this->intAccountId = $mixValue->Id;
  1691. // Return $mixValue
  1692. return $mixValue;
  1693. }
  1694. break;
  1695. case 'ShippingMethod':
  1696. /**
  1697. * Sets the value for the ShippingMethod object referenced by intShippingMethodId
  1698. * @param ShippingMethod $mixValue
  1699. * @return ShippingMethod
  1700. */
  1701. if (is_null($mixValue)) {
  1702. $this->intShippingMethodId = null;
  1703. $this->objShippingMethod = null;
  1704. return null;
  1705. } else {
  1706. // Make sure $mixValue actually is a ShippingMethod object
  1707. try {
  1708. $mixValue = QType::Cast($mixValue, 'ShippingMethod');
  1709. } catch (QInvalidCastException $objExc) {
  1710. $objExc->IncrementOffset();
  1711. throw $objExc;
  1712. }
  1713. // Make sure $mixValue is a SAVED ShippingMethod object
  1714. if (is_null($mixValue->Id))
  1715. throw new QCallerException('Unable to set an unsaved ShippingMethod for this Order');
  1716. // Update Local Member Variables
  1717. $this->objShippingMethod = $mixValue;
  1718. $this->intShippingMethodId = $mixValue->Id;
  1719. // Return $mixValue
  1720. return $mixValue;
  1721. }
  1722. break;
  1723. case 'PaymentMethod':
  1724. /**
  1725. * Sets the value for the PaymentMethod object referenced by intPaymentMethodId
  1726. * @param PaymentMethod $mixValue
  1727. * @return PaymentMethod
  1728. */
  1729. if (is_null($mixValue)) {
  1730. $this->intPaymentMethodId = null;
  1731. $this->objPaymentMethod = null;
  1732. return null;
  1733. } else {
  1734. // Make sure $mixValue actually is a PaymentMethod object
  1735. try {
  1736. $mixValue = QType::Cast($mixValue, 'PaymentMethod');
  1737. } catch (QInvalidCastException $objExc) {
  1738. $objExc->IncrementOffset();
  1739. throw $objExc;
  1740. }
  1741. // Make sure $mixValue is a SAVED PaymentMethod object
  1742. if (is_null($mixValue->Id))
  1743. throw new QCallerException('Unable to set an unsaved PaymentMethod for this Order');
  1744. // Update Local Member Variables
  1745. $this->objPaymentMethod = $mixValue;
  1746. $this->intPaymentMethodId = $mixValue->Id;
  1747. // Return $mixValue
  1748. return $mixValue;
  1749. }
  1750. break;
  1751. default:
  1752. try {
  1753. return parent::__set($strName, $mixValue);
  1754. } catch (QCallerException $objExc) {
  1755. $objExc->IncrementOffset();
  1756. throw $objExc;
  1757. }
  1758. }
  1759. }
  1760. ///////////////////////////////
  1761. // ASSOCIATED OBJECTS' METHODS
  1762. ///////////////////////////////
  1763. // Related Objects' Methods for AuthorizeNetTransaction
  1764. //-------------------------------------------------------------------
  1765. /**
  1766. * Gets all associated AuthorizeNetTransactions as an array of AuthorizeNetTransaction objects
  1767. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1768. * @return AuthorizeNetTransaction[]
  1769. */
  1770. public function GetAuthorizeNetTransactionArray($objOptionalClauses = null) {
  1771. if ((is_null($this->intId)))
  1772. return array();
  1773. try {
  1774. return AuthorizeNetTransaction::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  1775. } catch (QCallerException $objExc) {
  1776. $objExc->IncrementOffset();
  1777. throw $objExc;
  1778. }
  1779. }
  1780. /**
  1781. * Counts all associated AuthorizeNetTransactions
  1782. * @return int
  1783. */
  1784. public function CountAuthorizeNetTransactions() {
  1785. if ((is_null($this->intId)))
  1786. return 0;
  1787. return AuthorizeNetTransaction::CountByOrderId($this->intId);
  1788. }
  1789. /**
  1790. * Associates a AuthorizeNetTransaction
  1791. * @param AuthorizeNetTransaction $objAuthorizeNetTransaction
  1792. * @return void
  1793. */
  1794. public function AssociateAuthorizeNetTransaction(AuthorizeNetTransaction $objAuthorizeNetTransaction) {
  1795. if ((is_null($this->intId)))
  1796. throw new QUndefinedPrimaryKeyException('Unable to call AssociateAuthorizeNetTransaction on this unsaved Order.');
  1797. if ((is_null($objAuthorizeNetTransaction->Id)))
  1798. throw new QUndefinedPrimaryKeyException('Unable to call AssociateAuthorizeNetTransaction on this Order with an unsaved AuthorizeNetTransaction.');
  1799. // Get the Database Object for this Class
  1800. $objDatabase = Order::GetDatabase();
  1801. // Perform the SQL Query
  1802. $objDatabase->NonQuery('
  1803. UPDATE
  1804. `authorize_net_transaction`
  1805. SET
  1806. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1807. WHERE
  1808. `id` = ' . $objDatabase->SqlVariable($objAuthorizeNetTransaction->Id) . '
  1809. ');
  1810. }
  1811. /**
  1812. * Unassociates a AuthorizeNetTransaction
  1813. * @param AuthorizeNetTransaction $objAuthorizeNetTransaction
  1814. * @return void
  1815. */
  1816. public function UnassociateAuthorizeNetTransaction(AuthorizeNetTransaction $objAuthorizeNetTransaction) {
  1817. if ((is_null($this->intId)))
  1818. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAuthorizeNetTransaction on this unsaved Order.');
  1819. if ((is_null($objAuthorizeNetTransaction->Id)))
  1820. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAuthorizeNetTransaction on this Order with an unsaved AuthorizeNetTransaction.');
  1821. // Get the Database Object for this Class
  1822. $objDatabase = Order::GetDatabase();
  1823. // Perform the SQL Query
  1824. $objDatabase->NonQuery('
  1825. UPDATE
  1826. `authorize_net_transaction`
  1827. SET
  1828. `order_id` = null
  1829. WHERE
  1830. `id` = ' . $objDatabase->SqlVariable($objAuthorizeNetTransaction->Id) . ' AND
  1831. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1832. ');
  1833. }
  1834. /**
  1835. * Unassociates all AuthorizeNetTransactions
  1836. * @return void
  1837. */
  1838. public function UnassociateAllAuthorizeNetTransactions() {
  1839. if ((is_null($this->intId)))
  1840. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAuthorizeNetTransaction on this unsaved Order.');
  1841. // Get the Database Object for this Class
  1842. $objDatabase = Order::GetDatabase();
  1843. // Perform the SQL Query
  1844. $objDatabase->NonQuery('
  1845. UPDATE
  1846. `authorize_net_transaction`
  1847. SET
  1848. `order_id` = null
  1849. WHERE
  1850. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1851. ');
  1852. }
  1853. /**
  1854. * Deletes an associated AuthorizeNetTransaction
  1855. * @param AuthorizeNetTransaction $objAuthorizeNetTransaction
  1856. * @return void
  1857. */
  1858. public function DeleteAssociatedAuthorizeNetTransaction(AuthorizeNetTransaction $objAuthorizeNetTransaction) {
  1859. if ((is_null($this->intId)))
  1860. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAuthorizeNetTransaction on this unsaved Order.');
  1861. if ((is_null($objAuthorizeNetTransaction->Id)))
  1862. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAuthorizeNetTransaction on this Order with an unsaved AuthorizeNetTransaction.');
  1863. // Get the Database Object for this Class
  1864. $objDatabase = Order::GetDatabase();
  1865. // Perform the SQL Query
  1866. $objDatabase->NonQuery('
  1867. DELETE FROM
  1868. `authorize_net_transaction`
  1869. WHERE
  1870. `id` = ' . $objDatabase->SqlVariable($objAuthorizeNetTransaction->Id) . ' AND
  1871. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1872. ');
  1873. }
  1874. /**
  1875. * Deletes all associated AuthorizeNetTransactions
  1876. * @return void
  1877. */
  1878. public function DeleteAllAuthorizeNetTransactions() {
  1879. if ((is_null($this->intId)))
  1880. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateAuthorizeNetTransaction on this unsaved Order.');
  1881. // Get the Database Object for this Class
  1882. $objDatabase = Order::GetDatabase();
  1883. // Perform the SQL Query
  1884. $objDatabase->NonQuery('
  1885. DELETE FROM
  1886. `authorize_net_transaction`
  1887. WHERE
  1888. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1889. ');
  1890. }
  1891. // Related Objects' Methods for OrderAddress
  1892. //-------------------------------------------------------------------
  1893. /**
  1894. * Gets all associated OrderAddresses as an array of OrderAddress objects
  1895. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  1896. * @return OrderAddress[]
  1897. */
  1898. public function GetOrderAddressArray($objOptionalClauses = null) {
  1899. if ((is_null($this->intId)))
  1900. return array();
  1901. try {
  1902. return OrderAddress::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  1903. } catch (QCallerException $objExc) {
  1904. $objExc->IncrementOffset();
  1905. throw $objExc;
  1906. }
  1907. }
  1908. /**
  1909. * Counts all associated OrderAddresses
  1910. * @return int
  1911. */
  1912. public function CountOrderAddresses() {
  1913. if ((is_null($this->intId)))
  1914. return 0;
  1915. return OrderAddress::CountByOrderId($this->intId);
  1916. }
  1917. /**
  1918. * Associates a OrderAddress
  1919. * @param OrderAddress $objOrderAddress
  1920. * @return void
  1921. */
  1922. public function AssociateOrderAddress(OrderAddress $objOrderAddress) {
  1923. if ((is_null($this->intId)))
  1924. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderAddress on this unsaved Order.');
  1925. if ((is_null($objOrderAddress->Id)))
  1926. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderAddress on this Order with an unsaved OrderAddress.');
  1927. // Get the Database Object for this Class
  1928. $objDatabase = Order::GetDatabase();
  1929. // Perform the SQL Query
  1930. $objDatabase->NonQuery('
  1931. UPDATE
  1932. `order_address`
  1933. SET
  1934. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1935. WHERE
  1936. `id` = ' . $objDatabase->SqlVariable($objOrderAddress->Id) . '
  1937. ');
  1938. }
  1939. /**
  1940. * Unassociates a OrderAddress
  1941. * @param OrderAddress $objOrderAddress
  1942. * @return void
  1943. */
  1944. public function UnassociateOrderAddress(OrderAddress $objOrderAddress) {
  1945. if ((is_null($this->intId)))
  1946. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderAddress on this unsaved Order.');
  1947. if ((is_null($objOrderAddress->Id)))
  1948. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderAddress on this Order with an unsaved OrderAddress.');
  1949. // Get the Database Object for this Class
  1950. $objDatabase = Order::GetDatabase();
  1951. // Perform the SQL Query
  1952. $objDatabase->NonQuery('
  1953. UPDATE
  1954. `order_address`
  1955. SET
  1956. `order_id` = null
  1957. WHERE
  1958. `id` = ' . $objDatabase->SqlVariable($objOrderAddress->Id) . ' AND
  1959. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1960. ');
  1961. }
  1962. /**
  1963. * Unassociates all OrderAddresses
  1964. * @return void
  1965. */
  1966. public function UnassociateAllOrderAddresses() {
  1967. if ((is_null($this->intId)))
  1968. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderAddress on this unsaved Order.');
  1969. // Get the Database Object for this Class
  1970. $objDatabase = Order::GetDatabase();
  1971. // Perform the SQL Query
  1972. $objDatabase->NonQuery('
  1973. UPDATE
  1974. `order_address`
  1975. SET
  1976. `order_id` = null
  1977. WHERE
  1978. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  1979. ');
  1980. }
  1981. /**
  1982. * Deletes an associated OrderAddress
  1983. * @param OrderAddress $objOrderAddress
  1984. * @return void
  1985. */
  1986. public function DeleteAssociatedOrderAddress(OrderAddress $objOrderAddress) {
  1987. if ((is_null($this->intId)))
  1988. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderAddress on this unsaved Order.');
  1989. if ((is_null($objOrderAddress->Id)))
  1990. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderAddress on this Order with an unsaved OrderAddress.');
  1991. // Get the Database Object for this Class
  1992. $objDatabase = Order::GetDatabase();
  1993. // Perform the SQL Query
  1994. $objDatabase->NonQuery('
  1995. DELETE FROM
  1996. `order_address`
  1997. WHERE
  1998. `id` = ' . $objDatabase->SqlVariable($objOrderAddress->Id) . ' AND
  1999. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2000. ');
  2001. }
  2002. /**
  2003. * Deletes all associated OrderAddresses
  2004. * @return void
  2005. */
  2006. public function DeleteAllOrderAddresses() {
  2007. if ((is_null($this->intId)))
  2008. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderAddress on this unsaved Order.');
  2009. // Get the Database Object for this Class
  2010. $objDatabase = Order::GetDatabase();
  2011. // Perform the SQL Query
  2012. $objDatabase->NonQuery('
  2013. DELETE FROM
  2014. `order_address`
  2015. WHERE
  2016. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2017. ');
  2018. }
  2019. // Related Objects' Methods for OrderChange
  2020. //-------------------------------------------------------------------
  2021. /**
  2022. * Gets all associated OrderChanges as an array of OrderChange objects
  2023. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2024. * @return OrderChange[]
  2025. */
  2026. public function GetOrderChangeArray($objOptionalClauses = null) {
  2027. if ((is_null($this->intId)))
  2028. return array();
  2029. try {
  2030. return OrderChange::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  2031. } catch (QCallerException $objExc) {
  2032. $objExc->IncrementOffset();
  2033. throw $objExc;
  2034. }
  2035. }
  2036. /**
  2037. * Counts all associated OrderChanges
  2038. * @return int
  2039. */
  2040. public function CountOrderChanges() {
  2041. if ((is_null($this->intId)))
  2042. return 0;
  2043. return OrderChange::CountByOrderId($this->intId);
  2044. }
  2045. /**
  2046. * Associates a OrderChange
  2047. * @param OrderChange $objOrderChange
  2048. * @return void
  2049. */
  2050. public function AssociateOrderChange(OrderChange $objOrderChange) {
  2051. if ((is_null($this->intId)))
  2052. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderChange on this unsaved Order.');
  2053. if ((is_null($objOrderChange->OrderId)) || (is_null($objOrderChange->Date)))
  2054. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderChange on this Order with an unsaved OrderChange.');
  2055. // Get the Database Object for this Class
  2056. $objDatabase = Order::GetDatabase();
  2057. // Perform the SQL Query
  2058. $objDatabase->NonQuery('
  2059. UPDATE
  2060. `order_change`
  2061. SET
  2062. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2063. WHERE
  2064. `order_id` = ' . $objDatabase->SqlVariable($objOrderChange->OrderId) . ' AND
  2065. `date` = ' . $objDatabase->SqlVariable($objOrderChange->Date) . '
  2066. ');
  2067. }
  2068. /**
  2069. * Unassociates a OrderChange
  2070. * @param OrderChange $objOrderChange
  2071. * @return void
  2072. */
  2073. public function UnassociateOrderChange(OrderChange $objOrderChange) {
  2074. if ((is_null($this->intId)))
  2075. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderChange on this unsaved Order.');
  2076. if ((is_null($objOrderChange->OrderId)) || (is_null($objOrderChange->Date)))
  2077. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderChange on this Order with an unsaved OrderChange.');
  2078. // Get the Database Object for this Class
  2079. $objDatabase = Order::GetDatabase();
  2080. // Perform the SQL Query
  2081. $objDatabase->NonQuery('
  2082. UPDATE
  2083. `order_change`
  2084. SET
  2085. `order_id` = null
  2086. WHERE
  2087. `order_id` = ' . $objDatabase->SqlVariable($objOrderChange->OrderId) . ' AND
  2088. `date` = ' . $objDatabase->SqlVariable($objOrderChange->Date) . ' AND
  2089. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2090. ');
  2091. }
  2092. /**
  2093. * Unassociates all OrderChanges
  2094. * @return void
  2095. */
  2096. public function UnassociateAllOrderChanges() {
  2097. if ((is_null($this->intId)))
  2098. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderChange on this unsaved Order.');
  2099. // Get the Database Object for this Class
  2100. $objDatabase = Order::GetDatabase();
  2101. // Perform the SQL Query
  2102. $objDatabase->NonQuery('
  2103. UPDATE
  2104. `order_change`
  2105. SET
  2106. `order_id` = null
  2107. WHERE
  2108. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2109. ');
  2110. }
  2111. /**
  2112. * Deletes an associated OrderChange
  2113. * @param OrderChange $objOrderChange
  2114. * @return void
  2115. */
  2116. public function DeleteAssociatedOrderChange(OrderChange $objOrderChange) {
  2117. if ((is_null($this->intId)))
  2118. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderChange on this unsaved Order.');
  2119. if ((is_null($objOrderChange->OrderId)) || (is_null($objOrderChange->Date)))
  2120. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderChange on this Order with an unsaved OrderChange.');
  2121. // Get the Database Object for this Class
  2122. $objDatabase = Order::GetDatabase();
  2123. // Perform the SQL Query
  2124. $objDatabase->NonQuery('
  2125. DELETE FROM
  2126. `order_change`
  2127. WHERE
  2128. `order_id` = ' . $objDatabase->SqlVariable($objOrderChange->OrderId) . ' AND
  2129. `date` = ' . $objDatabase->SqlVariable($objOrderChange->Date) . ' AND
  2130. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2131. ');
  2132. }
  2133. /**
  2134. * Deletes all associated OrderChanges
  2135. * @return void
  2136. */
  2137. public function DeleteAllOrderChanges() {
  2138. if ((is_null($this->intId)))
  2139. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderChange on this unsaved Order.');
  2140. // Get the Database Object for this Class
  2141. $objDatabase = Order::GetDatabase();
  2142. // Perform the SQL Query
  2143. $objDatabase->NonQuery('
  2144. DELETE FROM
  2145. `order_change`
  2146. WHERE
  2147. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2148. ');
  2149. }
  2150. // Related Objects' Methods for OrderItem
  2151. //-------------------------------------------------------------------
  2152. /**
  2153. * Gets all associated OrderItems as an array of OrderItem objects
  2154. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2155. * @return OrderItem[]
  2156. */
  2157. public function GetOrderItemArray($objOptionalClauses = null) {
  2158. if ((is_null($this->intId)))
  2159. return array();
  2160. try {
  2161. return OrderItem::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  2162. } catch (QCallerException $objExc) {
  2163. $objExc->IncrementOffset();
  2164. throw $objExc;
  2165. }
  2166. }
  2167. /**
  2168. * Counts all associated OrderItems
  2169. * @return int
  2170. */
  2171. public function CountOrderItems() {
  2172. if ((is_null($this->intId)))
  2173. return 0;
  2174. return OrderItem::CountByOrderId($this->intId);
  2175. }
  2176. /**
  2177. * Associates a OrderItem
  2178. * @param OrderItem $objOrderItem
  2179. * @return void
  2180. */
  2181. public function AssociateOrderItem(OrderItem $objOrderItem) {
  2182. if ((is_null($this->intId)))
  2183. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderItem on this unsaved Order.');
  2184. if ((is_null($objOrderItem->OrderId)) || (is_null($objOrderItem->ProductId)))
  2185. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderItem on this Order with an unsaved OrderItem.');
  2186. // Get the Database Object for this Class
  2187. $objDatabase = Order::GetDatabase();
  2188. // Perform the SQL Query
  2189. $objDatabase->NonQuery('
  2190. UPDATE
  2191. `order_item`
  2192. SET
  2193. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2194. WHERE
  2195. `order_id` = ' . $objDatabase->SqlVariable($objOrderItem->OrderId) . ' AND
  2196. `product_id` = ' . $objDatabase->SqlVariable($objOrderItem->ProductId) . '
  2197. ');
  2198. }
  2199. /**
  2200. * Unassociates a OrderItem
  2201. * @param OrderItem $objOrderItem
  2202. * @return void
  2203. */
  2204. public function UnassociateOrderItem(OrderItem $objOrderItem) {
  2205. if ((is_null($this->intId)))
  2206. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderItem on this unsaved Order.');
  2207. if ((is_null($objOrderItem->OrderId)) || (is_null($objOrderItem->ProductId)))
  2208. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderItem on this Order with an unsaved OrderItem.');
  2209. // Get the Database Object for this Class
  2210. $objDatabase = Order::GetDatabase();
  2211. // Perform the SQL Query
  2212. $objDatabase->NonQuery('
  2213. UPDATE
  2214. `order_item`
  2215. SET
  2216. `order_id` = null
  2217. WHERE
  2218. `order_id` = ' . $objDatabase->SqlVariable($objOrderItem->OrderId) . ' AND
  2219. `product_id` = ' . $objDatabase->SqlVariable($objOrderItem->ProductId) . ' AND
  2220. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2221. ');
  2222. }
  2223. /**
  2224. * Unassociates all OrderItems
  2225. * @return void
  2226. */
  2227. public function UnassociateAllOrderItems() {
  2228. if ((is_null($this->intId)))
  2229. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderItem on this unsaved Order.');
  2230. // Get the Database Object for this Class
  2231. $objDatabase = Order::GetDatabase();
  2232. // Perform the SQL Query
  2233. $objDatabase->NonQuery('
  2234. UPDATE
  2235. `order_item`
  2236. SET
  2237. `order_id` = null
  2238. WHERE
  2239. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2240. ');
  2241. }
  2242. /**
  2243. * Deletes an associated OrderItem
  2244. * @param OrderItem $objOrderItem
  2245. * @return void
  2246. */
  2247. public function DeleteAssociatedOrderItem(OrderItem $objOrderItem) {
  2248. if ((is_null($this->intId)))
  2249. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderItem on this unsaved Order.');
  2250. if ((is_null($objOrderItem->OrderId)) || (is_null($objOrderItem->ProductId)))
  2251. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderItem on this Order with an unsaved OrderItem.');
  2252. // Get the Database Object for this Class
  2253. $objDatabase = Order::GetDatabase();
  2254. // Perform the SQL Query
  2255. $objDatabase->NonQuery('
  2256. DELETE FROM
  2257. `order_item`
  2258. WHERE
  2259. `order_id` = ' . $objDatabase->SqlVariable($objOrderItem->OrderId) . ' AND
  2260. `product_id` = ' . $objDatabase->SqlVariable($objOrderItem->ProductId) . ' AND
  2261. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2262. ');
  2263. }
  2264. /**
  2265. * Deletes all associated OrderItems
  2266. * @return void
  2267. */
  2268. public function DeleteAllOrderItems() {
  2269. if ((is_null($this->intId)))
  2270. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderItem on this unsaved Order.');
  2271. // Get the Database Object for this Class
  2272. $objDatabase = Order::GetDatabase();
  2273. // Perform the SQL Query
  2274. $objDatabase->NonQuery('
  2275. DELETE FROM
  2276. `order_item`
  2277. WHERE
  2278. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2279. ');
  2280. }
  2281. // Related Objects' Methods for OrderStatusHistory
  2282. //-------------------------------------------------------------------
  2283. /**
  2284. * Gets all associated OrderStatusHistories as an array of OrderStatusHistory objects
  2285. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2286. * @return OrderStatusHistory[]
  2287. */
  2288. public function GetOrderStatusHistoryArray($objOptionalClauses = null) {
  2289. if ((is_null($this->intId)))
  2290. return array();
  2291. try {
  2292. return OrderStatusHistory::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  2293. } catch (QCallerException $objExc) {
  2294. $objExc->IncrementOffset();
  2295. throw $objExc;
  2296. }
  2297. }
  2298. /**
  2299. * Counts all associated OrderStatusHistories
  2300. * @return int
  2301. */
  2302. public function CountOrderStatusHistories() {
  2303. if ((is_null($this->intId)))
  2304. return 0;
  2305. return OrderStatusHistory::CountByOrderId($this->intId);
  2306. }
  2307. /**
  2308. * Associates a OrderStatusHistory
  2309. * @param OrderStatusHistory $objOrderStatusHistory
  2310. * @return void
  2311. */
  2312. public function AssociateOrderStatusHistory(OrderStatusHistory $objOrderStatusHistory) {
  2313. if ((is_null($this->intId)))
  2314. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderStatusHistory on this unsaved Order.');
  2315. if ((is_null($objOrderStatusHistory->Id)))
  2316. throw new QUndefinedPrimaryKeyException('Unable to call AssociateOrderStatusHistory on this Order with an unsaved OrderStatusHistory.');
  2317. // Get the Database Object for this Class
  2318. $objDatabase = Order::GetDatabase();
  2319. // Perform the SQL Query
  2320. $objDatabase->NonQuery('
  2321. UPDATE
  2322. `order_status_history`
  2323. SET
  2324. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2325. WHERE
  2326. `id` = ' . $objDatabase->SqlVariable($objOrderStatusHistory->Id) . '
  2327. ');
  2328. }
  2329. /**
  2330. * Unassociates a OrderStatusHistory
  2331. * @param OrderStatusHistory $objOrderStatusHistory
  2332. * @return void
  2333. */
  2334. public function UnassociateOrderStatusHistory(OrderStatusHistory $objOrderStatusHistory) {
  2335. if ((is_null($this->intId)))
  2336. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderStatusHistory on this unsaved Order.');
  2337. if ((is_null($objOrderStatusHistory->Id)))
  2338. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderStatusHistory on this Order with an unsaved OrderStatusHistory.');
  2339. // Get the Database Object for this Class
  2340. $objDatabase = Order::GetDatabase();
  2341. // Perform the SQL Query
  2342. $objDatabase->NonQuery('
  2343. UPDATE
  2344. `order_status_history`
  2345. SET
  2346. `order_id` = null
  2347. WHERE
  2348. `id` = ' . $objDatabase->SqlVariable($objOrderStatusHistory->Id) . ' AND
  2349. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2350. ');
  2351. }
  2352. /**
  2353. * Unassociates all OrderStatusHistories
  2354. * @return void
  2355. */
  2356. public function UnassociateAllOrderStatusHistories() {
  2357. if ((is_null($this->intId)))
  2358. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderStatusHistory on this unsaved Order.');
  2359. // Get the Database Object for this Class
  2360. $objDatabase = Order::GetDatabase();
  2361. // Perform the SQL Query
  2362. $objDatabase->NonQuery('
  2363. UPDATE
  2364. `order_status_history`
  2365. SET
  2366. `order_id` = null
  2367. WHERE
  2368. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2369. ');
  2370. }
  2371. /**
  2372. * Deletes an associated OrderStatusHistory
  2373. * @param OrderStatusHistory $objOrderStatusHistory
  2374. * @return void
  2375. */
  2376. public function DeleteAssociatedOrderStatusHistory(OrderStatusHistory $objOrderStatusHistory) {
  2377. if ((is_null($this->intId)))
  2378. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderStatusHistory on this unsaved Order.');
  2379. if ((is_null($objOrderStatusHistory->Id)))
  2380. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderStatusHistory on this Order with an unsaved OrderStatusHistory.');
  2381. // Get the Database Object for this Class
  2382. $objDatabase = Order::GetDatabase();
  2383. // Perform the SQL Query
  2384. $objDatabase->NonQuery('
  2385. DELETE FROM
  2386. `order_status_history`
  2387. WHERE
  2388. `id` = ' . $objDatabase->SqlVariable($objOrderStatusHistory->Id) . ' AND
  2389. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2390. ');
  2391. }
  2392. /**
  2393. * Deletes all associated OrderStatusHistories
  2394. * @return void
  2395. */
  2396. public function DeleteAllOrderStatusHistories() {
  2397. if ((is_null($this->intId)))
  2398. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateOrderStatusHistory on this unsaved Order.');
  2399. // Get the Database Object for this Class
  2400. $objDatabase = Order::GetDatabase();
  2401. // Perform the SQL Query
  2402. $objDatabase->NonQuery('
  2403. DELETE FROM
  2404. `order_status_history`
  2405. WHERE
  2406. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2407. ');
  2408. }
  2409. // Related Objects' Methods for PaypalTransaction
  2410. //-------------------------------------------------------------------
  2411. /**
  2412. * Gets all associated PaypalTransactions as an array of PaypalTransaction objects
  2413. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2414. * @return PaypalTransaction[]
  2415. */
  2416. public function GetPaypalTransactionArray($objOptionalClauses = null) {
  2417. if ((is_null($this->intId)))
  2418. return array();
  2419. try {
  2420. return PaypalTransaction::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  2421. } catch (QCallerException $objExc) {
  2422. $objExc->IncrementOffset();
  2423. throw $objExc;
  2424. }
  2425. }
  2426. /**
  2427. * Counts all associated PaypalTransactions
  2428. * @return int
  2429. */
  2430. public function CountPaypalTransactions() {
  2431. if ((is_null($this->intId)))
  2432. return 0;
  2433. return PaypalTransaction::CountByOrderId($this->intId);
  2434. }
  2435. /**
  2436. * Associates a PaypalTransaction
  2437. * @param PaypalTransaction $objPaypalTransaction
  2438. * @return void
  2439. */
  2440. public function AssociatePaypalTransaction(PaypalTransaction $objPaypalTransaction) {
  2441. if ((is_null($this->intId)))
  2442. throw new QUndefinedPrimaryKeyException('Unable to call AssociatePaypalTransaction on this unsaved Order.');
  2443. if ((is_null($objPaypalTransaction->Id)))
  2444. throw new QUndefinedPrimaryKeyException('Unable to call AssociatePaypalTransaction on this Order with an unsaved PaypalTransaction.');
  2445. // Get the Database Object for this Class
  2446. $objDatabase = Order::GetDatabase();
  2447. // Perform the SQL Query
  2448. $objDatabase->NonQuery('
  2449. UPDATE
  2450. `paypal_transaction`
  2451. SET
  2452. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2453. WHERE
  2454. `id` = ' . $objDatabase->SqlVariable($objPaypalTransaction->Id) . '
  2455. ');
  2456. }
  2457. /**
  2458. * Unassociates a PaypalTransaction
  2459. * @param PaypalTransaction $objPaypalTransaction
  2460. * @return void
  2461. */
  2462. public function UnassociatePaypalTransaction(PaypalTransaction $objPaypalTransaction) {
  2463. if ((is_null($this->intId)))
  2464. throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePaypalTransaction on this unsaved Order.');
  2465. if ((is_null($objPaypalTransaction->Id)))
  2466. throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePaypalTransaction on this Order with an unsaved PaypalTransaction.');
  2467. // Get the Database Object for this Class
  2468. $objDatabase = Order::GetDatabase();
  2469. // Perform the SQL Query
  2470. $objDatabase->NonQuery('
  2471. UPDATE
  2472. `paypal_transaction`
  2473. SET
  2474. `order_id` = null
  2475. WHERE
  2476. `id` = ' . $objDatabase->SqlVariable($objPaypalTransaction->Id) . ' AND
  2477. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2478. ');
  2479. }
  2480. /**
  2481. * Unassociates all PaypalTransactions
  2482. * @return void
  2483. */
  2484. public function UnassociateAllPaypalTransactions() {
  2485. if ((is_null($this->intId)))
  2486. throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePaypalTransaction on this unsaved Order.');
  2487. // Get the Database Object for this Class
  2488. $objDatabase = Order::GetDatabase();
  2489. // Perform the SQL Query
  2490. $objDatabase->NonQuery('
  2491. UPDATE
  2492. `paypal_transaction`
  2493. SET
  2494. `order_id` = null
  2495. WHERE
  2496. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2497. ');
  2498. }
  2499. /**
  2500. * Deletes an associated PaypalTransaction
  2501. * @param PaypalTransaction $objPaypalTransaction
  2502. * @return void
  2503. */
  2504. public function DeleteAssociatedPaypalTransaction(PaypalTransaction $objPaypalTransaction) {
  2505. if ((is_null($this->intId)))
  2506. throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePaypalTransaction on this unsaved Order.');
  2507. if ((is_null($objPaypalTransaction->Id)))
  2508. throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePaypalTransaction on this Order with an unsaved PaypalTransaction.');
  2509. // Get the Database Object for this Class
  2510. $objDatabase = Order::GetDatabase();
  2511. // Perform the SQL Query
  2512. $objDatabase->NonQuery('
  2513. DELETE FROM
  2514. `paypal_transaction`
  2515. WHERE
  2516. `id` = ' . $objDatabase->SqlVariable($objPaypalTransaction->Id) . ' AND
  2517. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2518. ');
  2519. }
  2520. /**
  2521. * Deletes all associated PaypalTransactions
  2522. * @return void
  2523. */
  2524. public function DeleteAllPaypalTransactions() {
  2525. if ((is_null($this->intId)))
  2526. throw new QUndefinedPrimaryKeyException('Unable to call UnassociatePaypalTransaction on this unsaved Order.');
  2527. // Get the Database Object for this Class
  2528. $objDatabase = Order::GetDatabase();
  2529. // Perform the SQL Query
  2530. $objDatabase->NonQuery('
  2531. DELETE FROM
  2532. `paypal_transaction`
  2533. WHERE
  2534. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2535. ');
  2536. }
  2537. // Related Objects' Methods for TrackingNumber
  2538. //-------------------------------------------------------------------
  2539. /**
  2540. * Gets all associated TrackingNumbers as an array of TrackingNumber objects
  2541. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  2542. * @return TrackingNumber[]
  2543. */
  2544. public function GetTrackingNumberArray($objOptionalClauses = null) {
  2545. if ((is_null($this->intId)))
  2546. return array();
  2547. try {
  2548. return TrackingNumber::LoadArrayByOrderId($this->intId, $objOptionalClauses);
  2549. } catch (QCallerException $objExc) {
  2550. $objExc->IncrementOffset();
  2551. throw $objExc;
  2552. }
  2553. }
  2554. /**
  2555. * Counts all associated TrackingNumbers
  2556. * @return int
  2557. */
  2558. public function CountTrackingNumbers() {
  2559. if ((is_null($this->intId)))
  2560. return 0;
  2561. return TrackingNumber::CountByOrderId($this->intId);
  2562. }
  2563. /**
  2564. * Associates a TrackingNumber
  2565. * @param TrackingNumber $objTrackingNumber
  2566. * @return void
  2567. */
  2568. public function AssociateTrackingNumber(TrackingNumber $objTrackingNumber) {
  2569. if ((is_null($this->intId)))
  2570. throw new QUndefinedPrimaryKeyException('Unable to call AssociateTrackingNumber on this unsaved Order.');
  2571. if ((is_null($objTrackingNumber->OrderId)) || (is_null($objTrackingNumber->Number)))
  2572. throw new QUndefinedPrimaryKeyException('Unable to call AssociateTrackingNumber on this Order with an unsaved TrackingNumber.');
  2573. // Get the Database Object for this Class
  2574. $objDatabase = Order::GetDatabase();
  2575. // Perform the SQL Query
  2576. $objDatabase->NonQuery('
  2577. UPDATE
  2578. `tracking_number`
  2579. SET
  2580. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2581. WHERE
  2582. `order_id` = ' . $objDatabase->SqlVariable($objTrackingNumber->OrderId) . ' AND
  2583. `number` = ' . $objDatabase->SqlVariable($objTrackingNumber->Number) . '
  2584. ');
  2585. }
  2586. /**
  2587. * Unassociates a TrackingNumber
  2588. * @param TrackingNumber $objTrackingNumber
  2589. * @return void
  2590. */
  2591. public function UnassociateTrackingNumber(TrackingNumber $objTrackingNumber) {
  2592. if ((is_null($this->intId)))
  2593. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTrackingNumber on this unsaved Order.');
  2594. if ((is_null($objTrackingNumber->OrderId)) || (is_null($objTrackingNumber->Number)))
  2595. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTrackingNumber on this Order with an unsaved TrackingNumber.');
  2596. // Get the Database Object for this Class
  2597. $objDatabase = Order::GetDatabase();
  2598. // Perform the SQL Query
  2599. $objDatabase->NonQuery('
  2600. UPDATE
  2601. `tracking_number`
  2602. SET
  2603. `order_id` = null
  2604. WHERE
  2605. `order_id` = ' . $objDatabase->SqlVariable($objTrackingNumber->OrderId) . ' AND
  2606. `number` = ' . $objDatabase->SqlVariable($objTrackingNumber->Number) . ' AND
  2607. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2608. ');
  2609. }
  2610. /**
  2611. * Unassociates all TrackingNumbers
  2612. * @return void
  2613. */
  2614. public function UnassociateAllTrackingNumbers() {
  2615. if ((is_null($this->intId)))
  2616. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTrackingNumber on this unsaved Order.');
  2617. // Get the Database Object for this Class
  2618. $objDatabase = Order::GetDatabase();
  2619. // Perform the SQL Query
  2620. $objDatabase->NonQuery('
  2621. UPDATE
  2622. `tracking_number`
  2623. SET
  2624. `order_id` = null
  2625. WHERE
  2626. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2627. ');
  2628. }
  2629. /**
  2630. * Deletes an associated TrackingNumber
  2631. * @param TrackingNumber $objTrackingNumber
  2632. * @return void
  2633. */
  2634. public function DeleteAssociatedTrackingNumber(TrackingNumber $objTrackingNumber) {
  2635. if ((is_null($this->intId)))
  2636. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTrackingNumber on this unsaved Order.');
  2637. if ((is_null($objTrackingNumber->OrderId)) || (is_null($objTrackingNumber->Number)))
  2638. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTrackingNumber on this Order with an unsaved TrackingNumber.');
  2639. // Get the Database Object for this Class
  2640. $objDatabase = Order::GetDatabase();
  2641. // Perform the SQL Query
  2642. $objDatabase->NonQuery('
  2643. DELETE FROM
  2644. `tracking_number`
  2645. WHERE
  2646. `order_id` = ' . $objDatabase->SqlVariable($objTrackingNumber->OrderId) . ' AND
  2647. `number` = ' . $objDatabase->SqlVariable($objTrackingNumber->Number) . ' AND
  2648. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2649. ');
  2650. }
  2651. /**
  2652. * Deletes all associated TrackingNumbers
  2653. * @return void
  2654. */
  2655. public function DeleteAllTrackingNumbers() {
  2656. if ((is_null($this->intId)))
  2657. throw new QUndefinedPrimaryKeyException('Unable to call UnassociateTrackingNumber on this unsaved Order.');
  2658. // Get the Database Object for this Class
  2659. $objDatabase = Order::GetDatabase();
  2660. // Perform the SQL Query
  2661. $objDatabase->NonQuery('
  2662. DELETE FROM
  2663. `tracking_number`
  2664. WHERE
  2665. `order_id` = ' . $objDatabase->SqlVariable($this->intId) . '
  2666. ');
  2667. }
  2668. }
  2669. /////////////////////////////////////
  2670. // ADDITIONAL CLASSES for QCODO QUERY
  2671. /////////////////////////////////////
  2672. class QQNodeOrder extends QQNode {
  2673. protected $strTableName = 'order';
  2674. protected $strPrimaryKey = 'id';
  2675. protected $strClassName = 'Order';
  2676. public function __get($strName) {
  2677. switch ($strName) {
  2678. case 'Id':
  2679. return new QQNode('id', 'Id', 'integer', $this);
  2680. case 'AccountId':
  2681. return new QQNode('account_id', 'AccountId', 'integer', $this);
  2682. case 'Account':
  2683. return new QQNodeAccount('account_id', 'Account', 'integer', $this);
  2684. case 'CreationDate':
  2685. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  2686. case 'LastModification':
  2687. return new QQNode('last_modification', 'LastModification', 'string', $this);
  2688. case 'CompletionDate':
  2689. return new QQNode('completion_date', 'CompletionDate', 'QDateTime', $this);
  2690. case 'ProductTotalCost':
  2691. return new QQNode('product_total_cost', 'ProductTotalCost', 'double', $this);
  2692. case 'ShippingCost':
  2693. return new QQNode('shipping_cost', 'ShippingCost', 'double', $this);
  2694. case 'ShippingCharged':
  2695. return new QQNode('shipping_charged', 'ShippingCharged', 'double', $this);
  2696. case 'HandlingCost':
  2697. return new QQNode('handling_cost', 'HandlingCost', 'double', $this);
  2698. case 'HandlingCharged':
  2699. return new QQNode('handling_charged', 'HandlingCharged', 'double', $this);
  2700. case 'Tax':
  2701. return new QQNode('tax', 'Tax', 'double', $this);
  2702. case 'ProductTotalCharged':
  2703. return new QQNode('product_total_charged', 'ProductTotalCharged', 'double', $this);
  2704. case 'Notes':
  2705. return new QQNode('notes', 'Notes', 'string', $this);
  2706. case 'ShippingMethodId':
  2707. return new QQNode('shipping_method_id', 'ShippingMethodId', 'integer', $this);
  2708. case 'ShippingMethod':
  2709. return new QQNodeShippingMethod('shipping_method_id', 'ShippingMethod', 'integer', $this);
  2710. case 'PaymentMethodId':
  2711. return new QQNode('payment_method_id', 'PaymentMethodId', 'integer', $this);
  2712. case 'PaymentMethod':
  2713. return new QQNodePaymentMethod('payment_method_id', 'PaymentMethod', 'integer', $this);
  2714. case 'StatusId':
  2715. return new QQNode('status_id', 'StatusId', 'integer', $this);
  2716. case 'TypeId':
  2717. return new QQNode('type_id', 'TypeId', 'integer', $this);
  2718. case 'AuthorizeNetTransaction':
  2719. return new QQReverseReferenceNodeAuthorizeNetTransaction($this, 'authorizenettransaction', 'reverse_reference', 'order_id');
  2720. case 'OrderAddress':
  2721. return new QQReverseReferenceNodeOrderAddress($this, 'orderaddress', 'reverse_reference', 'order_id');
  2722. case 'OrderChange':
  2723. return new QQReverseReferenceNodeOrderChange($this, 'orderchange', 'reverse_reference', 'order_id');
  2724. case 'OrderItem':
  2725. return new QQReverseReferenceNodeOrderItem($this, 'orderitem', 'reverse_reference', 'order_id');
  2726. case 'OrderStatusHistory':
  2727. return new QQReverseReferenceNodeOrderStatusHistory($this, 'orderstatushistory', 'reverse_reference', 'order_id');
  2728. case 'PaypalTransaction':
  2729. return new QQReverseReferenceNodePaypalTransaction($this, 'paypaltransaction', 'reverse_reference', 'order_id');
  2730. case 'TrackingNumber':
  2731. return new QQReverseReferenceNodeTrackingNumber($this, 'trackingnumber', 'reverse_reference', 'order_id');
  2732. case '_PrimaryKeyNode':
  2733. return new QQNode('id', 'Id', 'integer', $this);
  2734. default:
  2735. try {
  2736. return parent::__get($strName);
  2737. } catch (QCallerException $objExc) {
  2738. $objExc->IncrementOffset();
  2739. throw $objExc;
  2740. }
  2741. }
  2742. }
  2743. }
  2744. class QQReverseReferenceNodeOrder extends QQReverseReferenceNode {
  2745. protected $strTableName = 'order';
  2746. protected $strPrimaryKey = 'id';
  2747. protected $strClassName = 'Order';
  2748. public function __get($strName) {
  2749. switch ($strName) {
  2750. case 'Id':
  2751. return new QQNode('id', 'Id', 'integer', $this);
  2752. case 'AccountId':
  2753. return new QQNode('account_id', 'AccountId', 'integer', $this);
  2754. case 'Account':
  2755. return new QQNodeAccount('account_id', 'Account', 'integer', $this);
  2756. case 'CreationDate':
  2757. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  2758. case 'LastModification':
  2759. return new QQNode('last_modification', 'LastModification', 'string', $this);
  2760. case 'CompletionDate':
  2761. return new QQNode('completion_date', 'CompletionDate', 'QDateTime', $this);
  2762. case 'ProductTotalCost':
  2763. return new QQNode('product_total_cost', 'ProductTotalCost', 'double', $this);
  2764. case 'ShippingCost':
  2765. return new QQNode('shipping_cost', 'ShippingCost', 'double', $this);
  2766. case 'ShippingCharged':
  2767. return new QQNode('shipping_charged', 'ShippingCharged', 'double', $this);
  2768. case 'HandlingCost':
  2769. return new QQNode('handling_cost', 'HandlingCost', 'double', $this);
  2770. case 'HandlingCharged':
  2771. return new QQNode('handling_charged', 'HandlingCharged', 'double', $this);
  2772. case 'Tax':
  2773. return new QQNode('tax', 'Tax', 'double', $this);
  2774. case 'ProductTotalCharged':
  2775. return new QQNode('product_total_charged', 'ProductTotalCharged', 'double', $this);
  2776. case 'Notes':
  2777. return new QQNode('notes', 'Notes', 'string', $this);
  2778. case 'ShippingMethodId':
  2779. return new QQNode('shipping_method_id', 'ShippingMethodId', 'integer', $this);
  2780. case 'ShippingMethod':
  2781. return new QQNodeShippingMethod('shipping_method_id', 'ShippingMethod', 'integer', $this);
  2782. case 'PaymentMethodId':
  2783. return new QQNode('payment_method_id', 'PaymentMethodId', 'integer', $this);
  2784. case 'PaymentMethod':
  2785. return new QQNodePaymentMethod('payment_method_id', 'PaymentMethod', 'integer', $this);
  2786. case 'StatusId':
  2787. return new QQNode('status_id', 'StatusId', 'integer', $this);
  2788. case 'TypeId':
  2789. return new QQNode('type_id', 'TypeId', 'integer', $this);
  2790. case 'AuthorizeNetTransaction':
  2791. return new QQReverseReferenceNodeAuthorizeNetTransaction($this, 'authorizenettransaction', 'reverse_reference', 'order_id');
  2792. case 'OrderAddress':
  2793. return new QQReverseReferenceNodeOrderAddress($this, 'orderaddress', 'reverse_reference', 'order_id');
  2794. case 'OrderChange':
  2795. return new QQReverseReferenceNodeOrderChange($this, 'orderchange', 'reverse_reference', 'order_id');
  2796. case 'OrderItem':
  2797. return new QQReverseReferenceNodeOrderItem($this, 'orderitem', 'reverse_reference', 'order_id');
  2798. case 'OrderStatusHistory':
  2799. return new QQReverseReferenceNodeOrderStatusHistory($this, 'orderstatushistory', 'reverse_reference', 'order_id');
  2800. case 'PaypalTransaction':
  2801. return new QQReverseReferenceNodePaypalTransaction($this, 'paypaltransaction', 'reverse_reference', 'order_id');
  2802. case 'TrackingNumber':
  2803. return new QQReverseReferenceNodeTrackingNumber($this, 'trackingnumber', 'reverse_reference', 'order_id');
  2804. case '_PrimaryKeyNode':
  2805. return new QQNode('id', 'Id', 'integer', $this);
  2806. default:
  2807. try {
  2808. return parent::__get($strName);
  2809. } catch (QCallerException $objExc) {
  2810. $objExc->IncrementOffset();
  2811. throw $objExc;
  2812. }
  2813. }
  2814. }
  2815. }
  2816. ?>