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.

1638 lines
69 KiB

  1. <?php
  2. /**
  3. * The abstract OrderAddressGen 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 OrderAddress subclass which
  8. * extends this OrderAddressGen 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 OrderAddress class.
  15. *
  16. * @package Quinta CMS
  17. * @subpackage GeneratedDataObjects
  18. * @property-read integer $Id the value for intId (Read-Only PK)
  19. * @property integer $OrderId the value for intOrderId (Not Null)
  20. * @property string $NamePrefix the value for strNamePrefix
  21. * @property string $FirstName the value for strFirstName
  22. * @property string $MiddleName the value for strMiddleName
  23. * @property string $LastName the value for strLastName
  24. * @property string $NameSuffix the value for strNameSuffix
  25. * @property string $Company the value for strCompany
  26. * @property string $Street1 the value for strStreet1
  27. * @property string $Street2 the value for strStreet2
  28. * @property string $Suburb the value for strSuburb
  29. * @property string $City the value for strCity
  30. * @property string $County the value for strCounty
  31. * @property integer $ZoneId the value for intZoneId (Not Null)
  32. * @property integer $CountryId the value for intCountryId (Not Null)
  33. * @property string $PostalCode the value for strPostalCode
  34. * @property integer $TypeId the value for intTypeId (Not Null)
  35. * @property-read string $CreationDate the value for strCreationDate (Read-Only Timestamp)
  36. * @property-read string $LastModification the value for strLastModification (Read-Only Timestamp)
  37. * @property Order $Order the value for the Order object referenced by intOrderId (Not Null)
  38. * @property-read boolean $__Restored whether or not this object was restored from the database (as opposed to created new)
  39. */
  40. class OrderAddressGen extends QBaseClass
  41. {
  42. ///////////////////////////////////////////////////////////////////////
  43. // PROTECTED MEMBER VARIABLES and TEXT FIELD MAXLENGTHS (if applicable)
  44. ///////////////////////////////////////////////////////////////////////
  45. /////////// Object properties ////////////
  46. /**
  47. * Protected member variable that maps to the database PK Identity column order_address.id
  48. * @var integer intId
  49. *
  50. */
  51. protected $intId = null;
  52. /**
  53. * Protected member variable that maps to the database column order_address.order_id
  54. * @var integer intOrderId
  55. *
  56. */
  57. protected $intOrderId = null;
  58. /**
  59. * Protected member variable that maps to the database column order_address.name_prefix
  60. * @var string strNamePrefix
  61. *
  62. */
  63. protected $strNamePrefix = null;
  64. const NamePrefixMaxLength = 16;
  65. /**
  66. * Protected member variable that maps to the database column order_address.first_name
  67. * @var string strFirstName
  68. *
  69. */
  70. protected $strFirstName = null;
  71. const FirstNameMaxLength = 128;
  72. /**
  73. * Protected member variable that maps to the database column order_address.middle_name
  74. * @var string strMiddleName
  75. *
  76. */
  77. protected $strMiddleName = null;
  78. const MiddleNameMaxLength = 128;
  79. /**
  80. * Protected member variable that maps to the database column order_address.last_name
  81. * @var string strLastName
  82. *
  83. */
  84. protected $strLastName = null;
  85. const LastNameMaxLength = 128;
  86. /**
  87. * Protected member variable that maps to the database column order_address.name_suffix
  88. * @var string strNameSuffix
  89. *
  90. */
  91. protected $strNameSuffix = null;
  92. const NameSuffixMaxLength = 16;
  93. /**
  94. * Protected member variable that maps to the database column order_address.company
  95. * @var string strCompany
  96. *
  97. */
  98. protected $strCompany = null;
  99. const CompanyMaxLength = 128;
  100. /**
  101. * Protected member variable that maps to the database column order_address.street_1
  102. * @var string strStreet1
  103. *
  104. */
  105. protected $strStreet1 = null;
  106. const Street1MaxLength = 256;
  107. /**
  108. * Protected member variable that maps to the database column order_address.street_2
  109. * @var string strStreet2
  110. *
  111. */
  112. protected $strStreet2 = null;
  113. const Street2MaxLength = 256;
  114. /**
  115. * Protected member variable that maps to the database column order_address.suburb
  116. * @var string strSuburb
  117. *
  118. */
  119. protected $strSuburb = null;
  120. const SuburbMaxLength = 256;
  121. /**
  122. * Protected member variable that maps to the database column order_address.city
  123. * @var string strCity
  124. *
  125. */
  126. protected $strCity = null;
  127. const CityMaxLength = 256;
  128. /**
  129. * Protected member variable that maps to the database column order_address.county
  130. * @var string strCounty
  131. *
  132. */
  133. protected $strCounty = null;
  134. const CountyMaxLength = 256;
  135. /**
  136. * Protected member variable that maps to the database column order_address.zone_id
  137. * @var integer intZoneId
  138. *
  139. */
  140. protected $intZoneId = null;
  141. /**
  142. * Protected member variable that maps to the database column order_address.country_id
  143. * @var integer intCountryId
  144. *
  145. */
  146. protected $intCountryId = null;
  147. /**
  148. * Protected member variable that maps to the database column order_address.postal_code
  149. * @var string strPostalCode
  150. *
  151. */
  152. protected $strPostalCode = null;
  153. const PostalCodeMaxLength = 32;
  154. /**
  155. * Protected member variable that maps to the database column order_address.type_id
  156. * @var integer intTypeId
  157. *
  158. */
  159. protected $intTypeId = null;
  160. /**
  161. * Protected member variable that maps to the database column order_address.creation_date
  162. * @var string strCreationDate
  163. *
  164. */
  165. protected $strCreationDate = null;
  166. /**
  167. * Protected member variable that maps to the database column order_address.last_modification
  168. * @var string strLastModification
  169. *
  170. */
  171. protected $strLastModification = null;
  172. /**
  173. * Protected array of virtual attributes for this object (e.g. extra/other calculated and/or non-object bound
  174. * columns from the run-time database query result for this object). Used by InstantiateDbRow and
  175. * GetVirtualAttribute.
  176. * @var string[] $__strVirtualAttributeArray
  177. */
  178. protected $__strVirtualAttributeArray = array();
  179. /**
  180. * Protected internal member variable that specifies whether or not this object is Restored from the database.
  181. * Used by Save() to determine if Save() should perform a db UPDATE or INSERT.
  182. * @var bool __blnRestored;
  183. */
  184. protected $__blnRestored;
  185. ///////////////////////////////
  186. // PROTECTED MEMBER OBJECTS
  187. ///////////////////////////////
  188. /**
  189. * Protected member variable that contains the object pointed by the reference
  190. * in the database column order_address.order_id.
  191. *
  192. * NOTE: Always use the Order property getter to correctly retrieve this Order object.
  193. * (Because this class implements late binding, this variable reference MAY be null.)
  194. * @var Order objOrder
  195. */
  196. protected $objOrder;
  197. ///////////////////////////////
  198. // CLASS-WIDE LOAD AND COUNT METHODS
  199. ///////////////////////////////
  200. /**
  201. * Static method to retrieve the Database object that owns this class.
  202. * @return QDatabaseBase reference to the Database object that can query this class
  203. */
  204. public static function GetDatabase() {
  205. return QApplication::$Database[1];
  206. }
  207. /**
  208. * Load a OrderAddress from PK Info
  209. * @param integer $intId
  210. * @return OrderAddress
  211. */
  212. public static function Load($intId) {
  213. // Use QuerySingle to Perform the Query
  214. return OrderAddress::QuerySingle(
  215. QQ::Equal(QQN::OrderAddress()->Id, $intId)
  216. );
  217. }
  218. /**
  219. * Load all OrderAddresses
  220. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  221. * @return OrderAddress[]
  222. */
  223. public static function LoadAll($objOptionalClauses = null) {
  224. // Call OrderAddress::QueryArray to perform the LoadAll query
  225. try {
  226. return OrderAddress::QueryArray(QQ::All(), $objOptionalClauses);
  227. } catch (QCallerException $objExc) {
  228. $objExc->IncrementOffset();
  229. throw $objExc;
  230. }
  231. }
  232. /**
  233. * Count all OrderAddresses
  234. * @return int
  235. */
  236. public static function CountAll() {
  237. // Call OrderAddress::QueryCount to perform the CountAll query
  238. return OrderAddress::QueryCount(QQ::All());
  239. }
  240. ///////////////////////////////
  241. // QCODO QUERY-RELATED METHODS
  242. ///////////////////////////////
  243. /**
  244. * Internally called method to assist with calling Qcodo Query for this class
  245. * on load methods.
  246. * @param QQueryBuilder &$objQueryBuilder the QueryBuilder object that will be created
  247. * @param QQCondition $objConditions any conditions on the query, itself
  248. * @param QQClause[] $objOptionalClausees additional optional QQClause object or array of QQClause objects for this query
  249. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with (sending in null will skip the PrepareStatement step)
  250. * @param boolean $blnCountOnly only select a rowcount
  251. * @return string the query statement
  252. */
  253. protected static function BuildQueryStatement(&$objQueryBuilder, QQCondition $objConditions, $objOptionalClauses, $mixParameterArray, $blnCountOnly) {
  254. // Get the Database Object for this Class
  255. $objDatabase = OrderAddress::GetDatabase();
  256. // Create/Build out the QueryBuilder object with OrderAddress-specific SELET and FROM fields
  257. $objQueryBuilder = new QQueryBuilder($objDatabase, 'order_address');
  258. OrderAddress::GetSelectFields($objQueryBuilder);
  259. $objQueryBuilder->AddFromItem('order_address');
  260. // Set "CountOnly" option (if applicable)
  261. if ($blnCountOnly)
  262. $objQueryBuilder->SetCountOnlyFlag();
  263. // Apply Any Conditions
  264. if ($objConditions)
  265. try {
  266. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  267. } catch (QCallerException $objExc) {
  268. $objExc->IncrementOffset();
  269. throw $objExc;
  270. }
  271. // Iterate through all the Optional Clauses (if any) and perform accordingly
  272. if ($objOptionalClauses) {
  273. if ($objOptionalClauses instanceof QQClause)
  274. $objOptionalClauses->UpdateQueryBuilder($objQueryBuilder);
  275. else if (is_array($objOptionalClauses))
  276. foreach ($objOptionalClauses as $objClause)
  277. $objClause->UpdateQueryBuilder($objQueryBuilder);
  278. else
  279. throw new QCallerException('Optional Clauses must be a QQClause object or an array of QQClause objects');
  280. }
  281. // Get the SQL Statement
  282. $strQuery = $objQueryBuilder->GetStatement();
  283. // Prepare the Statement with the Query Parameters (if applicable)
  284. if ($mixParameterArray) {
  285. if (is_array($mixParameterArray)) {
  286. if (count($mixParameterArray))
  287. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  288. // Ensure that there are no other Unresolved Named Parameters
  289. if (strpos($strQuery, chr(QQNamedValue::DelimiterCode) . '{') !== false)
  290. throw new QCallerException('Unresolved named parameters in the query');
  291. } else
  292. throw new QCallerException('Parameter Array must be an array of name-value parameter pairs');
  293. }
  294. // Return the Objects
  295. return $strQuery;
  296. }
  297. /**
  298. * Static Qcodo Query method to query for a single OrderAddress object.
  299. * Uses BuildQueryStatment to perform most of the work.
  300. * @param QQCondition $objConditions any conditions on the query, itself
  301. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  302. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  303. * @return OrderAddress the queried object
  304. */
  305. public static function QuerySingle(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  306. // Get the Query Statement
  307. try {
  308. $strQuery = OrderAddress::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  309. } catch (QCallerException $objExc) {
  310. $objExc->IncrementOffset();
  311. throw $objExc;
  312. }
  313. // Perform the Query, Get the First Row, and Instantiate a new OrderAddress object
  314. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  315. return OrderAddress::InstantiateDbRow($objDbResult->GetNextRow(), null, null, null, $objQueryBuilder->ColumnAliasArray);
  316. }
  317. /**
  318. * Static Qcodo Query method to query for an array of OrderAddress objects.
  319. * Uses BuildQueryStatment to perform most of the work.
  320. * @param QQCondition $objConditions any conditions on the query, itself
  321. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  322. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  323. * @return OrderAddress[] the queried objects as an array
  324. */
  325. public static function QueryArray(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  326. // Get the Query Statement
  327. try {
  328. $strQuery = OrderAddress::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, false);
  329. } catch (QCallerException $objExc) {
  330. $objExc->IncrementOffset();
  331. throw $objExc;
  332. }
  333. // Perform the Query and Instantiate the Array Result
  334. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  335. return OrderAddress::InstantiateDbResult($objDbResult, $objQueryBuilder->ExpandAsArrayNodes, $objQueryBuilder->ColumnAliasArray);
  336. }
  337. /**
  338. * Static Qcodo Query method to query for a count of OrderAddress objects.
  339. * Uses BuildQueryStatment to perform most of the work.
  340. * @param QQCondition $objConditions any conditions on the query, itself
  341. * @param QQClause[] $objOptionalClausees additional optional QQClause objects for this query
  342. * @param mixed[] $mixParameterArray a array of name-value pairs to perform PrepareStatement with
  343. * @return integer the count of queried objects as an integer
  344. */
  345. public static function QueryCount(QQCondition $objConditions, $objOptionalClauses = null, $mixParameterArray = null) {
  346. // Get the Query Statement
  347. try {
  348. $strQuery = OrderAddress::BuildQueryStatement($objQueryBuilder, $objConditions, $objOptionalClauses, $mixParameterArray, true);
  349. } catch (QCallerException $objExc) {
  350. $objExc->IncrementOffset();
  351. throw $objExc;
  352. }
  353. // Perform the Query and return the row_count
  354. $objDbResult = $objQueryBuilder->Database->Query($strQuery);
  355. // Figure out if the query is using GroupBy
  356. $blnGrouped = false;
  357. if ($objOptionalClauses) foreach ($objOptionalClauses as $objClause) {
  358. if ($objClause instanceof QQGroupBy) {
  359. $blnGrouped = true;
  360. break;
  361. }
  362. }
  363. if ($blnGrouped)
  364. // Groups in this query - return the count of Groups (which is the count of all rows)
  365. return $objDbResult->CountRows();
  366. else {
  367. // No Groups - return the sql-calculated count(*) value
  368. $strDbRow = $objDbResult->FetchRow();
  369. return QType::Cast($strDbRow[0], QType::Integer);
  370. }
  371. }
  372. /* public static function QueryArrayCached($strConditions, $mixParameterArray = null) {
  373. // Get the Database Object for this Class
  374. $objDatabase = OrderAddress::GetDatabase();
  375. // Lookup the QCache for This Query Statement
  376. $objCache = new QCache('query', 'order_address_' . serialize($strConditions));
  377. if (!($strQuery = $objCache->GetData())) {
  378. // Not Found -- Go ahead and Create/Build out a new QueryBuilder object with OrderAddress-specific fields
  379. $objQueryBuilder = new QQueryBuilder($objDatabase);
  380. OrderAddress::GetSelectFields($objQueryBuilder);
  381. OrderAddress::GetFromFields($objQueryBuilder);
  382. // Ensure the Passed-in Conditions is a string
  383. try {
  384. $strConditions = QType::Cast($strConditions, QType::String);
  385. } catch (QCallerException $objExc) {
  386. $objExc->IncrementOffset();
  387. throw $objExc;
  388. }
  389. // Create the Conditions object, and apply it
  390. $objConditions = eval('return ' . $strConditions . ';');
  391. // Apply Any Conditions
  392. if ($objConditions)
  393. $objConditions->UpdateQueryBuilder($objQueryBuilder);
  394. // Get the SQL Statement
  395. $strQuery = $objQueryBuilder->GetStatement();
  396. // Save the SQL Statement in the Cache
  397. $objCache->SaveData($strQuery);
  398. }
  399. // Prepare the Statement with the Parameters
  400. if ($mixParameterArray)
  401. $strQuery = $objDatabase->PrepareStatement($strQuery, $mixParameterArray);
  402. // Perform the Query and Instantiate the Array Result
  403. $objDbResult = $objDatabase->Query($strQuery);
  404. return OrderAddress::InstantiateDbResult($objDbResult);
  405. }*/
  406. /**
  407. * Updates a QQueryBuilder with the SELECT fields for this OrderAddress
  408. * @param QQueryBuilder $objBuilder the Query Builder object to update
  409. * @param string $strPrefix optional prefix to add to the SELECT fields
  410. */
  411. public static function GetSelectFields(QQueryBuilder $objBuilder, $strPrefix = null) {
  412. if ($strPrefix) {
  413. $strTableName = $strPrefix;
  414. $strAliasPrefix = $strPrefix . '__';
  415. } else {
  416. $strTableName = 'order_address';
  417. $strAliasPrefix = '';
  418. }
  419. $objBuilder->AddSelectItem($strTableName, 'id', $strAliasPrefix . 'id');
  420. $objBuilder->AddSelectItem($strTableName, 'order_id', $strAliasPrefix . 'order_id');
  421. $objBuilder->AddSelectItem($strTableName, 'name_prefix', $strAliasPrefix . 'name_prefix');
  422. $objBuilder->AddSelectItem($strTableName, 'first_name', $strAliasPrefix . 'first_name');
  423. $objBuilder->AddSelectItem($strTableName, 'middle_name', $strAliasPrefix . 'middle_name');
  424. $objBuilder->AddSelectItem($strTableName, 'last_name', $strAliasPrefix . 'last_name');
  425. $objBuilder->AddSelectItem($strTableName, 'name_suffix', $strAliasPrefix . 'name_suffix');
  426. $objBuilder->AddSelectItem($strTableName, 'company', $strAliasPrefix . 'company');
  427. $objBuilder->AddSelectItem($strTableName, 'street_1', $strAliasPrefix . 'street_1');
  428. $objBuilder->AddSelectItem($strTableName, 'street_2', $strAliasPrefix . 'street_2');
  429. $objBuilder->AddSelectItem($strTableName, 'suburb', $strAliasPrefix . 'suburb');
  430. $objBuilder->AddSelectItem($strTableName, 'city', $strAliasPrefix . 'city');
  431. $objBuilder->AddSelectItem($strTableName, 'county', $strAliasPrefix . 'county');
  432. $objBuilder->AddSelectItem($strTableName, 'zone_id', $strAliasPrefix . 'zone_id');
  433. $objBuilder->AddSelectItem($strTableName, 'country_id', $strAliasPrefix . 'country_id');
  434. $objBuilder->AddSelectItem($strTableName, 'postal_code', $strAliasPrefix . 'postal_code');
  435. $objBuilder->AddSelectItem($strTableName, 'type_id', $strAliasPrefix . 'type_id');
  436. $objBuilder->AddSelectItem($strTableName, 'creation_date', $strAliasPrefix . 'creation_date');
  437. $objBuilder->AddSelectItem($strTableName, 'last_modification', $strAliasPrefix . 'last_modification');
  438. }
  439. ///////////////////////////////
  440. // INSTANTIATION-RELATED METHODS
  441. ///////////////////////////////
  442. /**
  443. * Instantiate a OrderAddress from a Database Row.
  444. * Takes in an optional strAliasPrefix, used in case another Object::InstantiateDbRow
  445. * is calling this OrderAddress::InstantiateDbRow in order to perform
  446. * early binding on referenced objects.
  447. * @param DatabaseRowBase $objDbRow
  448. * @param string $strAliasPrefix
  449. * @param string $strExpandAsArrayNodes
  450. * @param QBaseClass $objPreviousItem
  451. * @param string[] $strColumnAliasArray
  452. * @return OrderAddress
  453. */
  454. public static function InstantiateDbRow($objDbRow, $strAliasPrefix = null, $strExpandAsArrayNodes = null, $objPreviousItem = null, $strColumnAliasArray = array()) {
  455. // If blank row, return null
  456. if (!$objDbRow)
  457. return null;
  458. // Create a new instance of the OrderAddress object
  459. $objToReturn = new OrderAddress();
  460. $objToReturn->__blnRestored = true;
  461. $strAliasName = array_key_exists($strAliasPrefix . 'id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'id'] : $strAliasPrefix . 'id';
  462. $objToReturn->intId = $objDbRow->GetColumn($strAliasName, 'Integer');
  463. $strAliasName = array_key_exists($strAliasPrefix . 'order_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'order_id'] : $strAliasPrefix . 'order_id';
  464. $objToReturn->intOrderId = $objDbRow->GetColumn($strAliasName, 'Integer');
  465. $strAliasName = array_key_exists($strAliasPrefix . 'name_prefix', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'name_prefix'] : $strAliasPrefix . 'name_prefix';
  466. $objToReturn->strNamePrefix = $objDbRow->GetColumn($strAliasName, 'VarChar');
  467. $strAliasName = array_key_exists($strAliasPrefix . 'first_name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'first_name'] : $strAliasPrefix . 'first_name';
  468. $objToReturn->strFirstName = $objDbRow->GetColumn($strAliasName, 'VarChar');
  469. $strAliasName = array_key_exists($strAliasPrefix . 'middle_name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'middle_name'] : $strAliasPrefix . 'middle_name';
  470. $objToReturn->strMiddleName = $objDbRow->GetColumn($strAliasName, 'VarChar');
  471. $strAliasName = array_key_exists($strAliasPrefix . 'last_name', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'last_name'] : $strAliasPrefix . 'last_name';
  472. $objToReturn->strLastName = $objDbRow->GetColumn($strAliasName, 'VarChar');
  473. $strAliasName = array_key_exists($strAliasPrefix . 'name_suffix', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'name_suffix'] : $strAliasPrefix . 'name_suffix';
  474. $objToReturn->strNameSuffix = $objDbRow->GetColumn($strAliasName, 'VarChar');
  475. $strAliasName = array_key_exists($strAliasPrefix . 'company', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'company'] : $strAliasPrefix . 'company';
  476. $objToReturn->strCompany = $objDbRow->GetColumn($strAliasName, 'VarChar');
  477. $strAliasName = array_key_exists($strAliasPrefix . 'street_1', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'street_1'] : $strAliasPrefix . 'street_1';
  478. $objToReturn->strStreet1 = $objDbRow->GetColumn($strAliasName, 'VarChar');
  479. $strAliasName = array_key_exists($strAliasPrefix . 'street_2', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'street_2'] : $strAliasPrefix . 'street_2';
  480. $objToReturn->strStreet2 = $objDbRow->GetColumn($strAliasName, 'VarChar');
  481. $strAliasName = array_key_exists($strAliasPrefix . 'suburb', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'suburb'] : $strAliasPrefix . 'suburb';
  482. $objToReturn->strSuburb = $objDbRow->GetColumn($strAliasName, 'VarChar');
  483. $strAliasName = array_key_exists($strAliasPrefix . 'city', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'city'] : $strAliasPrefix . 'city';
  484. $objToReturn->strCity = $objDbRow->GetColumn($strAliasName, 'VarChar');
  485. $strAliasName = array_key_exists($strAliasPrefix . 'county', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'county'] : $strAliasPrefix . 'county';
  486. $objToReturn->strCounty = $objDbRow->GetColumn($strAliasName, 'VarChar');
  487. $strAliasName = array_key_exists($strAliasPrefix . 'zone_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'zone_id'] : $strAliasPrefix . 'zone_id';
  488. $objToReturn->intZoneId = $objDbRow->GetColumn($strAliasName, 'Integer');
  489. $strAliasName = array_key_exists($strAliasPrefix . 'country_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'country_id'] : $strAliasPrefix . 'country_id';
  490. $objToReturn->intCountryId = $objDbRow->GetColumn($strAliasName, 'Integer');
  491. $strAliasName = array_key_exists($strAliasPrefix . 'postal_code', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'postal_code'] : $strAliasPrefix . 'postal_code';
  492. $objToReturn->strPostalCode = $objDbRow->GetColumn($strAliasName, 'VarChar');
  493. $strAliasName = array_key_exists($strAliasPrefix . 'type_id', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'type_id'] : $strAliasPrefix . 'type_id';
  494. $objToReturn->intTypeId = $objDbRow->GetColumn($strAliasName, 'Integer');
  495. $strAliasName = array_key_exists($strAliasPrefix . 'creation_date', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'creation_date'] : $strAliasPrefix . 'creation_date';
  496. $objToReturn->strCreationDate = $objDbRow->GetColumn($strAliasName, 'VarChar');
  497. $strAliasName = array_key_exists($strAliasPrefix . 'last_modification', $strColumnAliasArray) ? $strColumnAliasArray[$strAliasPrefix . 'last_modification'] : $strAliasPrefix . 'last_modification';
  498. $objToReturn->strLastModification = $objDbRow->GetColumn($strAliasName, 'VarChar');
  499. // Instantiate Virtual Attributes
  500. foreach ($objDbRow->GetColumnNameArray() as $strColumnName => $mixValue) {
  501. $strVirtualPrefix = $strAliasPrefix . '__';
  502. $strVirtualPrefixLength = strlen($strVirtualPrefix);
  503. if (substr($strColumnName, 0, $strVirtualPrefixLength) == $strVirtualPrefix)
  504. $objToReturn->__strVirtualAttributeArray[substr($strColumnName, $strVirtualPrefixLength)] = $mixValue;
  505. }
  506. // Prepare to Check for Early/Virtual Binding
  507. if (!$strAliasPrefix)
  508. $strAliasPrefix = 'order_address__';
  509. // Check for Order Early Binding
  510. $strAlias = $strAliasPrefix . 'order_id__id';
  511. $strAliasName = array_key_exists($strAlias, $strColumnAliasArray) ? $strColumnAliasArray[$strAlias] : $strAlias;
  512. if (!is_null($objDbRow->GetColumn($strAliasName)))
  513. $objToReturn->objOrder = Order::InstantiateDbRow($objDbRow, $strAliasPrefix . 'order_id__', $strExpandAsArrayNodes, null, $strColumnAliasArray);
  514. return $objToReturn;
  515. }
  516. /**
  517. * Instantiate an array of OrderAddresses from a Database Result
  518. * @param DatabaseResultBase $objDbResult
  519. * @param string $strExpandAsArrayNodes
  520. * @param string[] $strColumnAliasArray
  521. * @return OrderAddress[]
  522. */
  523. public static function InstantiateDbResult(QDatabaseResultBase $objDbResult, $strExpandAsArrayNodes = null, $strColumnAliasArray = null) {
  524. $objToReturn = array();
  525. if (!$strColumnAliasArray)
  526. $strColumnAliasArray = array();
  527. // If blank resultset, then return empty array
  528. if (!$objDbResult)
  529. return $objToReturn;
  530. // Load up the return array with each row
  531. if ($strExpandAsArrayNodes) {
  532. $objLastRowItem = null;
  533. while ($objDbRow = $objDbResult->GetNextRow()) {
  534. $objItem = OrderAddress::InstantiateDbRow($objDbRow, null, $strExpandAsArrayNodes, $objLastRowItem, $strColumnAliasArray);
  535. if ($objItem) {
  536. $objToReturn[] = $objItem;
  537. $objLastRowItem = $objItem;
  538. }
  539. }
  540. } else {
  541. while ($objDbRow = $objDbResult->GetNextRow())
  542. $objToReturn[] = OrderAddress::InstantiateDbRow($objDbRow, null, null, null, $strColumnAliasArray);
  543. }
  544. return $objToReturn;
  545. }
  546. ///////////////////////////////////////////////////
  547. // INDEX-BASED LOAD METHODS (Single Load and Array)
  548. ///////////////////////////////////////////////////
  549. /**
  550. * Load a single OrderAddress object,
  551. * by Id Index(es)
  552. * @param integer $intId
  553. * @return OrderAddress
  554. */
  555. public static function LoadById($intId) {
  556. return OrderAddress::QuerySingle(
  557. QQ::Equal(QQN::OrderAddress()->Id, $intId)
  558. );
  559. }
  560. /**
  561. * Load an array of OrderAddress objects,
  562. * by TypeId Index(es)
  563. * @param integer $intTypeId
  564. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  565. * @return OrderAddress[]
  566. */
  567. public static function LoadArrayByTypeId($intTypeId, $objOptionalClauses = null) {
  568. // Call OrderAddress::QueryArray to perform the LoadArrayByTypeId query
  569. try {
  570. return OrderAddress::QueryArray(
  571. QQ::Equal(QQN::OrderAddress()->TypeId, $intTypeId),
  572. $objOptionalClauses);
  573. } catch (QCallerException $objExc) {
  574. $objExc->IncrementOffset();
  575. throw $objExc;
  576. }
  577. }
  578. /**
  579. * Count OrderAddresses
  580. * by TypeId Index(es)
  581. * @param integer $intTypeId
  582. * @return int
  583. */
  584. public static function CountByTypeId($intTypeId) {
  585. // Call OrderAddress::QueryCount to perform the CountByTypeId query
  586. return OrderAddress::QueryCount(
  587. QQ::Equal(QQN::OrderAddress()->TypeId, $intTypeId)
  588. );
  589. }
  590. /**
  591. * Load an array of OrderAddress objects,
  592. * by ZoneId Index(es)
  593. * @param integer $intZoneId
  594. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  595. * @return OrderAddress[]
  596. */
  597. public static function LoadArrayByZoneId($intZoneId, $objOptionalClauses = null) {
  598. // Call OrderAddress::QueryArray to perform the LoadArrayByZoneId query
  599. try {
  600. return OrderAddress::QueryArray(
  601. QQ::Equal(QQN::OrderAddress()->ZoneId, $intZoneId),
  602. $objOptionalClauses);
  603. } catch (QCallerException $objExc) {
  604. $objExc->IncrementOffset();
  605. throw $objExc;
  606. }
  607. }
  608. /**
  609. * Count OrderAddresses
  610. * by ZoneId Index(es)
  611. * @param integer $intZoneId
  612. * @return int
  613. */
  614. public static function CountByZoneId($intZoneId) {
  615. // Call OrderAddress::QueryCount to perform the CountByZoneId query
  616. return OrderAddress::QueryCount(
  617. QQ::Equal(QQN::OrderAddress()->ZoneId, $intZoneId)
  618. );
  619. }
  620. /**
  621. * Load an array of OrderAddress objects,
  622. * by CountryId Index(es)
  623. * @param integer $intCountryId
  624. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  625. * @return OrderAddress[]
  626. */
  627. public static function LoadArrayByCountryId($intCountryId, $objOptionalClauses = null) {
  628. // Call OrderAddress::QueryArray to perform the LoadArrayByCountryId query
  629. try {
  630. return OrderAddress::QueryArray(
  631. QQ::Equal(QQN::OrderAddress()->CountryId, $intCountryId),
  632. $objOptionalClauses);
  633. } catch (QCallerException $objExc) {
  634. $objExc->IncrementOffset();
  635. throw $objExc;
  636. }
  637. }
  638. /**
  639. * Count OrderAddresses
  640. * by CountryId Index(es)
  641. * @param integer $intCountryId
  642. * @return int
  643. */
  644. public static function CountByCountryId($intCountryId) {
  645. // Call OrderAddress::QueryCount to perform the CountByCountryId query
  646. return OrderAddress::QueryCount(
  647. QQ::Equal(QQN::OrderAddress()->CountryId, $intCountryId)
  648. );
  649. }
  650. /**
  651. * Load an array of OrderAddress objects,
  652. * by OrderId Index(es)
  653. * @param integer $intOrderId
  654. * @param QQClause[] $objOptionalClauses additional optional QQClause objects for this query
  655. * @return OrderAddress[]
  656. */
  657. public static function LoadArrayByOrderId($intOrderId, $objOptionalClauses = null) {
  658. // Call OrderAddress::QueryArray to perform the LoadArrayByOrderId query
  659. try {
  660. return OrderAddress::QueryArray(
  661. QQ::Equal(QQN::OrderAddress()->OrderId, $intOrderId),
  662. $objOptionalClauses);
  663. } catch (QCallerException $objExc) {
  664. $objExc->IncrementOffset();
  665. throw $objExc;
  666. }
  667. }
  668. /**
  669. * Count OrderAddresses
  670. * by OrderId Index(es)
  671. * @param integer $intOrderId
  672. * @return int
  673. */
  674. public static function CountByOrderId($intOrderId) {
  675. // Call OrderAddress::QueryCount to perform the CountByOrderId query
  676. return OrderAddress::QueryCount(
  677. QQ::Equal(QQN::OrderAddress()->OrderId, $intOrderId)
  678. );
  679. }
  680. ////////////////////////////////////////////////////
  681. // INDEX-BASED LOAD METHODS (Array via Many to Many)
  682. ////////////////////////////////////////////////////
  683. //////////////////////////
  684. // SAVE, DELETE AND RELOAD
  685. //////////////////////////
  686. /**
  687. * Save this OrderAddress
  688. * @param bool $blnForceInsert
  689. * @param bool $blnForceUpdate
  690. * @return int
  691. */
  692. public function Save($blnForceInsert = false, $blnForceUpdate = false) {
  693. // Get the Database Object for this Class
  694. $objDatabase = OrderAddress::GetDatabase();
  695. $mixToReturn = null;
  696. try {
  697. if ((!$this->__blnRestored) || ($blnForceInsert)) {
  698. // Perform an INSERT query
  699. $objDatabase->NonQuery('
  700. INSERT INTO `order_address` (
  701. `order_id`,
  702. `name_prefix`,
  703. `first_name`,
  704. `middle_name`,
  705. `last_name`,
  706. `name_suffix`,
  707. `company`,
  708. `street_1`,
  709. `street_2`,
  710. `suburb`,
  711. `city`,
  712. `county`,
  713. `zone_id`,
  714. `country_id`,
  715. `postal_code`,
  716. `type_id`
  717. ) VALUES (
  718. ' . $objDatabase->SqlVariable($this->intOrderId) . ',
  719. ' . $objDatabase->SqlVariable($this->strNamePrefix) . ',
  720. ' . $objDatabase->SqlVariable($this->strFirstName) . ',
  721. ' . $objDatabase->SqlVariable($this->strMiddleName) . ',
  722. ' . $objDatabase->SqlVariable($this->strLastName) . ',
  723. ' . $objDatabase->SqlVariable($this->strNameSuffix) . ',
  724. ' . $objDatabase->SqlVariable($this->strCompany) . ',
  725. ' . $objDatabase->SqlVariable($this->strStreet1) . ',
  726. ' . $objDatabase->SqlVariable($this->strStreet2) . ',
  727. ' . $objDatabase->SqlVariable($this->strSuburb) . ',
  728. ' . $objDatabase->SqlVariable($this->strCity) . ',
  729. ' . $objDatabase->SqlVariable($this->strCounty) . ',
  730. ' . $objDatabase->SqlVariable($this->intZoneId) . ',
  731. ' . $objDatabase->SqlVariable($this->intCountryId) . ',
  732. ' . $objDatabase->SqlVariable($this->strPostalCode) . ',
  733. ' . $objDatabase->SqlVariable($this->intTypeId) . '
  734. )
  735. ');
  736. // Update Identity column and return its value
  737. $mixToReturn = $this->intId = $objDatabase->InsertId('order_address', 'id');
  738. } else {
  739. // Perform an UPDATE query
  740. // First checking for Optimistic Locking constraints (if applicable)
  741. if (!$blnForceUpdate) {
  742. // Perform the Optimistic Locking check
  743. $objResult = $objDatabase->Query('
  744. SELECT
  745. `creation_date`
  746. FROM
  747. `order_address`
  748. WHERE
  749. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  750. ');
  751. $objRow = $objResult->FetchArray();
  752. if ($objRow[0] != $this->strCreationDate)
  753. throw new QOptimisticLockingException('OrderAddress');
  754. }
  755. if (!$blnForceUpdate) {
  756. // Perform the Optimistic Locking check
  757. $objResult = $objDatabase->Query('
  758. SELECT
  759. `last_modification`
  760. FROM
  761. `order_address`
  762. WHERE
  763. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  764. ');
  765. $objRow = $objResult->FetchArray();
  766. if ($objRow[0] != $this->strLastModification)
  767. throw new QOptimisticLockingException('OrderAddress');
  768. }
  769. // Perform the UPDATE query
  770. $objDatabase->NonQuery('
  771. UPDATE
  772. `order_address`
  773. SET
  774. `order_id` = ' . $objDatabase->SqlVariable($this->intOrderId) . ',
  775. `name_prefix` = ' . $objDatabase->SqlVariable($this->strNamePrefix) . ',
  776. `first_name` = ' . $objDatabase->SqlVariable($this->strFirstName) . ',
  777. `middle_name` = ' . $objDatabase->SqlVariable($this->strMiddleName) . ',
  778. `last_name` = ' . $objDatabase->SqlVariable($this->strLastName) . ',
  779. `name_suffix` = ' . $objDatabase->SqlVariable($this->strNameSuffix) . ',
  780. `company` = ' . $objDatabase->SqlVariable($this->strCompany) . ',
  781. `street_1` = ' . $objDatabase->SqlVariable($this->strStreet1) . ',
  782. `street_2` = ' . $objDatabase->SqlVariable($this->strStreet2) . ',
  783. `suburb` = ' . $objDatabase->SqlVariable($this->strSuburb) . ',
  784. `city` = ' . $objDatabase->SqlVariable($this->strCity) . ',
  785. `county` = ' . $objDatabase->SqlVariable($this->strCounty) . ',
  786. `zone_id` = ' . $objDatabase->SqlVariable($this->intZoneId) . ',
  787. `country_id` = ' . $objDatabase->SqlVariable($this->intCountryId) . ',
  788. `postal_code` = ' . $objDatabase->SqlVariable($this->strPostalCode) . ',
  789. `type_id` = ' . $objDatabase->SqlVariable($this->intTypeId) . '
  790. WHERE
  791. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  792. ');
  793. }
  794. } catch (QCallerException $objExc) {
  795. $objExc->IncrementOffset();
  796. throw $objExc;
  797. }
  798. // Update __blnRestored and any Non-Identity PK Columns (if applicable)
  799. $this->__blnRestored = true;
  800. // Update Local Timestamp
  801. $objResult = $objDatabase->Query('
  802. SELECT
  803. `creation_date`
  804. FROM
  805. `order_address`
  806. WHERE
  807. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  808. ');
  809. $objRow = $objResult->FetchArray();
  810. $this->strCreationDate = $objRow[0];
  811. // Update Local Timestamp
  812. $objResult = $objDatabase->Query('
  813. SELECT
  814. `last_modification`
  815. FROM
  816. `order_address`
  817. WHERE
  818. `id` = ' . $objDatabase->SqlVariable($this->intId) . '
  819. ');
  820. $objRow = $objResult->FetchArray();
  821. $this->strLastModification = $objRow[0];
  822. // Return
  823. return $mixToReturn;
  824. }
  825. /**
  826. * Delete this OrderAddress
  827. * @return void
  828. */
  829. public function Delete() {
  830. if ((is_null($this->intId)))
  831. throw new QUndefinedPrimaryKeyException('Cannot delete this OrderAddress with an unset primary key.');
  832. // Get the Database Object for this Class
  833. $objDatabase = OrderAddress::GetDatabase();
  834. // Perform the SQL Query
  835. $objDatabase->NonQuery('
  836. DELETE FROM
  837. `order_address`
  838. WHERE
  839. `id` = ' . $objDatabase->SqlVariable($this->intId) . '');
  840. }
  841. /**
  842. * Delete all OrderAddresses
  843. * @return void
  844. */
  845. public static function DeleteAll() {
  846. // Get the Database Object for this Class
  847. $objDatabase = OrderAddress::GetDatabase();
  848. // Perform the Query
  849. $objDatabase->NonQuery('
  850. DELETE FROM
  851. `order_address`');
  852. }
  853. /**
  854. * Truncate order_address table
  855. * @return void
  856. */
  857. public static function Truncate() {
  858. // Get the Database Object for this Class
  859. $objDatabase = OrderAddress::GetDatabase();
  860. // Perform the Query
  861. $objDatabase->NonQuery('
  862. TRUNCATE `order_address`');
  863. }
  864. /**
  865. * Reload this OrderAddress from the database.
  866. * @return void
  867. */
  868. public function Reload() {
  869. // Make sure we are actually Restored from the database
  870. if (!$this->__blnRestored)
  871. throw new QCallerException('Cannot call Reload() on a new, unsaved OrderAddress object.');
  872. // Reload the Object
  873. $objReloaded = OrderAddress::Load($this->intId);
  874. // Update $this's local variables to match
  875. $this->OrderId = $objReloaded->OrderId;
  876. $this->strNamePrefix = $objReloaded->strNamePrefix;
  877. $this->strFirstName = $objReloaded->strFirstName;
  878. $this->strMiddleName = $objReloaded->strMiddleName;
  879. $this->strLastName = $objReloaded->strLastName;
  880. $this->strNameSuffix = $objReloaded->strNameSuffix;
  881. $this->strCompany = $objReloaded->strCompany;
  882. $this->strStreet1 = $objReloaded->strStreet1;
  883. $this->strStreet2 = $objReloaded->strStreet2;
  884. $this->strSuburb = $objReloaded->strSuburb;
  885. $this->strCity = $objReloaded->strCity;
  886. $this->strCounty = $objReloaded->strCounty;
  887. $this->ZoneId = $objReloaded->ZoneId;
  888. $this->CountryId = $objReloaded->CountryId;
  889. $this->strPostalCode = $objReloaded->strPostalCode;
  890. $this->TypeId = $objReloaded->TypeId;
  891. $this->strCreationDate = $objReloaded->strCreationDate;
  892. $this->strLastModification = $objReloaded->strLastModification;
  893. }
  894. ////////////////////
  895. // GETTORS AND SETTORS
  896. ////////////////////
  897. /**
  898. * Lookup a VirtualAttribute value (if applicable). Returns NULL if none found.
  899. * @param string $strName
  900. * @return string
  901. */
  902. public function GetVirtualAttribute($strName)
  903. {
  904. if (array_key_exists($strName, $this->__strVirtualAttributeArray))
  905. return $this->__strVirtualAttributeArray[$strName];
  906. return null;
  907. }
  908. /**
  909. * Override method to perform a property "Get"
  910. * This will get the value of $strName
  911. *
  912. * @param string $strName Name of the property to get
  913. * @return mixed
  914. */
  915. public function __get($strName)
  916. {
  917. switch ($strName)
  918. {
  919. ///////////////////
  920. // Member Variables
  921. ///////////////////
  922. case 'Id':
  923. /**
  924. * Gets the value for intId (Read-Only PK)
  925. * @return integer
  926. */
  927. return $this->intId;
  928. case 'OrderId':
  929. /**
  930. * Gets the value for intOrderId (Not Null)
  931. * @return integer
  932. */
  933. return $this->intOrderId;
  934. case 'NamePrefix':
  935. /**
  936. * Gets the value for strNamePrefix
  937. * @return string
  938. */
  939. return $this->strNamePrefix;
  940. case 'FirstName':
  941. /**
  942. * Gets the value for strFirstName
  943. * @return string
  944. */
  945. return $this->strFirstName;
  946. case 'MiddleName':
  947. /**
  948. * Gets the value for strMiddleName
  949. * @return string
  950. */
  951. return $this->strMiddleName;
  952. case 'LastName':
  953. /**
  954. * Gets the value for strLastName
  955. * @return string
  956. */
  957. return $this->strLastName;
  958. case 'NameSuffix':
  959. /**
  960. * Gets the value for strNameSuffix
  961. * @return string
  962. */
  963. return $this->strNameSuffix;
  964. case 'Company':
  965. /**
  966. * Gets the value for strCompany
  967. * @return string
  968. */
  969. return $this->strCompany;
  970. case 'Street1':
  971. /**
  972. * Gets the value for strStreet1
  973. * @return string
  974. */
  975. return $this->strStreet1;
  976. case 'Street2':
  977. /**
  978. * Gets the value for strStreet2
  979. * @return string
  980. */
  981. return $this->strStreet2;
  982. case 'Suburb':
  983. /**
  984. * Gets the value for strSuburb
  985. * @return string
  986. */
  987. return $this->strSuburb;
  988. case 'City':
  989. /**
  990. * Gets the value for strCity
  991. * @return string
  992. */
  993. return $this->strCity;
  994. case 'County':
  995. /**
  996. * Gets the value for strCounty
  997. * @return string
  998. */
  999. return $this->strCounty;
  1000. case 'ZoneId':
  1001. /**
  1002. * Gets the value for intZoneId (Not Null)
  1003. * @return integer
  1004. */
  1005. return $this->intZoneId;
  1006. case 'CountryId':
  1007. /**
  1008. * Gets the value for intCountryId (Not Null)
  1009. * @return integer
  1010. */
  1011. return $this->intCountryId;
  1012. case 'PostalCode':
  1013. /**
  1014. * Gets the value for strPostalCode
  1015. * @return string
  1016. */
  1017. return $this->strPostalCode;
  1018. case 'TypeId':
  1019. /**
  1020. * Gets the value for intTypeId (Not Null)
  1021. * @return integer
  1022. */
  1023. return $this->intTypeId;
  1024. case 'CreationDate':
  1025. /**
  1026. * Gets the value for strCreationDate (Read-Only Timestamp)
  1027. * @return string
  1028. */
  1029. return $this->strCreationDate;
  1030. case 'LastModification':
  1031. /**
  1032. * Gets the value for strLastModification (Read-Only Timestamp)
  1033. * @return string
  1034. */
  1035. return $this->strLastModification;
  1036. ///////////////////
  1037. // Member Objects
  1038. ///////////////////
  1039. case 'Order':
  1040. /**
  1041. * Gets the value for the Order object referenced by intOrderId (Not Null)
  1042. * @return Order
  1043. */
  1044. try {
  1045. if ((!$this->objOrder) && (!is_null($this->intOrderId)))
  1046. $this->objOrder = Order::Load($this->intOrderId);
  1047. return $this->objOrder;
  1048. } catch (QCallerException $objExc) {
  1049. $objExc->IncrementOffset();
  1050. throw $objExc;
  1051. }
  1052. ////////////////////////////
  1053. // Virtual Object References (Many to Many and Reverse References)
  1054. // (If restored via a "Many-to" expansion)
  1055. ////////////////////////////
  1056. case '__Restored':
  1057. return $this->__blnRestored;
  1058. default:
  1059. try {
  1060. return parent::__get($strName);
  1061. } catch (QCallerException $objExc) {
  1062. $objExc->IncrementOffset();
  1063. throw $objExc;
  1064. }
  1065. }
  1066. }
  1067. /**
  1068. * Override method to perform a property "Set"
  1069. * This will set the property $strName to be $mixValue
  1070. *
  1071. * @param string $strName Name of the property to set
  1072. * @param string $mixValue New value of the property
  1073. * @return mixed
  1074. */
  1075. public function __set($strName, $mixValue) {
  1076. switch ($strName) {
  1077. ///////////////////
  1078. // Member Variables
  1079. ///////////////////
  1080. case 'OrderId':
  1081. /**
  1082. * Sets the value for intOrderId (Not Null)
  1083. * @param integer $mixValue
  1084. * @return integer
  1085. */
  1086. try {
  1087. $this->objOrder = null;
  1088. return ($this->intOrderId = QType::Cast($mixValue, QType::Integer));
  1089. } catch (QCallerException $objExc) {
  1090. $objExc->IncrementOffset();
  1091. throw $objExc;
  1092. }
  1093. case 'NamePrefix':
  1094. /**
  1095. * Sets the value for strNamePrefix
  1096. * @param string $mixValue
  1097. * @return string
  1098. */
  1099. try {
  1100. return ($this->strNamePrefix = QType::Cast($mixValue, QType::String));
  1101. } catch (QCallerException $objExc) {
  1102. $objExc->IncrementOffset();
  1103. throw $objExc;
  1104. }
  1105. case 'FirstName':
  1106. /**
  1107. * Sets the value for strFirstName
  1108. * @param string $mixValue
  1109. * @return string
  1110. */
  1111. try {
  1112. return ($this->strFirstName = QType::Cast($mixValue, QType::String));
  1113. } catch (QCallerException $objExc) {
  1114. $objExc->IncrementOffset();
  1115. throw $objExc;
  1116. }
  1117. case 'MiddleName':
  1118. /**
  1119. * Sets the value for strMiddleName
  1120. * @param string $mixValue
  1121. * @return string
  1122. */
  1123. try {
  1124. return ($this->strMiddleName = QType::Cast($mixValue, QType::String));
  1125. } catch (QCallerException $objExc) {
  1126. $objExc->IncrementOffset();
  1127. throw $objExc;
  1128. }
  1129. case 'LastName':
  1130. /**
  1131. * Sets the value for strLastName
  1132. * @param string $mixValue
  1133. * @return string
  1134. */
  1135. try {
  1136. return ($this->strLastName = QType::Cast($mixValue, QType::String));
  1137. } catch (QCallerException $objExc) {
  1138. $objExc->IncrementOffset();
  1139. throw $objExc;
  1140. }
  1141. case 'NameSuffix':
  1142. /**
  1143. * Sets the value for strNameSuffix
  1144. * @param string $mixValue
  1145. * @return string
  1146. */
  1147. try {
  1148. return ($this->strNameSuffix = QType::Cast($mixValue, QType::String));
  1149. } catch (QCallerException $objExc) {
  1150. $objExc->IncrementOffset();
  1151. throw $objExc;
  1152. }
  1153. case 'Company':
  1154. /**
  1155. * Sets the value for strCompany
  1156. * @param string $mixValue
  1157. * @return string
  1158. */
  1159. try {
  1160. return ($this->strCompany = QType::Cast($mixValue, QType::String));
  1161. } catch (QCallerException $objExc) {
  1162. $objExc->IncrementOffset();
  1163. throw $objExc;
  1164. }
  1165. case 'Street1':
  1166. /**
  1167. * Sets the value for strStreet1
  1168. * @param string $mixValue
  1169. * @return string
  1170. */
  1171. try {
  1172. return ($this->strStreet1 = QType::Cast($mixValue, QType::String));
  1173. } catch (QCallerException $objExc) {
  1174. $objExc->IncrementOffset();
  1175. throw $objExc;
  1176. }
  1177. case 'Street2':
  1178. /**
  1179. * Sets the value for strStreet2
  1180. * @param string $mixValue
  1181. * @return string
  1182. */
  1183. try {
  1184. return ($this->strStreet2 = QType::Cast($mixValue, QType::String));
  1185. } catch (QCallerException $objExc) {
  1186. $objExc->IncrementOffset();
  1187. throw $objExc;
  1188. }
  1189. case 'Suburb':
  1190. /**
  1191. * Sets the value for strSuburb
  1192. * @param string $mixValue
  1193. * @return string
  1194. */
  1195. try {
  1196. return ($this->strSuburb = QType::Cast($mixValue, QType::String));
  1197. } catch (QCallerException $objExc) {
  1198. $objExc->IncrementOffset();
  1199. throw $objExc;
  1200. }
  1201. case 'City':
  1202. /**
  1203. * Sets the value for strCity
  1204. * @param string $mixValue
  1205. * @return string
  1206. */
  1207. try {
  1208. return ($this->strCity = QType::Cast($mixValue, QType::String));
  1209. } catch (QCallerException $objExc) {
  1210. $objExc->IncrementOffset();
  1211. throw $objExc;
  1212. }
  1213. case 'County':
  1214. /**
  1215. * Sets the value for strCounty
  1216. * @param string $mixValue
  1217. * @return string
  1218. */
  1219. try {
  1220. return ($this->strCounty = QType::Cast($mixValue, QType::String));
  1221. } catch (QCallerException $objExc) {
  1222. $objExc->IncrementOffset();
  1223. throw $objExc;
  1224. }
  1225. case 'ZoneId':
  1226. /**
  1227. * Sets the value for intZoneId (Not Null)
  1228. * @param integer $mixValue
  1229. * @return integer
  1230. */
  1231. try {
  1232. return ($this->intZoneId = QType::Cast($mixValue, QType::Integer));
  1233. } catch (QCallerException $objExc) {
  1234. $objExc->IncrementOffset();
  1235. throw $objExc;
  1236. }
  1237. case 'CountryId':
  1238. /**
  1239. * Sets the value for intCountryId (Not Null)
  1240. * @param integer $mixValue
  1241. * @return integer
  1242. */
  1243. try {
  1244. return ($this->intCountryId = QType::Cast($mixValue, QType::Integer));
  1245. } catch (QCallerException $objExc) {
  1246. $objExc->IncrementOffset();
  1247. throw $objExc;
  1248. }
  1249. case 'PostalCode':
  1250. /**
  1251. * Sets the value for strPostalCode
  1252. * @param string $mixValue
  1253. * @return string
  1254. */
  1255. try {
  1256. return ($this->strPostalCode = QType::Cast($mixValue, QType::String));
  1257. } catch (QCallerException $objExc) {
  1258. $objExc->IncrementOffset();
  1259. throw $objExc;
  1260. }
  1261. case 'TypeId':
  1262. /**
  1263. * Sets the value for intTypeId (Not Null)
  1264. * @param integer $mixValue
  1265. * @return integer
  1266. */
  1267. try {
  1268. return ($this->intTypeId = QType::Cast($mixValue, QType::Integer));
  1269. } catch (QCallerException $objExc) {
  1270. $objExc->IncrementOffset();
  1271. throw $objExc;
  1272. }
  1273. ///////////////////
  1274. // Member Objects
  1275. ///////////////////
  1276. case 'Order':
  1277. /**
  1278. * Sets the value for the Order object referenced by intOrderId (Not Null)
  1279. * @param Order $mixValue
  1280. * @return Order
  1281. */
  1282. if (is_null($mixValue)) {
  1283. $this->intOrderId = null;
  1284. $this->objOrder = null;
  1285. return null;
  1286. } else {
  1287. // Make sure $mixValue actually is a Order object
  1288. try {
  1289. $mixValue = QType::Cast($mixValue, 'Order');
  1290. } catch (QInvalidCastException $objExc) {
  1291. $objExc->IncrementOffset();
  1292. throw $objExc;
  1293. }
  1294. // Make sure $mixValue is a SAVED Order object
  1295. if (is_null($mixValue->Id))
  1296. throw new QCallerException('Unable to set an unsaved Order for this OrderAddress');
  1297. // Update Local Member Variables
  1298. $this->objOrder = $mixValue;
  1299. $this->intOrderId = $mixValue->Id;
  1300. // Return $mixValue
  1301. return $mixValue;
  1302. }
  1303. break;
  1304. default:
  1305. try {
  1306. return parent::__set($strName, $mixValue);
  1307. } catch (QCallerException $objExc) {
  1308. $objExc->IncrementOffset();
  1309. throw $objExc;
  1310. }
  1311. }
  1312. }
  1313. ///////////////////////////////
  1314. // ASSOCIATED OBJECTS' METHODS
  1315. ///////////////////////////////
  1316. }
  1317. /////////////////////////////////////
  1318. // ADDITIONAL CLASSES for QCODO QUERY
  1319. /////////////////////////////////////
  1320. class QQNodeOrderAddress extends QQNode {
  1321. protected $strTableName = 'order_address';
  1322. protected $strPrimaryKey = 'id';
  1323. protected $strClassName = 'OrderAddress';
  1324. public function __get($strName) {
  1325. switch ($strName) {
  1326. case 'Id':
  1327. return new QQNode('id', 'Id', 'integer', $this);
  1328. case 'OrderId':
  1329. return new QQNode('order_id', 'OrderId', 'integer', $this);
  1330. case 'Order':
  1331. return new QQNodeOrder('order_id', 'Order', 'integer', $this);
  1332. case 'NamePrefix':
  1333. return new QQNode('name_prefix', 'NamePrefix', 'string', $this);
  1334. case 'FirstName':
  1335. return new QQNode('first_name', 'FirstName', 'string', $this);
  1336. case 'MiddleName':
  1337. return new QQNode('middle_name', 'MiddleName', 'string', $this);
  1338. case 'LastName':
  1339. return new QQNode('last_name', 'LastName', 'string', $this);
  1340. case 'NameSuffix':
  1341. return new QQNode('name_suffix', 'NameSuffix', 'string', $this);
  1342. case 'Company':
  1343. return new QQNode('company', 'Company', 'string', $this);
  1344. case 'Street1':
  1345. return new QQNode('street_1', 'Street1', 'string', $this);
  1346. case 'Street2':
  1347. return new QQNode('street_2', 'Street2', 'string', $this);
  1348. case 'Suburb':
  1349. return new QQNode('suburb', 'Suburb', 'string', $this);
  1350. case 'City':
  1351. return new QQNode('city', 'City', 'string', $this);
  1352. case 'County':
  1353. return new QQNode('county', 'County', 'string', $this);
  1354. case 'ZoneId':
  1355. return new QQNode('zone_id', 'ZoneId', 'integer', $this);
  1356. case 'CountryId':
  1357. return new QQNode('country_id', 'CountryId', 'integer', $this);
  1358. case 'PostalCode':
  1359. return new QQNode('postal_code', 'PostalCode', 'string', $this);
  1360. case 'TypeId':
  1361. return new QQNode('type_id', 'TypeId', 'integer', $this);
  1362. case 'CreationDate':
  1363. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  1364. case 'LastModification':
  1365. return new QQNode('last_modification', 'LastModification', 'string', $this);
  1366. case '_PrimaryKeyNode':
  1367. return new QQNode('id', 'Id', 'integer', $this);
  1368. default:
  1369. try {
  1370. return parent::__get($strName);
  1371. } catch (QCallerException $objExc) {
  1372. $objExc->IncrementOffset();
  1373. throw $objExc;
  1374. }
  1375. }
  1376. }
  1377. }
  1378. class QQReverseReferenceNodeOrderAddress extends QQReverseReferenceNode {
  1379. protected $strTableName = 'order_address';
  1380. protected $strPrimaryKey = 'id';
  1381. protected $strClassName = 'OrderAddress';
  1382. public function __get($strName) {
  1383. switch ($strName) {
  1384. case 'Id':
  1385. return new QQNode('id', 'Id', 'integer', $this);
  1386. case 'OrderId':
  1387. return new QQNode('order_id', 'OrderId', 'integer', $this);
  1388. case 'Order':
  1389. return new QQNodeOrder('order_id', 'Order', 'integer', $this);
  1390. case 'NamePrefix':
  1391. return new QQNode('name_prefix', 'NamePrefix', 'string', $this);
  1392. case 'FirstName':
  1393. return new QQNode('first_name', 'FirstName', 'string', $this);
  1394. case 'MiddleName':
  1395. return new QQNode('middle_name', 'MiddleName', 'string', $this);
  1396. case 'LastName':
  1397. return new QQNode('last_name', 'LastName', 'string', $this);
  1398. case 'NameSuffix':
  1399. return new QQNode('name_suffix', 'NameSuffix', 'string', $this);
  1400. case 'Company':
  1401. return new QQNode('company', 'Company', 'string', $this);
  1402. case 'Street1':
  1403. return new QQNode('street_1', 'Street1', 'string', $this);
  1404. case 'Street2':
  1405. return new QQNode('street_2', 'Street2', 'string', $this);
  1406. case 'Suburb':
  1407. return new QQNode('suburb', 'Suburb', 'string', $this);
  1408. case 'City':
  1409. return new QQNode('city', 'City', 'string', $this);
  1410. case 'County':
  1411. return new QQNode('county', 'County', 'string', $this);
  1412. case 'ZoneId':
  1413. return new QQNode('zone_id', 'ZoneId', 'integer', $this);
  1414. case 'CountryId':
  1415. return new QQNode('country_id', 'CountryId', 'integer', $this);
  1416. case 'PostalCode':
  1417. return new QQNode('postal_code', 'PostalCode', 'string', $this);
  1418. case 'TypeId':
  1419. return new QQNode('type_id', 'TypeId', 'integer', $this);
  1420. case 'CreationDate':
  1421. return new QQNode('creation_date', 'CreationDate', 'string', $this);
  1422. case 'LastModification':
  1423. return new QQNode('last_modification', 'LastModification', 'string', $this);
  1424. case '_PrimaryKeyNode':
  1425. return new QQNode('id', 'Id', 'integer', $this);
  1426. default:
  1427. try {
  1428. return parent::__get($strName);
  1429. } catch (QCallerException $objExc) {
  1430. $objExc->IncrementOffset();
  1431. throw $objExc;
  1432. }
  1433. }
  1434. }
  1435. }
  1436. ?>