PageRenderTime 53ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/generator/lib/builder/om/QueryBuilder.php

https://github.com/1989gaurav/Propel
PHP | 1290 lines | 932 code | 40 blank | 318 comment | 78 complexity | 368d339ab545f3d1505b969b982f7a1e MD5 | raw file
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. require_once dirname(__FILE__) . '/OMBuilder.php';
  10. /**
  11. * Generates a PHP5 base Query class for user object model (OM).
  12. *
  13. * This class produces the base query class (e.g. BaseBookQuery) which contains all
  14. * the custom-built query methods.
  15. *
  16. * @author Francois Zaninotto
  17. * @package propel.generator.builder.om
  18. */
  19. class QueryBuilder extends OMBuilder
  20. {
  21. /**
  22. * Gets the package for the [base] object classes.
  23. * @return string
  24. */
  25. public function getPackage()
  26. {
  27. return parent::getPackage() . ".om";
  28. }
  29. public function getNamespace()
  30. {
  31. if ($namespace = parent::getNamespace()) {
  32. if ($this->getGeneratorConfig() && $omns = $this->getGeneratorConfig()->getBuildProperty('namespaceOm')) {
  33. return $namespace . '\\' . $omns;
  34. } else {
  35. return $namespace;
  36. }
  37. }
  38. }
  39. /**
  40. * Returns the name of the current class being built.
  41. * @return string
  42. */
  43. public function getUnprefixedClassname()
  44. {
  45. return $this->getBuildProperty('basePrefix') . $this->getStubQueryBuilder()->getUnprefixedClassname();
  46. }
  47. /**
  48. * Adds the include() statements for files that this class depends on or utilizes.
  49. * @param string &$script The script will be modified in this method.
  50. */
  51. protected function addIncludes(&$script)
  52. {
  53. }
  54. /**
  55. * Adds class phpdoc comment and openning of class.
  56. * @param string &$script The script will be modified in this method.
  57. */
  58. protected function addClassOpen(&$script)
  59. {
  60. $table = $this->getTable();
  61. $tableName = $table->getName();
  62. $tableDesc = $table->getDescription();
  63. $queryClass = $this->getStubQueryBuilder()->getClassname();
  64. $modelClass = $this->getStubObjectBuilder()->getClassname();
  65. $parentClass = $this->getBehaviorContent('parentClass');
  66. $parentClass = null === $parentClass ? 'ModelCriteria' : $parentClass;
  67. $script .= "
  68. /**
  69. * Base class that represents a query for the '$tableName' table.
  70. *
  71. * $tableDesc
  72. *";
  73. if ($this->getBuildProperty('addTimeStamp')) {
  74. $now = strftime('%c');
  75. $script .= "
  76. * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:
  77. *
  78. * $now
  79. *";
  80. }
  81. // magic orderBy() methods, for IDE completion
  82. foreach ($this->getTable()->getColumns() as $column) {
  83. $script .= "
  84. * @method $queryClass orderBy" . $column->getPhpName() . "(\$order = Criteria::ASC) Order by the " . $column->getName() . " column";
  85. }
  86. $script .= "
  87. *";
  88. // magic groupBy() methods, for IDE completion
  89. foreach ($this->getTable()->getColumns() as $column) {
  90. $script .= "
  91. * @method $queryClass groupBy" . $column->getPhpName() . "() Group by the " . $column->getName() . " column";
  92. }
  93. // override the signature of ModelCriteria::left-, right- and innerJoin to specify the class of the returned object, for IDE completion
  94. $script .= "
  95. *
  96. * @method $queryClass leftJoin(\$relation) Adds a LEFT JOIN clause to the query
  97. * @method $queryClass rightJoin(\$relation) Adds a RIGHT JOIN clause to the query
  98. * @method $queryClass innerJoin(\$relation) Adds a INNER JOIN clause to the query
  99. *";
  100. // magic XXXjoinYYY() methods, for IDE completion
  101. foreach ($this->getTable()->getForeignKeys() as $fk) {
  102. $relationName = $this->getFKPhpNameAffix($fk);
  103. $script .= "
  104. * @method $queryClass leftJoin" . $relationName . "(\$relationAlias = null) Adds a LEFT JOIN clause to the query using the " . $relationName . " relation
  105. * @method $queryClass rightJoin" . $relationName . "(\$relationAlias = null) Adds a RIGHT JOIN clause to the query using the " . $relationName . " relation
  106. * @method $queryClass innerJoin" . $relationName . "(\$relationAlias = null) Adds a INNER JOIN clause to the query using the " . $relationName . " relation
  107. *";
  108. }
  109. foreach ($this->getTable()->getReferrers() as $refFK) {
  110. $relationName = $this->getRefFKPhpNameAffix($refFK);
  111. $script .= "
  112. * @method $queryClass leftJoin" . $relationName . "(\$relationAlias = null) Adds a LEFT JOIN clause to the query using the " . $relationName . " relation
  113. * @method $queryClass rightJoin" . $relationName . "(\$relationAlias = null) Adds a RIGHT JOIN clause to the query using the " . $relationName . " relation
  114. * @method $queryClass innerJoin" . $relationName . "(\$relationAlias = null) Adds a INNER JOIN clause to the query using the " . $relationName . " relation
  115. *";
  116. }
  117. // override the signature of ModelCriteria::findOne() to specify the class of the returned object, for IDE completion
  118. $script .= "
  119. * @method $modelClass findOne(PropelPDO \$con = null) Return the first $modelClass matching the query
  120. * @method $modelClass findOneOrCreate(PropelPDO \$con = null) Return the first $modelClass matching the query, or a new $modelClass object populated from the query conditions when no match is found
  121. *";
  122. // magic findBy() methods, for IDE completion
  123. foreach ($this->getTable()->getColumns() as $column) {
  124. $script .= "
  125. * @method $modelClass findOneBy" . $column->getPhpName() . "(" . $column->getPhpType() . " \$" . $column->getName() . ") Return the first $modelClass filtered by the " . $column->getName() . " column";
  126. }
  127. $script .= "
  128. *";
  129. foreach ($this->getTable()->getColumns() as $column) {
  130. $script .= "
  131. * @method array findBy" . $column->getPhpName() . "(" . $column->getPhpType() . " \$" . $column->getName() . ") Return $modelClass objects filtered by the " . $column->getName() . " column";
  132. }
  133. $script .= "
  134. *
  135. * @package propel.generator.".$this->getPackage()."
  136. */
  137. abstract class ".$this->getClassname()." extends " . $parentClass . "
  138. {
  139. ";
  140. }
  141. /**
  142. * Specifies the methods that are added as part of the stub object class.
  143. *
  144. * By default there are no methods for the empty stub classes; override this method
  145. * if you want to change that behavior.
  146. *
  147. * @see ObjectBuilder::addClassBody()
  148. */
  149. protected function addClassBody(&$script)
  150. {
  151. // namespaces
  152. $this->declareClasses('ModelCriteria', 'Criteria', 'ModelJoin');
  153. $this->declareClassFromBuilder($this->getStubQueryBuilder());
  154. $this->declareClassFromBuilder($this->getStubPeerBuilder());
  155. // apply behaviors
  156. $this->applyBehaviorModifier('queryAttributes', $script, " ");
  157. $this->addConstructor($script);
  158. $this->addFactory($script);
  159. $this->addFindPk($script);
  160. $this->addFindPks($script);
  161. $this->addFilterByPrimaryKey($script);
  162. $this->addFilterByPrimaryKeys($script);
  163. foreach ($this->getTable()->getColumns() as $col) {
  164. $this->addFilterByCol($script, $col);
  165. if ($col->getType() === PropelTypes::PHP_ARRAY && $col->isNamePlural()) {
  166. $this->addFilterByArrayCol($script, $col);
  167. }
  168. }
  169. foreach ($this->getTable()->getForeignKeys() as $fk) {
  170. $this->addFilterByFK($script, $fk);
  171. $this->addJoinFk($script, $fk);
  172. $this->addUseFKQuery($script, $fk);
  173. }
  174. foreach ($this->getTable()->getReferrers() as $refFK) {
  175. $this->addFilterByRefFK($script, $refFK);
  176. $this->addJoinRefFk($script, $refFK);
  177. $this->addUseRefFKQuery($script, $refFK);
  178. }
  179. foreach ($this->getTable()->getCrossFks() as $fkList) {
  180. list($refFK, $crossFK) = $fkList;
  181. $this->addFilterByCrossFK($script, $refFK, $crossFK);
  182. }
  183. $this->addPrune($script);
  184. $this->addBasePreSelect($script);
  185. $this->addBasePreDelete($script);
  186. $this->addBasePostDelete($script);
  187. $this->addBasePreUpdate($script);
  188. $this->addBasePostUpdate($script);
  189. // apply behaviors
  190. $this->applyBehaviorModifier('queryMethods', $script, " ");
  191. }
  192. /**
  193. * Closes class.
  194. * @param string &$script The script will be modified in this method.
  195. */
  196. protected function addClassClose(&$script)
  197. {
  198. $script .= "
  199. } // " . $this->getClassname() . "";
  200. $this->applyBehaviorModifier('queryFilter', $script, "");
  201. }
  202. /**
  203. * Adds the constructor for this object.
  204. * @param string &$script The script will be modified in this method.
  205. * @see addConstructor()
  206. */
  207. protected function addConstructor(&$script)
  208. {
  209. $this->addConstructorComment($script);
  210. $this->addConstructorOpen($script);
  211. $this->addConstructorBody($script);
  212. $this->addConstructorClose($script);
  213. }
  214. /**
  215. * Adds the comment for the constructor
  216. * @param string &$script The script will be modified in this method.
  217. **/
  218. protected function addConstructorComment(&$script)
  219. {
  220. $script .= "
  221. /**
  222. * Initializes internal state of ".$this->getClassname()." object.
  223. *
  224. * @param string \$dbName The dabase name
  225. * @param string \$modelName The phpName of a model, e.g. 'Book'
  226. * @param string \$modelAlias The alias for the model in this query, e.g. 'b'
  227. */";
  228. }
  229. /**
  230. * Adds the function declaration for the constructor
  231. * @param string &$script The script will be modified in this method.
  232. **/
  233. protected function addConstructorOpen(&$script)
  234. {
  235. $table = $this->getTable();
  236. $script .= "
  237. public function __construct(\$dbName = '" . $table->getDatabase()->getName() . "', \$modelName = '" . addslashes($this->getNewStubObjectBuilder($table)->getFullyQualifiedClassname()) . "', \$modelAlias = null)
  238. {";
  239. }
  240. /**
  241. * Adds the function body for the constructor
  242. * @param string &$script The script will be modified in this method.
  243. **/
  244. protected function addConstructorBody(&$script)
  245. {
  246. $script .= "
  247. parent::__construct(\$dbName, \$modelName, \$modelAlias);";
  248. }
  249. /**
  250. * Adds the function close for the constructor
  251. * @param string &$script The script will be modified in this method.
  252. **/
  253. protected function addConstructorClose(&$script)
  254. {
  255. $script .= "
  256. }
  257. ";
  258. }
  259. /**
  260. * Adds the factory for this object.
  261. * @param string &$script The script will be modified in this method.
  262. */
  263. protected function addFactory(&$script)
  264. {
  265. $this->addFactoryComment($script);
  266. $this->addFactoryOpen($script);
  267. $this->addFactoryBody($script);
  268. $this->addFactoryClose($script);
  269. }
  270. /**
  271. * Adds the comment for the factory
  272. * @param string &$script The script will be modified in this method.
  273. **/
  274. protected function addFactoryComment(&$script)
  275. {
  276. $classname = $this->getNewStubQueryBuilder($this->getTable())->getClassname();
  277. $script .= "
  278. /**
  279. * Returns a new " . $classname . " object.
  280. *
  281. * @param string \$modelAlias The alias of a model in the query
  282. * @param Criteria \$criteria Optional Criteria to build the query from
  283. *
  284. * @return " . $classname . "
  285. */";
  286. }
  287. /**
  288. * Adds the function declaration for the factory
  289. * @param string &$script The script will be modified in this method.
  290. **/
  291. protected function addFactoryOpen(&$script)
  292. {
  293. $script .= "
  294. public static function create(\$modelAlias = null, \$criteria = null)
  295. {";
  296. }
  297. /**
  298. * Adds the function body for the factory
  299. * @param string &$script The script will be modified in this method.
  300. */
  301. protected function addFactoryBody(&$script)
  302. {
  303. $classname = $this->getNewStubQueryBuilder($this->getTable())->getClassname();
  304. $script .= "
  305. if (\$criteria instanceof " . $classname . ") {
  306. return \$criteria;
  307. }
  308. \$query = new " . $classname . "();
  309. if (null !== \$modelAlias) {
  310. \$query->setModelAlias(\$modelAlias);
  311. }
  312. if (\$criteria instanceof Criteria) {
  313. \$query->mergeWith(\$criteria);
  314. }
  315. return \$query;";
  316. }
  317. /**
  318. * Adds the function close for the factory
  319. * @param string &$script The script will be modified in this method.
  320. */
  321. protected function addFactoryClose(&$script)
  322. {
  323. $script .= "
  324. }
  325. ";
  326. }
  327. /**
  328. * Adds the findPk method for this object.
  329. * @param string &$script The script will be modified in this method.
  330. */
  331. protected function addFindPk(&$script)
  332. {
  333. $table = $this->getTable();
  334. $pks = $table->getPrimaryKey();
  335. $class = $class = $this->getStubObjectBuilder()->getClassname();
  336. $this->declareClasses('PropelPDO');
  337. $script .= "
  338. /**
  339. * Find object by primary key";
  340. if (count($pks) === 1) {
  341. $pkType = 'mixed';
  342. $script .= "
  343. * Use instance pooling to avoid a database query if the object exists
  344. * <code>
  345. * \$obj = \$c->findPk(12, \$con);";
  346. } else {
  347. $examplePk = array_slice(array(12, 34, 56, 78, 91), 0, count($pks));
  348. $colNames = array();
  349. foreach ($pks as $col) {
  350. $colNames[]= '$' . $col->getName();
  351. }
  352. $pkType = 'array['. join($colNames, ', ') . ']';
  353. $script .= "
  354. * <code>
  355. * \$obj = \$c->findPk(array(" . join($examplePk, ', ') . "), \$con);";
  356. }
  357. $script .= "
  358. * </code>
  359. * @param " . $pkType . " \$key Primary key to use for the query
  360. * @param PropelPDO \$con an optional connection object
  361. *
  362. * @return " . $class . "|array|mixed the result, formatted by the current formatter
  363. */
  364. public function findPk(\$key, \$con = null)
  365. {";
  366. if (count($pks) === 1) {
  367. $poolKeyHashParams = '$key';
  368. } else {
  369. $poolKeyHashParams = array();
  370. for ($i = 0, $count = count($pks); $i < $count; $i++) {
  371. $poolKeyHashParams[]= '$key[' . $i . ']';
  372. }
  373. }
  374. // tip: we don't use findOne() to avoid putting an unecessary LIMIT 1 statement,
  375. // which may be costly on platforms not natively supporting LIMIT (like Oracle)
  376. $script .= "
  377. if ((null !== (\$obj = ".$this->getPeerClassname()."::getInstanceFromPool(".$this->getPeerBuilder()->getInstancePoolKeySnippet($poolKeyHashParams)."))) && \$this->getFormatter()->isObjectFormatter()) {
  378. // the object is alredy in the instance pool
  379. return \$obj;
  380. } else {
  381. // the object has not been requested yet, or the formatter is not an object formatter
  382. \$criteria = \$this->isKeepQuery() ? clone \$this : \$this;
  383. \$stmt = \$criteria
  384. ->filterByPrimaryKey(\$key)
  385. ->getSelectStatement(\$con);
  386. return \$criteria->getFormatter()->init(\$criteria)->formatOne(\$stmt);
  387. }
  388. }
  389. ";
  390. }
  391. /**
  392. * Adds the findPks method for this object.
  393. * @param string &$script The script will be modified in this method.
  394. */
  395. protected function addFindPks(&$script)
  396. {
  397. $this->declareClasses('PropelPDO');
  398. $table = $this->getTable();
  399. $pks = $table->getPrimaryKey();
  400. $count = count($pks);
  401. $script .= "
  402. /**
  403. * Find objects by primary key
  404. * <code>";
  405. if ($count === 1) {
  406. $script .= "
  407. * \$objs = \$c->findPks(array(12, 56, 832), \$con);";
  408. } else {
  409. $script .= "
  410. * \$objs = \$c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), \$con);";
  411. }
  412. $script .= "
  413. * </code>
  414. * @param array \$keys Primary keys to use for the query
  415. * @param PropelPDO \$con an optional connection object
  416. *
  417. * @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
  418. */
  419. public function findPks(\$keys, \$con = null)
  420. {
  421. \$criteria = \$this->isKeepQuery() ? clone \$this : \$this;
  422. return \$this
  423. ->filterByPrimaryKeys(\$keys)
  424. ->find(\$con);
  425. }
  426. ";
  427. }
  428. /**
  429. * Adds the filterByPrimaryKey method for this object.
  430. * @param string &$script The script will be modified in this method.
  431. */
  432. protected function addFilterByPrimaryKey(&$script)
  433. {
  434. $script .= "
  435. /**
  436. * Filter the query by primary key
  437. *
  438. * @param mixed \$key Primary key to use for the query
  439. *
  440. * @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
  441. */
  442. public function filterByPrimaryKey(\$key)
  443. {";
  444. $table = $this->getTable();
  445. $pks = $table->getPrimaryKey();
  446. if (count($pks) === 1) {
  447. // simple primary key
  448. $col = $pks[0];
  449. $const = $this->getColumnConstant($col);
  450. $script .= "
  451. return \$this->addUsingAlias($const, \$key, Criteria::EQUAL);";
  452. } else {
  453. // composite primary key
  454. $i = 0;
  455. foreach ($pks as $col) {
  456. $const = $this->getColumnConstant($col);
  457. $script .= "
  458. \$this->addUsingAlias($const, \$key[$i], Criteria::EQUAL);";
  459. $i++;
  460. }
  461. $script .= "
  462. return \$this;";
  463. }
  464. $script .= "
  465. }
  466. ";
  467. }
  468. /**
  469. * Adds the filterByPrimaryKey method for this object.
  470. * @param string &$script The script will be modified in this method.
  471. */
  472. protected function addFilterByPrimaryKeys(&$script)
  473. {
  474. $script .= "
  475. /**
  476. * Filter the query by a list of primary keys
  477. *
  478. * @param array \$keys The list of primary key to use for the query
  479. *
  480. * @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
  481. */
  482. public function filterByPrimaryKeys(\$keys)
  483. {";
  484. $table = $this->getTable();
  485. $pks = $table->getPrimaryKey();
  486. if (count($pks) === 1) {
  487. // simple primary key
  488. $col = $pks[0];
  489. $const = $this->getColumnConstant($col);
  490. $script .= "
  491. return \$this->addUsingAlias($const, \$keys, Criteria::IN);";
  492. } else {
  493. // composite primary key
  494. $script .= "
  495. if (empty(\$keys)) {
  496. return \$this->add(null, '1<>1', Criteria::CUSTOM);
  497. }
  498. foreach (\$keys as \$key) {";
  499. $i = 0;
  500. foreach ($pks as $col) {
  501. $const = $this->getColumnConstant($col);
  502. $script .= "
  503. \$cton$i = \$this->getNewCriterion($const, \$key[$i], Criteria::EQUAL);";
  504. if ($i>0) {
  505. $script .= "
  506. \$cton0->addAnd(\$cton$i);";
  507. }
  508. $i++;
  509. }
  510. $script .= "
  511. \$this->addOr(\$cton0);
  512. }";
  513. $script .= "
  514. return \$this;";
  515. }
  516. $script .= "
  517. }
  518. ";
  519. }
  520. /**
  521. * Adds the filterByCol method for this object.
  522. * @param string &$script The script will be modified in this method.
  523. */
  524. protected function addFilterByCol(&$script, $col)
  525. {
  526. $colPhpName = $col->getPhpName();
  527. $colName = $col->getName();
  528. $variableName = $col->getStudlyPhpName();
  529. $qualifiedName = $this->getColumnConstant($col);
  530. $script .= "
  531. /**
  532. * Filter the query on the $colName column
  533. *";
  534. if ($col->isNumericType()) {
  535. $script .= "
  536. * Example usage:
  537. * <code>
  538. * \$query->filterBy$colPhpName(1234); // WHERE $colName = 1234
  539. * \$query->filterBy$colPhpName(array(12, 34)); // WHERE $colName IN (12, 34)
  540. * \$query->filterBy$colPhpName(array('min' => 12)); // WHERE $colName > 12
  541. * </code>";
  542. if ($col->isForeignKey()) {
  543. foreach ($col->getForeignKeys() as $fk) {
  544. $script .= "
  545. *
  546. * @see filterBy" . $this->getFKPhpNameAffix($fk) . "()";
  547. }
  548. }
  549. $script .= "
  550. *
  551. * @param mixed \$$variableName The value to use as filter.
  552. * Use scalar values for equality.
  553. * Use array values for in_array() equivalent.
  554. * Use associative array('min' => \$minValue, 'max' => \$maxValue) for intervals.";
  555. } elseif ($col->isTemporalType()) {
  556. $script .= "
  557. * Example usage:
  558. * <code>
  559. * \$query->filterBy$colPhpName('2011-03-14'); // WHERE $colName = '2011-03-14'
  560. * \$query->filterBy$colPhpName('now'); // WHERE $colName = '2011-03-14'
  561. * \$query->filterBy$colPhpName(array('max' => 'yesterday')); // WHERE $colName > '2011-03-13'
  562. * </code>
  563. *
  564. * @param mixed \$$variableName The value to use as filter.
  565. * Values can be integers (unix timestamps), DateTime objects, or strings.
  566. * Empty strings are treated as NULL.
  567. * Use scalar values for equality.
  568. * Use array values for in_array() equivalent.
  569. * Use associative array('min' => \$minValue, 'max' => \$maxValue) for intervals.";
  570. } elseif ($col->getType() == PropelTypes::PHP_ARRAY) {
  571. $script .= "
  572. * @param array \$$variableName The values to use as filter.";
  573. } elseif ($col->isTextType()) {
  574. $script .= "
  575. * Example usage:
  576. * <code>
  577. * \$query->filterBy$colPhpName('fooValue'); // WHERE $colName = 'fooValue'
  578. * \$query->filterBy$colPhpName('%fooValue%'); // WHERE $colName LIKE '%fooValue%'
  579. * </code>
  580. *
  581. * @param string \$$variableName The value to use as filter.
  582. * Accepts wildcards (* and % trigger a LIKE)";
  583. } elseif ($col->isBooleanType()) {
  584. $script .= "
  585. * Example usage:
  586. * <code>
  587. * \$query->filterBy$colPhpName(true); // WHERE $colName = true
  588. * \$query->filterBy$colPhpName('yes'); // WHERE $colName = true
  589. * </code>
  590. *
  591. * @param boolean|string \$$variableName The value to use as filter.
  592. * Non-boolean arguments are converted using the following rules:
  593. * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
  594. * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
  595. * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').";
  596. } else {
  597. $script .= "
  598. * @param mixed \$$variableName The value to use as filter";
  599. }
  600. $script .= "
  601. * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  602. *
  603. * @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
  604. */
  605. public function filterBy$colPhpName(\$$variableName = null, \$comparison = null)
  606. {";
  607. if ($col->isPrimaryKey() && ($col->getType() == PropelTypes::INTEGER || $col->getType() == PropelTypes::BIGINT)) {
  608. $script .= "
  609. if (is_array(\$$variableName) && null === \$comparison) {
  610. \$comparison = Criteria::IN;
  611. }";
  612. } elseif ($col->isNumericType() || $col->isTemporalType()) {
  613. $script .= "
  614. if (is_array(\$$variableName)) {
  615. \$useMinMax = false;
  616. if (isset(\${$variableName}['min'])) {
  617. \$this->addUsingAlias($qualifiedName, \${$variableName}['min'], Criteria::GREATER_EQUAL);
  618. \$useMinMax = true;
  619. }
  620. if (isset(\${$variableName}['max'])) {
  621. \$this->addUsingAlias($qualifiedName, \${$variableName}['max'], Criteria::LESS_EQUAL);
  622. \$useMinMax = true;
  623. }
  624. if (\$useMinMax) {
  625. return \$this;
  626. }
  627. if (null === \$comparison) {
  628. \$comparison = Criteria::IN;
  629. }
  630. }";
  631. } elseif ($col->getType() == PropelTypes::OBJECT) {
  632. $script .= "
  633. if (is_object(\$$variableName)) {
  634. \$$variableName = serialize(\$$variableName);
  635. }";
  636. } elseif ($col->getType() == PropelTypes::PHP_ARRAY) {
  637. $script .= "
  638. \$key = \$this->getAliasedColName($qualifiedName);
  639. if (null === \$comparison || \$comparison == Criteria::CONTAINS_ALL) {
  640. foreach (\$$variableName as \$value) {
  641. \$value = '%| ' . \$value . ' |%';
  642. if(\$this->containsKey(\$key)) {
  643. \$this->addAnd(\$key, \$value, Criteria::LIKE);
  644. } else {
  645. \$this->add(\$key, \$value, Criteria::LIKE);
  646. }
  647. }
  648. return \$this;
  649. } elseif (\$comparison == Criteria::CONTAINS_SOME) {
  650. foreach (\$$variableName as \$value) {
  651. \$value = '%| ' . \$value . ' |%';
  652. if(\$this->containsKey(\$key)) {
  653. \$this->addOr(\$key, \$value, Criteria::LIKE);
  654. } else {
  655. \$this->add(\$key, \$value, Criteria::LIKE);
  656. }
  657. }
  658. return \$this;
  659. } elseif (\$comparison == Criteria::CONTAINS_NONE) {
  660. foreach (\$$variableName as \$value) {
  661. \$value = '%| ' . \$value . ' |%';
  662. if(\$this->containsKey(\$key)) {
  663. \$this->addAnd(\$key, \$value, Criteria::NOT_LIKE);
  664. } else {
  665. \$this->add(\$key, \$value, Criteria::NOT_LIKE);
  666. }
  667. }
  668. \$this->addOr(\$key, null, Criteria::ISNULL);
  669. return \$this;
  670. }";
  671. } elseif ($col->getType() == PropelTypes::ENUM) {
  672. $script .= "
  673. \$valueSet = " . $this->getPeerClassname() . "::getValueSet(" . $this->getColumnConstant($col) . ");
  674. if (is_scalar(\$$variableName)) {
  675. if (!in_array(\$$variableName, \$valueSet)) {
  676. throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$$variableName));
  677. }
  678. \$$variableName = array_search(\$$variableName, \$valueSet);
  679. } elseif (is_array(\$$variableName)) {
  680. \$convertedValues = array();
  681. foreach (\$$variableName as \$value) {
  682. if (!in_array(\$value, \$valueSet)) {
  683. throw new PropelException(sprintf('Value \"%s\" is not accepted in this enumerated column', \$value));
  684. }
  685. \$convertedValues []= array_search(\$value, \$valueSet);
  686. }
  687. \$$variableName = \$convertedValues;
  688. if (null === \$comparison) {
  689. \$comparison = Criteria::IN;
  690. }
  691. }";
  692. } elseif ($col->isTextType()) {
  693. $script .= "
  694. if (null === \$comparison) {
  695. if (is_array(\$$variableName)) {
  696. \$comparison = Criteria::IN;
  697. } elseif (preg_match('/[\%\*]/', \$$variableName)) {
  698. \$$variableName = str_replace('*', '%', \$$variableName);
  699. \$comparison = Criteria::LIKE;
  700. }
  701. }";
  702. } elseif ($col->isBooleanType()) {
  703. $script .= "
  704. if (is_string(\$$variableName)) {
  705. \$$colName = in_array(strtolower(\$$variableName), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
  706. }";
  707. }
  708. $script .= "
  709. return \$this->addUsingAlias($qualifiedName, \$$variableName, \$comparison);
  710. }
  711. ";
  712. }
  713. /**
  714. * Adds the singular filterByCol method for an Arry column.
  715. * @param string &$script The script will be modified in this method.
  716. */
  717. protected function addFilterByArrayCol(&$script, $col)
  718. {
  719. $colPhpName = $col->getPhpName();
  720. $singularPhpName = rtrim($colPhpName, 's');
  721. $colName = $col->getName();
  722. $variableName = $col->getStudlyPhpName();
  723. $qualifiedName = $this->getColumnConstant($col);
  724. $script .= "
  725. /**
  726. * Filter the query on the $colName column
  727. * @param mixed \$$variableName The value to use as filter
  728. * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::CONTAINS_ALL
  729. *
  730. * @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
  731. */
  732. public function filterBy$singularPhpName(\$$variableName = null, \$comparison = null)
  733. {
  734. if (null === \$comparison || \$comparison == Criteria::CONTAINS_ALL) {
  735. if (is_scalar(\$$variableName)) {
  736. \$$variableName = '%| ' . \$$variableName . ' |%';
  737. \$comparison = Criteria::LIKE;
  738. }
  739. } elseif (\$comparison == Criteria::CONTAINS_NONE) {
  740. \$$variableName = '%| ' . \$$variableName . ' |%';
  741. \$comparison = Criteria::NOT_LIKE;
  742. \$key = \$this->getAliasedColName($qualifiedName);
  743. if(\$this->containsKey(\$key)) {
  744. \$this->addAnd(\$key, \$$variableName, \$comparison);
  745. } else {
  746. \$this->addAnd(\$key, \$$variableName, \$comparison);
  747. }
  748. \$this->addOr(\$key, null, Criteria::ISNULL);
  749. return \$this;
  750. }
  751. return \$this->addUsingAlias($qualifiedName, \$$variableName, \$comparison);
  752. }
  753. ";
  754. }
  755. /**
  756. * Adds the filterByFk method for this object.
  757. * @param string &$script The script will be modified in this method.
  758. */
  759. protected function addFilterByFk(&$script, $fk)
  760. {
  761. $this->declareClasses('PropelCollection', 'PropelException');
  762. $table = $this->getTable();
  763. $queryClass = $this->getStubQueryBuilder()->getClassname();
  764. $fkTable = $this->getForeignTable($fk);
  765. $fkStubObjectBuilder = $this->getNewStubObjectBuilder($fkTable);
  766. $this->declareClassFromBuilder($fkStubObjectBuilder);
  767. $fkPhpName = $fkStubObjectBuilder->getClassname();
  768. $relationName = $this->getFKPhpNameAffix($fk);
  769. $objectName = '$' . $fkTable->getStudlyPhpName();
  770. $script .= "
  771. /**
  772. * Filter the query by a related $fkPhpName object
  773. *";
  774. if ($fk->isComposite()) {
  775. $script .= "
  776. * @param $fkPhpName $objectName The related object to use as filter";
  777. } else {
  778. $script .= "
  779. * @param $fkPhpName|PropelCollection $objectName The related object(s) to use as filter";
  780. }
  781. $script .= "
  782. * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  783. *
  784. * @return $queryClass The current query, for fluid interface
  785. */
  786. public function filterBy$relationName($objectName, \$comparison = null)
  787. {
  788. if ($objectName instanceof $fkPhpName) {
  789. return \$this";
  790. foreach ($fk->getLocalForeignMapping() as $localColumn => $foreignColumn) {
  791. $localColumnObject = $table->getColumn($localColumn);
  792. $foreignColumnObject = $fkTable->getColumn($foreignColumn);
  793. $script .= "
  794. ->addUsingAlias(" . $this->getColumnConstant($localColumnObject) . ", " . $objectName . "->get" . $foreignColumnObject->getPhpName() . "(), \$comparison)";
  795. }
  796. $script .= ";";
  797. if (!$fk->isComposite()) {
  798. $localColumnConstant = $this->getColumnConstant($fk->getLocalColumn());
  799. $foreignColumnName = $fk->getForeignColumn()->getPhpName();
  800. $script .= "
  801. } elseif ($objectName instanceof PropelCollection) {
  802. if (null === \$comparison) {
  803. \$comparison = Criteria::IN;
  804. }
  805. return \$this
  806. ->addUsingAlias($localColumnConstant, {$objectName}->toKeyValue('PrimaryKey', '$foreignColumnName'), \$comparison);";
  807. }
  808. $script .= "
  809. } else {";
  810. if ($fk->isComposite()) {
  811. $script .= "
  812. throw new PropelException('filterBy$relationName() only accepts arguments of type $fkPhpName');";
  813. } else {
  814. $script .= "
  815. throw new PropelException('filterBy$relationName() only accepts arguments of type $fkPhpName or PropelCollection');";
  816. }
  817. $script .= "
  818. }
  819. }
  820. ";
  821. }
  822. /**
  823. * Adds the filterByRefFk method for this object.
  824. * @param string &$script The script will be modified in this method.
  825. */
  826. protected function addFilterByRefFk(&$script, $fk)
  827. {
  828. $this->declareClasses('PropelCollection', 'PropelException');
  829. $table = $this->getTable();
  830. $queryClass = $this->getStubQueryBuilder()->getClassname();
  831. $fkTable = $this->getTable()->getDatabase()->getTable($fk->getTableName());
  832. $fkStubObjectBuilder = $this->getNewStubObjectBuilder($fkTable);
  833. $this->declareClassFromBuilder($fkStubObjectBuilder);
  834. $fkPhpName = $fkStubObjectBuilder->getClassname();
  835. $relationName = $this->getRefFKPhpNameAffix($fk);
  836. $objectName = '$' . $fkTable->getStudlyPhpName();
  837. $script .= "
  838. /**
  839. * Filter the query by a related $fkPhpName object
  840. *
  841. * @param $fkPhpName $objectName the related object to use as filter
  842. * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  843. *
  844. * @return $queryClass The current query, for fluid interface
  845. */
  846. public function filterBy$relationName($objectName, \$comparison = null)
  847. {
  848. if ($objectName instanceof $fkPhpName) {
  849. return \$this";
  850. foreach ($fk->getForeignLocalMapping() as $localColumn => $foreignColumn) {
  851. $localColumnObject = $table->getColumn($localColumn);
  852. $foreignColumnObject = $fkTable->getColumn($foreignColumn);
  853. $script .= "
  854. ->addUsingAlias(" . $this->getColumnConstant($localColumnObject) . ", " . $objectName . "->get" . $foreignColumnObject->getPhpName() . "(), \$comparison)";
  855. }
  856. $script .= ";";
  857. if (!$fk->isComposite()) {
  858. $script .= "
  859. } elseif ($objectName instanceof PropelCollection) {
  860. return \$this
  861. ->use{$relationName}Query()
  862. ->filterByPrimaryKeys({$objectName}->getPrimaryKeys())
  863. ->endUse();";
  864. }
  865. $script .= "
  866. } else {";
  867. if ($fk->isComposite()) {
  868. $script .= "
  869. throw new PropelException('filterBy$relationName() only accepts arguments of type $fkPhpName');";
  870. } else {
  871. $script .= "
  872. throw new PropelException('filterBy$relationName() only accepts arguments of type $fkPhpName or PropelCollection');";
  873. }
  874. $script .= "
  875. }
  876. }
  877. ";
  878. }
  879. /**
  880. * Adds the joinFk method for this object.
  881. * @param string &$script The script will be modified in this method.
  882. */
  883. protected function addJoinFk(&$script, $fk)
  884. {
  885. $table = $this->getTable();
  886. $queryClass = $this->getStubQueryBuilder()->getClassname();
  887. $fkTable = $this->getForeignTable($fk);
  888. $relationName = $this->getFKPhpNameAffix($fk);
  889. $joinType = $this->getJoinType($fk);
  890. $this->addJoinRelated($script, $fkTable, $queryClass, $relationName, $joinType);
  891. }
  892. /**
  893. * Adds the joinRefFk method for this object.
  894. * @param string &$script The script will be modified in this method.
  895. */
  896. protected function addJoinRefFk(&$script, $fk)
  897. {
  898. $table = $this->getTable();
  899. $queryClass = $this->getStubQueryBuilder()->getClassname();
  900. $fkTable = $this->getTable()->getDatabase()->getTable($fk->getTableName());
  901. $relationName = $this->getRefFKPhpNameAffix($fk);
  902. $joinType = $this->getJoinType($fk);
  903. $this->addJoinRelated($script, $fkTable, $queryClass, $relationName, $joinType);
  904. }
  905. /**
  906. * Adds a joinRelated method for this object.
  907. * @param string &$script The script will be modified in this method.
  908. */
  909. protected function addJoinRelated(&$script, $fkTable, $queryClass, $relationName, $joinType)
  910. {
  911. $script .= "
  912. /**
  913. * Adds a JOIN clause to the query using the " . $relationName . " relation
  914. *
  915. * @param string \$relationAlias optional alias for the relation
  916. * @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'
  917. *
  918. * @return ". $queryClass . " The current query, for fluid interface
  919. */
  920. public function join" . $relationName . "(\$relationAlias = null, \$joinType = " . $joinType . ")
  921. {
  922. \$tableMap = \$this->getTableMap();
  923. \$relationMap = \$tableMap->getRelation('" . $relationName . "');
  924. // create a ModelJoin object for this join
  925. \$join = new ModelJoin();
  926. \$join->setJoinType(\$joinType);
  927. \$join->setRelationMap(\$relationMap, \$this->useAliasInSQL ? \$this->getModelAlias() : null, \$relationAlias);
  928. if (\$previousJoin = \$this->getPreviousJoin()) {
  929. \$join->setPreviousJoin(\$previousJoin);
  930. }
  931. // add the ModelJoin to the current object
  932. if(\$relationAlias) {
  933. \$this->addAlias(\$relationAlias, \$relationMap->getRightTable()->getName());
  934. \$this->addJoinObject(\$join, \$relationAlias);
  935. } else {
  936. \$this->addJoinObject(\$join, '" . $relationName . "');
  937. }
  938. return \$this;
  939. }
  940. ";
  941. }
  942. /**
  943. * Adds the useFkQuery method for this object.
  944. * @param string &$script The script will be modified in this method.
  945. */
  946. protected function addUseFkQuery(&$script, $fk)
  947. {
  948. $table = $this->getTable();
  949. $fkTable = $this->getForeignTable($fk);
  950. $fkQueryBuilder = $this->getNewStubQueryBuilder($fkTable);
  951. $queryClass = $fkQueryBuilder->getClassname();
  952. if ($namespace = $fkQueryBuilder->getNamespace()) {
  953. $queryClass = '\\' . $namespace . '\\' . $queryClass;
  954. }
  955. $relationName = $this->getFKPhpNameAffix($fk);
  956. $joinType = $this->getJoinType($fk);
  957. $this->addUseRelatedQuery($script, $fkTable, $queryClass, $relationName, $joinType);
  958. }
  959. /**
  960. * Adds the useFkQuery method for this object.
  961. * @param string &$script The script will be modified in this method.
  962. */
  963. protected function addUseRefFkQuery(&$script, $fk)
  964. {
  965. $table = $this->getTable();
  966. $fkTable = $this->getTable()->getDatabase()->getTable($fk->getTableName());
  967. $fkQueryBuilder = $this->getNewStubQueryBuilder($fkTable);
  968. $queryClass = $fkQueryBuilder->getClassname();
  969. if ($namespace = $fkQueryBuilder->getNamespace()) {
  970. $queryClass = '\\' . $namespace . '\\' . $queryClass;
  971. }
  972. $relationName = $this->getRefFKPhpNameAffix($fk);
  973. $joinType = $this->getJoinType($fk);
  974. $this->addUseRelatedQuery($script, $fkTable, $queryClass, $relationName, $joinType);
  975. }
  976. /**
  977. * Adds a useRelatedQuery method for this object.
  978. * @param string &$script The script will be modified in this method.
  979. */
  980. protected function addUseRelatedQuery(&$script, $fkTable, $queryClass, $relationName, $joinType)
  981. {
  982. $script .= "
  983. /**
  984. * Use the $relationName relation " . $fkTable->getPhpName() . " object
  985. *
  986. * @see useQuery()
  987. *
  988. * @param string \$relationAlias optional alias for the relation,
  989. * to be used as main alias in the secondary query
  990. * @param string \$joinType Accepted values are null, 'left join', 'right join', 'inner join'
  991. *
  992. * @return $queryClass A secondary query class using the current class as primary query
  993. */
  994. public function use" . $relationName . "Query(\$relationAlias = null, \$joinType = " . $joinType . ")
  995. {
  996. return \$this
  997. ->join" . $relationName . "(\$relationAlias, \$joinType)
  998. ->useQuery(\$relationAlias ? \$relationAlias : '$relationName', '$queryClass');
  999. }
  1000. ";
  1001. }
  1002. protected function addFilterByCrossFK(&$script, $refFK, $crossFK)
  1003. {
  1004. $queryClass = $this->getStubQueryBuilder()->getClassname();
  1005. $crossRefTable = $crossFK->getTable();
  1006. $foreignTable = $crossFK->getForeignTable();
  1007. $fkPhpName = $foreignTable->getPhpName();
  1008. $crossTableName = $crossRefTable->getName();
  1009. $relName = $this->getFKPhpNameAffix($crossFK, $plural = false);
  1010. $objectName = '$' . $foreignTable->getStudlyPhpName();
  1011. $relationName = $this->getRefFKPhpNameAffix($refFK, $plural = false);
  1012. $script .= "
  1013. /**
  1014. * Filter the query by a related $fkPhpName object
  1015. * using the $crossTableName table as cross reference
  1016. *
  1017. * @param $fkPhpName $objectName the related object to use as filter
  1018. * @param string \$comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  1019. *
  1020. * @return $queryClass The current query, for fluid interface
  1021. */
  1022. public function filterBy{$relName}($objectName, \$comparison = Criteria::EQUAL)
  1023. {
  1024. return \$this
  1025. ->use{$relationName}Query()
  1026. ->filterBy{$relName}($objectName, \$comparison)
  1027. ->endUse();
  1028. }
  1029. ";
  1030. }
  1031. /**
  1032. * Adds the prune method for this object.
  1033. * @param string &$script The script will be modified in this method.
  1034. */
  1035. protected function addPrune(&$script)
  1036. {
  1037. $table = $this->getTable();
  1038. $class = $this->getStubObjectBuilder()->getClassname();
  1039. $objectName = '$' . $table->getStudlyPhpName();
  1040. $script .= "
  1041. /**
  1042. * Exclude object from result
  1043. *
  1044. * @param $class $objectName Object to remove from the list of results
  1045. *
  1046. * @return " . $this->getStubQueryBuilder()->getClassname() . " The current query, for fluid interface
  1047. */
  1048. public function prune($objectName = null)
  1049. {
  1050. if ($objectName) {";
  1051. $pks = $table->getPrimaryKey();
  1052. if (count($pks) > 1) {
  1053. $i = 0;
  1054. $conditions = array();
  1055. foreach ($pks as $col) {
  1056. $const = $this->getColumnConstant($col);
  1057. $condName = "'pruneCond" . $i . "'";
  1058. $conditions[]= $condName;
  1059. $script .= "
  1060. \$this->addCond(". $condName . ", \$this->getAliasedColName($const), " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);";
  1061. $i++;
  1062. }
  1063. $conditionsString = implode(', ', $conditions);
  1064. $script .= "
  1065. \$this->combine(array(" . $conditionsString . "), Criteria::LOGICAL_OR);";
  1066. } else {
  1067. $col = $pks[0];
  1068. $const = $this->getColumnConstant($col);
  1069. $script .= "
  1070. \$this->addUsingAlias($const, " . $objectName . "->get" . $col->getPhpName() . "(), Criteria::NOT_EQUAL);";
  1071. }
  1072. $script .= "
  1073. }
  1074. return \$this;
  1075. }
  1076. ";
  1077. }
  1078. /**
  1079. * Adds the basePreSelect hook for this object.
  1080. * @param string &$script The script will be modified in this method.
  1081. */
  1082. protected function addBasePreSelect(&$script)
  1083. {
  1084. $behaviorCode = '';
  1085. $this->applyBehaviorModifier('preSelectQuery', $behaviorCode, " ");
  1086. if (!$behaviorCode) {
  1087. return;
  1088. }
  1089. $script .= "
  1090. /**
  1091. * Code to execute before every SELECT statement
  1092. *
  1093. * @param PropelPDO \$con The connection object used by the query
  1094. */
  1095. protected function basePreSelect(PropelPDO \$con)
  1096. {" . $behaviorCode . "
  1097. return \$this->preSelect(\$con);
  1098. }
  1099. ";
  1100. }
  1101. /**
  1102. * Adds the basePreDelete hook for this object.
  1103. * @param string &$script The script will be modified in this method.
  1104. */
  1105. protected function addBasePreDelete(&$script)
  1106. {
  1107. $behaviorCode = '';
  1108. $this->applyBehaviorModifier('preDeleteQuery', $behaviorCode, " ");
  1109. if (!$behaviorCode) {
  1110. return;
  1111. }
  1112. $script .= "
  1113. /**
  1114. * Code to execute before every DELETE statement
  1115. *
  1116. * @param PropelPDO \$con The connection object used by the query
  1117. */
  1118. protected function basePreDelete(PropelPDO \$con)
  1119. {" . $behaviorCode . "
  1120. return \$this->preDelete(\$con);
  1121. }
  1122. ";
  1123. }
  1124. /**
  1125. * Adds the basePostDelete hook for this object.
  1126. * @param string &$script The script will be modified in this method.
  1127. */
  1128. protected function addBasePostDelete(&$script)
  1129. {
  1130. $behaviorCode = '';
  1131. $this->applyBehaviorModifier('postDeleteQuery', $behaviorCode, " ");
  1132. if (!$behaviorCode) {
  1133. return;
  1134. }
  1135. $script .= "
  1136. /**
  1137. * Code to execute after every DELETE statement
  1138. *
  1139. * @param int \$affectedRows the number of deleted rows
  1140. * @param PropelPDO \$con The connection object used by the query
  1141. */
  1142. protected function basePostDelete(\$affectedRows, PropelPDO \$con)
  1143. {" . $behaviorCode . "
  1144. return \$this->postDelete(\$affectedRows, \$con);
  1145. }
  1146. ";
  1147. }
  1148. /**
  1149. * Adds the basePreUpdate hook for this object.
  1150. * @param string &$script The script will be modified in this method.
  1151. */
  1152. protected function addBasePreUpdate(&$script)
  1153. {
  1154. $behaviorCode = '';
  1155. $this->applyBehaviorModifier('preUpdateQuery', $behaviorCode, " ");
  1156. if (!$behaviorCode) {
  1157. return;
  1158. }
  1159. $script .= "
  1160. /**
  1161. * Code to execute before every UPDATE statement
  1162. *
  1163. * @param array \$values The associatiove array of columns and values for the update
  1164. * @param PropelPDO \$con The connection object used by the query
  1165. * @param boolean \$forceIndividualSaves If false (default), the resulting call is a BasePeer::doUpdate(), ortherwise it is a series of save() calls on all the found objects
  1166. */
  1167. protected function basePreUpdate(&\$values, PropelPDO \$con, \$forceIndividualSaves = false)
  1168. {" . $behaviorCode . "
  1169. return \$this->preUpdate(\$values, \$con, \$forceIndividualSaves);
  1170. }
  1171. ";
  1172. }
  1173. /**
  1174. * Adds the basePostUpdate hook for this object.
  1175. * @param string &$script The script will be modified in this method.
  1176. */
  1177. protected function addBasePostUpdate(&$script)
  1178. {
  1179. $behaviorCode = '';
  1180. $this->applyBehaviorModifier('postUpdateQuery', $behaviorCode, " ");
  1181. if (!$behaviorCode) {
  1182. return;
  1183. }
  1184. $script .= "
  1185. /**
  1186. * Code to execute after every UPDATE statement
  1187. *
  1188. * @param int \$affectedRows the number of udated rows
  1189. * @param PropelPDO \$con The connection object used by the query
  1190. */
  1191. protected function basePostUpdate(\$affectedRows, PropelPDO \$con)
  1192. {" . $behaviorCode . "
  1193. return \$this->postUpdate(\$affectedRows, \$con);
  1194. }
  1195. ";
  1196. }
  1197. /**
  1198. * Checks whether any registered behavior on that table has a modifier for a hook
  1199. * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
  1200. * @return boolean
  1201. */
  1202. public function hasBehaviorModifier($hookName, $modifier = null)
  1203. {
  1204. return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier');
  1205. }
  1206. /**
  1207. * Checks whether any registered behavior on that table has a modifier for a hook
  1208. * @param string $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
  1209. * @param string &$script The script will be modified in this method.
  1210. */
  1211. public function applyBehaviorModifier($hookName, &$script, $tab = " ")
  1212. {
  1213. return $this->applyBehaviorModifierBase($hookName, 'QueryBuilderModifier', $script, $tab);
  1214. }
  1215. /**
  1216. * Checks whether any registered behavior content creator on that table exists a contentName
  1217. * @param string $contentName The name of the content as called from one of this class methods, e.g. "parentClassname"
  1218. */
  1219. public function getBehaviorContent($contentName)
  1220. {
  1221. return $this->getBehaviorContentBase($contentName, 'QueryBuilderModifier');
  1222. }
  1223. }