PageRenderTime 99ms CodeModel.GetById 28ms RepoModel.GetById 28ms app.codeStats 1ms

/includes/model/generated/WordGen.class.php

https://bitbucket.org/diacritice/submit-word
PHP | 1513 lines | 763 code | 223 blank | 527 comment | 107 complexity | 97341e6a4a2a6b2c64e27d9c5fbbb964 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

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

Large files files are truncated, but you can click here to view the full file