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\Cvterm;
16: use cli_db\propel\FeatureSynonym;
17: use cli_db\propel\Synonym;
18: use cli_db\propel\SynonymPeer;
19: use cli_db\propel\SynonymQuery;
20:
21: /**
22: * Base class that represents a query for the 'synonym' table.
23: *
24: *
25: *
26: * @method SynonymQuery orderBySynonymId($order = Criteria::ASC) Order by the synonym_id column
27: * @method SynonymQuery orderByName($order = Criteria::ASC) Order by the name column
28: * @method SynonymQuery orderByTypeId($order = Criteria::ASC) Order by the type_id column
29: * @method SynonymQuery orderBySynonymSgml($order = Criteria::ASC) Order by the synonym_sgml column
30: *
31: * @method SynonymQuery groupBySynonymId() Group by the synonym_id column
32: * @method SynonymQuery groupByName() Group by the name column
33: * @method SynonymQuery groupByTypeId() Group by the type_id column
34: * @method SynonymQuery groupBySynonymSgml() Group by the synonym_sgml column
35: *
36: * @method SynonymQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
37: * @method SynonymQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
38: * @method SynonymQuery innerJoin($relation) Adds a INNER JOIN clause to the query
39: *
40: * @method SynonymQuery leftJoinCvterm($relationAlias = null) Adds a LEFT JOIN clause to the query using the Cvterm relation
41: * @method SynonymQuery rightJoinCvterm($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cvterm relation
42: * @method SynonymQuery innerJoinCvterm($relationAlias = null) Adds a INNER JOIN clause to the query using the Cvterm relation
43: *
44: * @method SynonymQuery leftJoinFeatureSynonym($relationAlias = null) Adds a LEFT JOIN clause to the query using the FeatureSynonym relation
45: * @method SynonymQuery rightJoinFeatureSynonym($relationAlias = null) Adds a RIGHT JOIN clause to the query using the FeatureSynonym relation
46: * @method SynonymQuery innerJoinFeatureSynonym($relationAlias = null) Adds a INNER JOIN clause to the query using the FeatureSynonym relation
47: *
48: * @method Synonym findOne(PropelPDO $con = null) Return the first Synonym matching the query
49: * @method Synonym findOneOrCreate(PropelPDO $con = null) Return the first Synonym matching the query, or a new Synonym object populated from the query conditions when no match is found
50: *
51: * @method Synonym findOneByName(string $name) Return the first Synonym filtered by the name column
52: * @method Synonym findOneByTypeId(int $type_id) Return the first Synonym filtered by the type_id column
53: * @method Synonym findOneBySynonymSgml(string $synonym_sgml) Return the first Synonym filtered by the synonym_sgml column
54: *
55: * @method array findBySynonymId(int $synonym_id) Return Synonym objects filtered by the synonym_id column
56: * @method array findByName(string $name) Return Synonym objects filtered by the name column
57: * @method array findByTypeId(int $type_id) Return Synonym objects filtered by the type_id column
58: * @method array findBySynonymSgml(string $synonym_sgml) Return Synonym objects filtered by the synonym_sgml column
59: *
60: * @package propel.generator.cli_db.om
61: */
62: abstract class BaseSynonymQuery extends ModelCriteria
63: {
64: /**
65: * Initializes internal state of BaseSynonymQuery 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\\Synonym', $modelAlias = null)
72: {
73: parent::__construct($dbName, $modelName, $modelAlias);
74: }
75:
76: /**
77: * Returns a new SynonymQuery object.
78: *
79: * @param string $modelAlias The alias of a model in the query
80: * @param SynonymQuery|Criteria $criteria Optional Criteria to build the query from
81: *
82: * @return SynonymQuery
83: */
84: public static function create($modelAlias = null, $criteria = null)
85: {
86: if ($criteria instanceof SynonymQuery) {
87: return $criteria;
88: }
89: $query = new SynonymQuery();
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 Synonym|Synonym[]|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 = SynonymPeer::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(SynonymPeer::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 Synonym A model object, or null if the key is not found
143: * @throws PropelException
144: */
145: public function findOneBySynonymId($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 Synonym 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 "synonym_id", "name", "type_id", "synonym_sgml" FROM "synonym" WHERE "synonym_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 Synonym();
174: $obj->hydrate($row);
175: SynonymPeer::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 Synonym|Synonym[]|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|Synonym[]|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 SynonymQuery The current query, for fluid interface
231: */
232: public function filterByPrimaryKey($key)
233: {
234:
235: return $this->addUsingAlias(SynonymPeer::SYNONYM_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 SynonymQuery The current query, for fluid interface
244: */
245: public function filterByPrimaryKeys($keys)
246: {
247:
248: return $this->addUsingAlias(SynonymPeer::SYNONYM_ID, $keys, Criteria::IN);
249: }
250:
251: /**
252: * Filter the query on the synonym_id column
253: *
254: * Example usage:
255: * <code>
256: * $query->filterBySynonymId(1234); // WHERE synonym_id = 1234
257: * $query->filterBySynonymId(array(12, 34)); // WHERE synonym_id IN (12, 34)
258: * $query->filterBySynonymId(array('min' => 12)); // WHERE synonym_id >= 12
259: * $query->filterBySynonymId(array('max' => 12)); // WHERE synonym_id <= 12
260: * </code>
261: *
262: * @param mixed $synonymId 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 SynonymQuery The current query, for fluid interface
269: */
270: public function filterBySynonymId($synonymId = null, $comparison = null)
271: {
272: if (is_array($synonymId)) {
273: $useMinMax = false;
274: if (isset($synonymId['min'])) {
275: $this->addUsingAlias(SynonymPeer::SYNONYM_ID, $synonymId['min'], Criteria::GREATER_EQUAL);
276: $useMinMax = true;
277: }
278: if (isset($synonymId['max'])) {
279: $this->addUsingAlias(SynonymPeer::SYNONYM_ID, $synonymId['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(SynonymPeer::SYNONYM_ID, $synonymId, $comparison);
291: }
292:
293: /**
294: * Filter the query on the name column
295: *
296: * Example usage:
297: * <code>
298: * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
299: * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
300: * </code>
301: *
302: * @param string $name The value to use as filter.
303: * Accepts wildcards (* and % trigger a LIKE)
304: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
305: *
306: * @return SynonymQuery The current query, for fluid interface
307: */
308: public function filterByName($name = null, $comparison = null)
309: {
310: if (null === $comparison) {
311: if (is_array($name)) {
312: $comparison = Criteria::IN;
313: } elseif (preg_match('/[\%\*]/', $name)) {
314: $name = str_replace('*', '%', $name);
315: $comparison = Criteria::LIKE;
316: }
317: }
318:
319: return $this->addUsingAlias(SynonymPeer::NAME, $name, $comparison);
320: }
321:
322: /**
323: * Filter the query on the type_id column
324: *
325: * Example usage:
326: * <code>
327: * $query->filterByTypeId(1234); // WHERE type_id = 1234
328: * $query->filterByTypeId(array(12, 34)); // WHERE type_id IN (12, 34)
329: * $query->filterByTypeId(array('min' => 12)); // WHERE type_id >= 12
330: * $query->filterByTypeId(array('max' => 12)); // WHERE type_id <= 12
331: * </code>
332: *
333: * @see filterByCvterm()
334: *
335: * @param mixed $typeId The value to use as filter.
336: * Use scalar values for equality.
337: * Use array values for in_array() equivalent.
338: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
339: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
340: *
341: * @return SynonymQuery The current query, for fluid interface
342: */
343: public function filterByTypeId($typeId = null, $comparison = null)
344: {
345: if (is_array($typeId)) {
346: $useMinMax = false;
347: if (isset($typeId['min'])) {
348: $this->addUsingAlias(SynonymPeer::TYPE_ID, $typeId['min'], Criteria::GREATER_EQUAL);
349: $useMinMax = true;
350: }
351: if (isset($typeId['max'])) {
352: $this->addUsingAlias(SynonymPeer::TYPE_ID, $typeId['max'], Criteria::LESS_EQUAL);
353: $useMinMax = true;
354: }
355: if ($useMinMax) {
356: return $this;
357: }
358: if (null === $comparison) {
359: $comparison = Criteria::IN;
360: }
361: }
362:
363: return $this->addUsingAlias(SynonymPeer::TYPE_ID, $typeId, $comparison);
364: }
365:
366: /**
367: * Filter the query on the synonym_sgml column
368: *
369: * Example usage:
370: * <code>
371: * $query->filterBySynonymSgml('fooValue'); // WHERE synonym_sgml = 'fooValue'
372: * $query->filterBySynonymSgml('%fooValue%'); // WHERE synonym_sgml LIKE '%fooValue%'
373: * </code>
374: *
375: * @param string $synonymSgml The value to use as filter.
376: * Accepts wildcards (* and % trigger a LIKE)
377: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
378: *
379: * @return SynonymQuery The current query, for fluid interface
380: */
381: public function filterBySynonymSgml($synonymSgml = null, $comparison = null)
382: {
383: if (null === $comparison) {
384: if (is_array($synonymSgml)) {
385: $comparison = Criteria::IN;
386: } elseif (preg_match('/[\%\*]/', $synonymSgml)) {
387: $synonymSgml = str_replace('*', '%', $synonymSgml);
388: $comparison = Criteria::LIKE;
389: }
390: }
391:
392: return $this->addUsingAlias(SynonymPeer::SYNONYM_SGML, $synonymSgml, $comparison);
393: }
394:
395: /**
396: * Filter the query by a related Cvterm object
397: *
398: * @param Cvterm|PropelObjectCollection $cvterm The related object(s) to use as filter
399: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
400: *
401: * @return SynonymQuery The current query, for fluid interface
402: * @throws PropelException - if the provided filter is invalid.
403: */
404: public function filterByCvterm($cvterm, $comparison = null)
405: {
406: if ($cvterm instanceof Cvterm) {
407: return $this
408: ->addUsingAlias(SynonymPeer::TYPE_ID, $cvterm->getCvtermId(), $comparison);
409: } elseif ($cvterm instanceof PropelObjectCollection) {
410: if (null === $comparison) {
411: $comparison = Criteria::IN;
412: }
413:
414: return $this
415: ->addUsingAlias(SynonymPeer::TYPE_ID, $cvterm->toKeyValue('PrimaryKey', 'CvtermId'), $comparison);
416: } else {
417: throw new PropelException('filterByCvterm() only accepts arguments of type Cvterm or PropelCollection');
418: }
419: }
420:
421: /**
422: * Adds a JOIN clause to the query using the Cvterm relation
423: *
424: * @param string $relationAlias optional alias for the relation
425: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
426: *
427: * @return SynonymQuery The current query, for fluid interface
428: */
429: public function joinCvterm($relationAlias = null, $joinType = Criteria::INNER_JOIN)
430: {
431: $tableMap = $this->getTableMap();
432: $relationMap = $tableMap->getRelation('Cvterm');
433:
434: // create a ModelJoin object for this join
435: $join = new ModelJoin();
436: $join->setJoinType($joinType);
437: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
438: if ($previousJoin = $this->getPreviousJoin()) {
439: $join->setPreviousJoin($previousJoin);
440: }
441:
442: // add the ModelJoin to the current object
443: if ($relationAlias) {
444: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
445: $this->addJoinObject($join, $relationAlias);
446: } else {
447: $this->addJoinObject($join, 'Cvterm');
448: }
449:
450: return $this;
451: }
452:
453: /**
454: * Use the Cvterm relation Cvterm object
455: *
456: * @see useQuery()
457: *
458: * @param string $relationAlias optional alias for the relation,
459: * to be used as main alias in the secondary query
460: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
461: *
462: * @return \cli_db\propel\CvtermQuery A secondary query class using the current class as primary query
463: */
464: public function useCvtermQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
465: {
466: return $this
467: ->joinCvterm($relationAlias, $joinType)
468: ->useQuery($relationAlias ? $relationAlias : 'Cvterm', '\cli_db\propel\CvtermQuery');
469: }
470:
471: /**
472: * Filter the query by a related FeatureSynonym object
473: *
474: * @param FeatureSynonym|PropelObjectCollection $featureSynonym the related object to use as filter
475: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
476: *
477: * @return SynonymQuery The current query, for fluid interface
478: * @throws PropelException - if the provided filter is invalid.
479: */
480: public function filterByFeatureSynonym($featureSynonym, $comparison = null)
481: {
482: if ($featureSynonym instanceof FeatureSynonym) {
483: return $this
484: ->addUsingAlias(SynonymPeer::SYNONYM_ID, $featureSynonym->getSynonymId(), $comparison);
485: } elseif ($featureSynonym instanceof PropelObjectCollection) {
486: return $this
487: ->useFeatureSynonymQuery()
488: ->filterByPrimaryKeys($featureSynonym->getPrimaryKeys())
489: ->endUse();
490: } else {
491: throw new PropelException('filterByFeatureSynonym() only accepts arguments of type FeatureSynonym or PropelCollection');
492: }
493: }
494:
495: /**
496: * Adds a JOIN clause to the query using the FeatureSynonym relation
497: *
498: * @param string $relationAlias optional alias for the relation
499: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
500: *
501: * @return SynonymQuery The current query, for fluid interface
502: */
503: public function joinFeatureSynonym($relationAlias = null, $joinType = Criteria::INNER_JOIN)
504: {
505: $tableMap = $this->getTableMap();
506: $relationMap = $tableMap->getRelation('FeatureSynonym');
507:
508: // create a ModelJoin object for this join
509: $join = new ModelJoin();
510: $join->setJoinType($joinType);
511: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
512: if ($previousJoin = $this->getPreviousJoin()) {
513: $join->setPreviousJoin($previousJoin);
514: }
515:
516: // add the ModelJoin to the current object
517: if ($relationAlias) {
518: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
519: $this->addJoinObject($join, $relationAlias);
520: } else {
521: $this->addJoinObject($join, 'FeatureSynonym');
522: }
523:
524: return $this;
525: }
526:
527: /**
528: * Use the FeatureSynonym relation FeatureSynonym object
529: *
530: * @see useQuery()
531: *
532: * @param string $relationAlias optional alias for the relation,
533: * to be used as main alias in the secondary query
534: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
535: *
536: * @return \cli_db\propel\FeatureSynonymQuery A secondary query class using the current class as primary query
537: */
538: public function useFeatureSynonymQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
539: {
540: return $this
541: ->joinFeatureSynonym($relationAlias, $joinType)
542: ->useQuery($relationAlias ? $relationAlias : 'FeatureSynonym', '\cli_db\propel\FeatureSynonymQuery');
543: }
544:
545: /**
546: * Exclude object from result
547: *
548: * @param Synonym $synonym Object to remove from the list of results
549: *
550: * @return SynonymQuery The current query, for fluid interface
551: */
552: public function prune($synonym = null)
553: {
554: if ($synonym) {
555: $this->addUsingAlias(SynonymPeer::SYNONYM_ID, $synonym->getSynonymId(), Criteria::NOT_EQUAL);
556: }
557:
558: return $this;
559: }
560:
561: }
562: