1: <?php
2:
3: namespace cli_db\propel\om;
4:
5: use \Criteria;
6: use \Exception;
7: use \ModelCriteria;
8: use \ModelJoin;
9: use \PDO;
10: use \Propel;
11: use \PropelCollection;
12: use \PropelException;
13: use \PropelObjectCollection;
14: use \PropelPDO;
15: use cli_db\propel\Pub;
16: use cli_db\propel\Pubauthor;
17: use cli_db\propel\PubauthorPeer;
18: use cli_db\propel\PubauthorQuery;
19:
20: /**
21: * Base class that represents a query for the 'pubauthor' table.
22: *
23: *
24: *
25: * @method PubauthorQuery orderByPubauthorId($order = Criteria::ASC) Order by the pubauthor_id column
26: * @method PubauthorQuery orderByPubId($order = Criteria::ASC) Order by the pub_id column
27: * @method PubauthorQuery orderByRank($order = Criteria::ASC) Order by the rank column
28: * @method PubauthorQuery orderByEditor($order = Criteria::ASC) Order by the editor column
29: * @method PubauthorQuery orderBySurname($order = Criteria::ASC) Order by the surname column
30: * @method PubauthorQuery orderByGivennames($order = Criteria::ASC) Order by the givennames column
31: * @method PubauthorQuery orderBySuffix($order = Criteria::ASC) Order by the suffix column
32: *
33: * @method PubauthorQuery groupByPubauthorId() Group by the pubauthor_id column
34: * @method PubauthorQuery groupByPubId() Group by the pub_id column
35: * @method PubauthorQuery groupByRank() Group by the rank column
36: * @method PubauthorQuery groupByEditor() Group by the editor column
37: * @method PubauthorQuery groupBySurname() Group by the surname column
38: * @method PubauthorQuery groupByGivennames() Group by the givennames column
39: * @method PubauthorQuery groupBySuffix() Group by the suffix column
40: *
41: * @method PubauthorQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
42: * @method PubauthorQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
43: * @method PubauthorQuery innerJoin($relation) Adds a INNER JOIN clause to the query
44: *
45: * @method PubauthorQuery leftJoinPub($relationAlias = null) Adds a LEFT JOIN clause to the query using the Pub relation
46: * @method PubauthorQuery rightJoinPub($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Pub relation
47: * @method PubauthorQuery innerJoinPub($relationAlias = null) Adds a INNER JOIN clause to the query using the Pub relation
48: *
49: * @method Pubauthor findOne(PropelPDO $con = null) Return the first Pubauthor matching the query
50: * @method Pubauthor findOneOrCreate(PropelPDO $con = null) Return the first Pubauthor matching the query, or a new Pubauthor object populated from the query conditions when no match is found
51: *
52: * @method Pubauthor findOneByPubId(int $pub_id) Return the first Pubauthor filtered by the pub_id column
53: * @method Pubauthor findOneByRank(int $rank) Return the first Pubauthor filtered by the rank column
54: * @method Pubauthor findOneByEditor(boolean $editor) Return the first Pubauthor filtered by the editor column
55: * @method Pubauthor findOneBySurname(string $surname) Return the first Pubauthor filtered by the surname column
56: * @method Pubauthor findOneByGivennames(string $givennames) Return the first Pubauthor filtered by the givennames column
57: * @method Pubauthor findOneBySuffix(string $suffix) Return the first Pubauthor filtered by the suffix column
58: *
59: * @method array findByPubauthorId(int $pubauthor_id) Return Pubauthor objects filtered by the pubauthor_id column
60: * @method array findByPubId(int $pub_id) Return Pubauthor objects filtered by the pub_id column
61: * @method array findByRank(int $rank) Return Pubauthor objects filtered by the rank column
62: * @method array findByEditor(boolean $editor) Return Pubauthor objects filtered by the editor column
63: * @method array findBySurname(string $surname) Return Pubauthor objects filtered by the surname column
64: * @method array findByGivennames(string $givennames) Return Pubauthor objects filtered by the givennames column
65: * @method array findBySuffix(string $suffix) Return Pubauthor objects filtered by the suffix column
66: *
67: * @package propel.generator.cli_db.om
68: */
69: abstract class BasePubauthorQuery extends ModelCriteria
70: {
71: /**
72: * Initializes internal state of BasePubauthorQuery object.
73: *
74: * @param string $dbName The dabase name
75: * @param string $modelName The phpName of a model, e.g. 'Book'
76: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
77: */
78: public function __construct($dbName = 'cli_db', $modelName = 'cli_db\\propel\\Pubauthor', $modelAlias = null)
79: {
80: parent::__construct($dbName, $modelName, $modelAlias);
81: }
82:
83: /**
84: * Returns a new PubauthorQuery object.
85: *
86: * @param string $modelAlias The alias of a model in the query
87: * @param PubauthorQuery|Criteria $criteria Optional Criteria to build the query from
88: *
89: * @return PubauthorQuery
90: */
91: public static function create($modelAlias = null, $criteria = null)
92: {
93: if ($criteria instanceof PubauthorQuery) {
94: return $criteria;
95: }
96: $query = new PubauthorQuery();
97: if (null !== $modelAlias) {
98: $query->setModelAlias($modelAlias);
99: }
100: if ($criteria instanceof Criteria) {
101: $query->mergeWith($criteria);
102: }
103:
104: return $query;
105: }
106:
107: /**
108: * Find object by primary key.
109: * Propel uses the instance pool to skip the database if the object exists.
110: * Go fast if the query is untouched.
111: *
112: * <code>
113: * $obj = $c->findPk(12, $con);
114: * </code>
115: *
116: * @param mixed $key Primary key to use for the query
117: * @param PropelPDO $con an optional connection object
118: *
119: * @return Pubauthor|Pubauthor[]|mixed the result, formatted by the current formatter
120: */
121: public function findPk($key, $con = null)
122: {
123: if ($key === null) {
124: return null;
125: }
126: if ((null !== ($obj = PubauthorPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
127: // the object is alredy in the instance pool
128: return $obj;
129: }
130: if ($con === null) {
131: $con = Propel::getConnection(PubauthorPeer::DATABASE_NAME, Propel::CONNECTION_READ);
132: }
133: $this->basePreSelect($con);
134: if ($this->formatter || $this->modelAlias || $this->with || $this->select
135: || $this->selectColumns || $this->asColumns || $this->selectModifiers
136: || $this->map || $this->having || $this->joins) {
137: return $this->findPkComplex($key, $con);
138: } else {
139: return $this->findPkSimple($key, $con);
140: }
141: }
142:
143: /**
144: * Alias of findPk to use instance pooling
145: *
146: * @param mixed $key Primary key to use for the query
147: * @param PropelPDO $con A connection object
148: *
149: * @return Pubauthor A model object, or null if the key is not found
150: * @throws PropelException
151: */
152: public function findOneByPubauthorId($key, $con = null)
153: {
154: return $this->findPk($key, $con);
155: }
156:
157: /**
158: * Find object by primary key using raw SQL to go fast.
159: * Bypass doSelect() and the object formatter by using generated code.
160: *
161: * @param mixed $key Primary key to use for the query
162: * @param PropelPDO $con A connection object
163: *
164: * @return Pubauthor A model object, or null if the key is not found
165: * @throws PropelException
166: */
167: protected function findPkSimple($key, $con)
168: {
169: $sql = 'SELECT "pubauthor_id", "pub_id", "rank", "editor", "surname", "givennames", "suffix" FROM "pubauthor" WHERE "pubauthor_id" = :p0';
170: try {
171: $stmt = $con->prepare($sql);
172: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
173: $stmt->execute();
174: } catch (Exception $e) {
175: Propel::log($e->getMessage(), Propel::LOG_ERR);
176: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
177: }
178: $obj = null;
179: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
180: $obj = new Pubauthor();
181: $obj->hydrate($row);
182: PubauthorPeer::addInstanceToPool($obj, (string) $key);
183: }
184: $stmt->closeCursor();
185:
186: return $obj;
187: }
188:
189: /**
190: * Find object by primary key.
191: *
192: * @param mixed $key Primary key to use for the query
193: * @param PropelPDO $con A connection object
194: *
195: * @return Pubauthor|Pubauthor[]|mixed the result, formatted by the current formatter
196: */
197: protected function findPkComplex($key, $con)
198: {
199: // As the query uses a PK condition, no limit(1) is necessary.
200: $criteria = $this->isKeepQuery() ? clone $this : $this;
201: $stmt = $criteria
202: ->filterByPrimaryKey($key)
203: ->doSelect($con);
204:
205: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
206: }
207:
208: /**
209: * Find objects by primary key
210: * <code>
211: * $objs = $c->findPks(array(12, 56, 832), $con);
212: * </code>
213: * @param array $keys Primary keys to use for the query
214: * @param PropelPDO $con an optional connection object
215: *
216: * @return PropelObjectCollection|Pubauthor[]|mixed the list of results, formatted by the current formatter
217: */
218: public function findPks($keys, $con = null)
219: {
220: if ($con === null) {
221: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
222: }
223: $this->basePreSelect($con);
224: $criteria = $this->isKeepQuery() ? clone $this : $this;
225: $stmt = $criteria
226: ->filterByPrimaryKeys($keys)
227: ->doSelect($con);
228:
229: return $criteria->getFormatter()->init($criteria)->format($stmt);
230: }
231:
232: /**
233: * Filter the query by primary key
234: *
235: * @param mixed $key Primary key to use for the query
236: *
237: * @return PubauthorQuery The current query, for fluid interface
238: */
239: public function filterByPrimaryKey($key)
240: {
241:
242: return $this->addUsingAlias(PubauthorPeer::PUBAUTHOR_ID, $key, Criteria::EQUAL);
243: }
244:
245: /**
246: * Filter the query by a list of primary keys
247: *
248: * @param array $keys The list of primary key to use for the query
249: *
250: * @return PubauthorQuery The current query, for fluid interface
251: */
252: public function filterByPrimaryKeys($keys)
253: {
254:
255: return $this->addUsingAlias(PubauthorPeer::PUBAUTHOR_ID, $keys, Criteria::IN);
256: }
257:
258: /**
259: * Filter the query on the pubauthor_id column
260: *
261: * Example usage:
262: * <code>
263: * $query->filterByPubauthorId(1234); // WHERE pubauthor_id = 1234
264: * $query->filterByPubauthorId(array(12, 34)); // WHERE pubauthor_id IN (12, 34)
265: * $query->filterByPubauthorId(array('min' => 12)); // WHERE pubauthor_id >= 12
266: * $query->filterByPubauthorId(array('max' => 12)); // WHERE pubauthor_id <= 12
267: * </code>
268: *
269: * @param mixed $pubauthorId The value to use as filter.
270: * Use scalar values for equality.
271: * Use array values for in_array() equivalent.
272: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
273: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
274: *
275: * @return PubauthorQuery The current query, for fluid interface
276: */
277: public function filterByPubauthorId($pubauthorId = null, $comparison = null)
278: {
279: if (is_array($pubauthorId)) {
280: $useMinMax = false;
281: if (isset($pubauthorId['min'])) {
282: $this->addUsingAlias(PubauthorPeer::PUBAUTHOR_ID, $pubauthorId['min'], Criteria::GREATER_EQUAL);
283: $useMinMax = true;
284: }
285: if (isset($pubauthorId['max'])) {
286: $this->addUsingAlias(PubauthorPeer::PUBAUTHOR_ID, $pubauthorId['max'], Criteria::LESS_EQUAL);
287: $useMinMax = true;
288: }
289: if ($useMinMax) {
290: return $this;
291: }
292: if (null === $comparison) {
293: $comparison = Criteria::IN;
294: }
295: }
296:
297: return $this->addUsingAlias(PubauthorPeer::PUBAUTHOR_ID, $pubauthorId, $comparison);
298: }
299:
300: /**
301: * Filter the query on the pub_id column
302: *
303: * Example usage:
304: * <code>
305: * $query->filterByPubId(1234); // WHERE pub_id = 1234
306: * $query->filterByPubId(array(12, 34)); // WHERE pub_id IN (12, 34)
307: * $query->filterByPubId(array('min' => 12)); // WHERE pub_id >= 12
308: * $query->filterByPubId(array('max' => 12)); // WHERE pub_id <= 12
309: * </code>
310: *
311: * @see filterByPub()
312: *
313: * @param mixed $pubId The value to use as filter.
314: * Use scalar values for equality.
315: * Use array values for in_array() equivalent.
316: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
317: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
318: *
319: * @return PubauthorQuery The current query, for fluid interface
320: */
321: public function filterByPubId($pubId = null, $comparison = null)
322: {
323: if (is_array($pubId)) {
324: $useMinMax = false;
325: if (isset($pubId['min'])) {
326: $this->addUsingAlias(PubauthorPeer::PUB_ID, $pubId['min'], Criteria::GREATER_EQUAL);
327: $useMinMax = true;
328: }
329: if (isset($pubId['max'])) {
330: $this->addUsingAlias(PubauthorPeer::PUB_ID, $pubId['max'], Criteria::LESS_EQUAL);
331: $useMinMax = true;
332: }
333: if ($useMinMax) {
334: return $this;
335: }
336: if (null === $comparison) {
337: $comparison = Criteria::IN;
338: }
339: }
340:
341: return $this->addUsingAlias(PubauthorPeer::PUB_ID, $pubId, $comparison);
342: }
343:
344: /**
345: * Filter the query on the rank column
346: *
347: * Example usage:
348: * <code>
349: * $query->filterByRank(1234); // WHERE rank = 1234
350: * $query->filterByRank(array(12, 34)); // WHERE rank IN (12, 34)
351: * $query->filterByRank(array('min' => 12)); // WHERE rank >= 12
352: * $query->filterByRank(array('max' => 12)); // WHERE rank <= 12
353: * </code>
354: *
355: * @param mixed $rank The value to use as filter.
356: * Use scalar values for equality.
357: * Use array values for in_array() equivalent.
358: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
359: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
360: *
361: * @return PubauthorQuery The current query, for fluid interface
362: */
363: public function filterByRank($rank = null, $comparison = null)
364: {
365: if (is_array($rank)) {
366: $useMinMax = false;
367: if (isset($rank['min'])) {
368: $this->addUsingAlias(PubauthorPeer::RANK, $rank['min'], Criteria::GREATER_EQUAL);
369: $useMinMax = true;
370: }
371: if (isset($rank['max'])) {
372: $this->addUsingAlias(PubauthorPeer::RANK, $rank['max'], Criteria::LESS_EQUAL);
373: $useMinMax = true;
374: }
375: if ($useMinMax) {
376: return $this;
377: }
378: if (null === $comparison) {
379: $comparison = Criteria::IN;
380: }
381: }
382:
383: return $this->addUsingAlias(PubauthorPeer::RANK, $rank, $comparison);
384: }
385:
386: /**
387: * Filter the query on the editor column
388: *
389: * Example usage:
390: * <code>
391: * $query->filterByEditor(true); // WHERE editor = true
392: * $query->filterByEditor('yes'); // WHERE editor = true
393: * </code>
394: *
395: * @param boolean|string $editor The value to use as filter.
396: * Non-boolean arguments are converted using the following rules:
397: * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
398: * * 0, '0', 'false', 'off', and 'no' are converted to boolean false
399: * Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
400: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
401: *
402: * @return PubauthorQuery The current query, for fluid interface
403: */
404: public function filterByEditor($editor = null, $comparison = null)
405: {
406: if (is_string($editor)) {
407: $editor = in_array(strtolower($editor), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
408: }
409:
410: return $this->addUsingAlias(PubauthorPeer::EDITOR, $editor, $comparison);
411: }
412:
413: /**
414: * Filter the query on the surname column
415: *
416: * Example usage:
417: * <code>
418: * $query->filterBySurname('fooValue'); // WHERE surname = 'fooValue'
419: * $query->filterBySurname('%fooValue%'); // WHERE surname LIKE '%fooValue%'
420: * </code>
421: *
422: * @param string $surname The value to use as filter.
423: * Accepts wildcards (* and % trigger a LIKE)
424: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
425: *
426: * @return PubauthorQuery The current query, for fluid interface
427: */
428: public function filterBySurname($surname = null, $comparison = null)
429: {
430: if (null === $comparison) {
431: if (is_array($surname)) {
432: $comparison = Criteria::IN;
433: } elseif (preg_match('/[\%\*]/', $surname)) {
434: $surname = str_replace('*', '%', $surname);
435: $comparison = Criteria::LIKE;
436: }
437: }
438:
439: return $this->addUsingAlias(PubauthorPeer::SURNAME, $surname, $comparison);
440: }
441:
442: /**
443: * Filter the query on the givennames column
444: *
445: * Example usage:
446: * <code>
447: * $query->filterByGivennames('fooValue'); // WHERE givennames = 'fooValue'
448: * $query->filterByGivennames('%fooValue%'); // WHERE givennames LIKE '%fooValue%'
449: * </code>
450: *
451: * @param string $givennames The value to use as filter.
452: * Accepts wildcards (* and % trigger a LIKE)
453: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
454: *
455: * @return PubauthorQuery The current query, for fluid interface
456: */
457: public function filterByGivennames($givennames = null, $comparison = null)
458: {
459: if (null === $comparison) {
460: if (is_array($givennames)) {
461: $comparison = Criteria::IN;
462: } elseif (preg_match('/[\%\*]/', $givennames)) {
463: $givennames = str_replace('*', '%', $givennames);
464: $comparison = Criteria::LIKE;
465: }
466: }
467:
468: return $this->addUsingAlias(PubauthorPeer::GIVENNAMES, $givennames, $comparison);
469: }
470:
471: /**
472: * Filter the query on the suffix column
473: *
474: * Example usage:
475: * <code>
476: * $query->filterBySuffix('fooValue'); // WHERE suffix = 'fooValue'
477: * $query->filterBySuffix('%fooValue%'); // WHERE suffix LIKE '%fooValue%'
478: * </code>
479: *
480: * @param string $suffix The value to use as filter.
481: * Accepts wildcards (* and % trigger a LIKE)
482: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
483: *
484: * @return PubauthorQuery The current query, for fluid interface
485: */
486: public function filterBySuffix($suffix = null, $comparison = null)
487: {
488: if (null === $comparison) {
489: if (is_array($suffix)) {
490: $comparison = Criteria::IN;
491: } elseif (preg_match('/[\%\*]/', $suffix)) {
492: $suffix = str_replace('*', '%', $suffix);
493: $comparison = Criteria::LIKE;
494: }
495: }
496:
497: return $this->addUsingAlias(PubauthorPeer::SUFFIX, $suffix, $comparison);
498: }
499:
500: /**
501: * Filter the query by a related Pub object
502: *
503: * @param Pub|PropelObjectCollection $pub The related object(s) to use as filter
504: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
505: *
506: * @return PubauthorQuery The current query, for fluid interface
507: * @throws PropelException - if the provided filter is invalid.
508: */
509: public function filterByPub($pub, $comparison = null)
510: {
511: if ($pub instanceof Pub) {
512: return $this
513: ->addUsingAlias(PubauthorPeer::PUB_ID, $pub->getPubId(), $comparison);
514: } elseif ($pub instanceof PropelObjectCollection) {
515: if (null === $comparison) {
516: $comparison = Criteria::IN;
517: }
518:
519: return $this
520: ->addUsingAlias(PubauthorPeer::PUB_ID, $pub->toKeyValue('PrimaryKey', 'PubId'), $comparison);
521: } else {
522: throw new PropelException('filterByPub() only accepts arguments of type Pub or PropelCollection');
523: }
524: }
525:
526: /**
527: * Adds a JOIN clause to the query using the Pub relation
528: *
529: * @param string $relationAlias optional alias for the relation
530: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
531: *
532: * @return PubauthorQuery The current query, for fluid interface
533: */
534: public function joinPub($relationAlias = null, $joinType = Criteria::INNER_JOIN)
535: {
536: $tableMap = $this->getTableMap();
537: $relationMap = $tableMap->getRelation('Pub');
538:
539: // create a ModelJoin object for this join
540: $join = new ModelJoin();
541: $join->setJoinType($joinType);
542: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
543: if ($previousJoin = $this->getPreviousJoin()) {
544: $join->setPreviousJoin($previousJoin);
545: }
546:
547: // add the ModelJoin to the current object
548: if ($relationAlias) {
549: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
550: $this->addJoinObject($join, $relationAlias);
551: } else {
552: $this->addJoinObject($join, 'Pub');
553: }
554:
555: return $this;
556: }
557:
558: /**
559: * Use the Pub relation Pub object
560: *
561: * @see useQuery()
562: *
563: * @param string $relationAlias optional alias for the relation,
564: * to be used as main alias in the secondary query
565: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
566: *
567: * @return \cli_db\propel\PubQuery A secondary query class using the current class as primary query
568: */
569: public function usePubQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
570: {
571: return $this
572: ->joinPub($relationAlias, $joinType)
573: ->useQuery($relationAlias ? $relationAlias : 'Pub', '\cli_db\propel\PubQuery');
574: }
575:
576: /**
577: * Exclude object from result
578: *
579: * @param Pubauthor $pubauthor Object to remove from the list of results
580: *
581: * @return PubauthorQuery The current query, for fluid interface
582: */
583: public function prune($pubauthor = null)
584: {
585: if ($pubauthor) {
586: $this->addUsingAlias(PubauthorPeer::PUBAUTHOR_ID, $pubauthor->getPubauthorId(), Criteria::NOT_EQUAL);
587: }
588:
589: return $this;
590: }
591:
592: }
593: