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.

1435 lines
61 KiB

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