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