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.

3156 lines
140 KiB

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