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\Cv;
16: use cli_db\propel\CvPeer;
17: use cli_db\propel\CvQuery;
18: use cli_db\propel\Cvterm;
19:
20: /**
21: * Base class that represents a query for the 'cv' table.
22: *
23: *
24: *
25: * @method CvQuery orderByCvId($order = Criteria::ASC) Order by the cv_id column
26: * @method CvQuery orderByName($order = Criteria::ASC) Order by the name column
27: * @method CvQuery orderByDefinition($order = Criteria::ASC) Order by the definition column
28: *
29: * @method CvQuery groupByCvId() Group by the cv_id column
30: * @method CvQuery groupByName() Group by the name column
31: * @method CvQuery groupByDefinition() Group by the definition column
32: *
33: * @method CvQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
34: * @method CvQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
35: * @method CvQuery innerJoin($relation) Adds a INNER JOIN clause to the query
36: *
37: * @method CvQuery leftJoinCvterm($relationAlias = null) Adds a LEFT JOIN clause to the query using the Cvterm relation
38: * @method CvQuery rightJoinCvterm($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Cvterm relation
39: * @method CvQuery innerJoinCvterm($relationAlias = null) Adds a INNER JOIN clause to the query using the Cvterm relation
40: *
41: * @method Cv findOne(PropelPDO $con = null) Return the first Cv matching the query
42: * @method Cv findOneOrCreate(PropelPDO $con = null) Return the first Cv matching the query, or a new Cv object populated from the query conditions when no match is found
43: *
44: * @method Cv findOneByName(string $name) Return the first Cv filtered by the name column
45: * @method Cv findOneByDefinition(string $definition) Return the first Cv filtered by the definition column
46: *
47: * @method array findByCvId(int $cv_id) Return Cv objects filtered by the cv_id column
48: * @method array findByName(string $name) Return Cv objects filtered by the name column
49: * @method array findByDefinition(string $definition) Return Cv objects filtered by the definition column
50: *
51: * @package propel.generator.cli_db.om
52: */
53: abstract class BaseCvQuery extends ModelCriteria
54: {
55: /**
56: * Initializes internal state of BaseCvQuery object.
57: *
58: * @param string $dbName The dabase name
59: * @param string $modelName The phpName of a model, e.g. 'Book'
60: * @param string $modelAlias The alias for the model in this query, e.g. 'b'
61: */
62: public function __construct($dbName = 'cli_db', $modelName = 'cli_db\\propel\\Cv', $modelAlias = null)
63: {
64: parent::__construct($dbName, $modelName, $modelAlias);
65: }
66:
67: /**
68: * Returns a new CvQuery object.
69: *
70: * @param string $modelAlias The alias of a model in the query
71: * @param CvQuery|Criteria $criteria Optional Criteria to build the query from
72: *
73: * @return CvQuery
74: */
75: public static function create($modelAlias = null, $criteria = null)
76: {
77: if ($criteria instanceof CvQuery) {
78: return $criteria;
79: }
80: $query = new CvQuery();
81: if (null !== $modelAlias) {
82: $query->setModelAlias($modelAlias);
83: }
84: if ($criteria instanceof Criteria) {
85: $query->mergeWith($criteria);
86: }
87:
88: return $query;
89: }
90:
91: /**
92: * Find object by primary key.
93: * Propel uses the instance pool to skip the database if the object exists.
94: * Go fast if the query is untouched.
95: *
96: * <code>
97: * $obj = $c->findPk(12, $con);
98: * </code>
99: *
100: * @param mixed $key Primary key to use for the query
101: * @param PropelPDO $con an optional connection object
102: *
103: * @return Cv|Cv[]|mixed the result, formatted by the current formatter
104: */
105: public function findPk($key, $con = null)
106: {
107: if ($key === null) {
108: return null;
109: }
110: if ((null !== ($obj = CvPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
111: // the object is alredy in the instance pool
112: return $obj;
113: }
114: if ($con === null) {
115: $con = Propel::getConnection(CvPeer::DATABASE_NAME, Propel::CONNECTION_READ);
116: }
117: $this->basePreSelect($con);
118: if ($this->formatter || $this->modelAlias || $this->with || $this->select
119: || $this->selectColumns || $this->asColumns || $this->selectModifiers
120: || $this->map || $this->having || $this->joins) {
121: return $this->findPkComplex($key, $con);
122: } else {
123: return $this->findPkSimple($key, $con);
124: }
125: }
126:
127: /**
128: * Alias of findPk to use instance pooling
129: *
130: * @param mixed $key Primary key to use for the query
131: * @param PropelPDO $con A connection object
132: *
133: * @return Cv A model object, or null if the key is not found
134: * @throws PropelException
135: */
136: public function findOneByCvId($key, $con = null)
137: {
138: return $this->findPk($key, $con);
139: }
140:
141: /**
142: * Find object by primary key using raw SQL to go fast.
143: * Bypass doSelect() and the object formatter by using generated code.
144: *
145: * @param mixed $key Primary key to use for the query
146: * @param PropelPDO $con A connection object
147: *
148: * @return Cv A model object, or null if the key is not found
149: * @throws PropelException
150: */
151: protected function findPkSimple($key, $con)
152: {
153: $sql = 'SELECT "cv_id", "name", "definition" FROM "cv" WHERE "cv_id" = :p0';
154: try {
155: $stmt = $con->prepare($sql);
156: $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
157: $stmt->execute();
158: } catch (Exception $e) {
159: Propel::log($e->getMessage(), Propel::LOG_ERR);
160: throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
161: }
162: $obj = null;
163: if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
164: $obj = new Cv();
165: $obj->hydrate($row);
166: CvPeer::addInstanceToPool($obj, (string) $key);
167: }
168: $stmt->closeCursor();
169:
170: return $obj;
171: }
172:
173: /**
174: * Find object by primary key.
175: *
176: * @param mixed $key Primary key to use for the query
177: * @param PropelPDO $con A connection object
178: *
179: * @return Cv|Cv[]|mixed the result, formatted by the current formatter
180: */
181: protected function findPkComplex($key, $con)
182: {
183: // As the query uses a PK condition, no limit(1) is necessary.
184: $criteria = $this->isKeepQuery() ? clone $this : $this;
185: $stmt = $criteria
186: ->filterByPrimaryKey($key)
187: ->doSelect($con);
188:
189: return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
190: }
191:
192: /**
193: * Find objects by primary key
194: * <code>
195: * $objs = $c->findPks(array(12, 56, 832), $con);
196: * </code>
197: * @param array $keys Primary keys to use for the query
198: * @param PropelPDO $con an optional connection object
199: *
200: * @return PropelObjectCollection|Cv[]|mixed the list of results, formatted by the current formatter
201: */
202: public function findPks($keys, $con = null)
203: {
204: if ($con === null) {
205: $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
206: }
207: $this->basePreSelect($con);
208: $criteria = $this->isKeepQuery() ? clone $this : $this;
209: $stmt = $criteria
210: ->filterByPrimaryKeys($keys)
211: ->doSelect($con);
212:
213: return $criteria->getFormatter()->init($criteria)->format($stmt);
214: }
215:
216: /**
217: * Filter the query by primary key
218: *
219: * @param mixed $key Primary key to use for the query
220: *
221: * @return CvQuery The current query, for fluid interface
222: */
223: public function filterByPrimaryKey($key)
224: {
225:
226: return $this->addUsingAlias(CvPeer::CV_ID, $key, Criteria::EQUAL);
227: }
228:
229: /**
230: * Filter the query by a list of primary keys
231: *
232: * @param array $keys The list of primary key to use for the query
233: *
234: * @return CvQuery The current query, for fluid interface
235: */
236: public function filterByPrimaryKeys($keys)
237: {
238:
239: return $this->addUsingAlias(CvPeer::CV_ID, $keys, Criteria::IN);
240: }
241:
242: /**
243: * Filter the query on the cv_id column
244: *
245: * Example usage:
246: * <code>
247: * $query->filterByCvId(1234); // WHERE cv_id = 1234
248: * $query->filterByCvId(array(12, 34)); // WHERE cv_id IN (12, 34)
249: * $query->filterByCvId(array('min' => 12)); // WHERE cv_id >= 12
250: * $query->filterByCvId(array('max' => 12)); // WHERE cv_id <= 12
251: * </code>
252: *
253: * @param mixed $cvId The value to use as filter.
254: * Use scalar values for equality.
255: * Use array values for in_array() equivalent.
256: * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
257: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
258: *
259: * @return CvQuery The current query, for fluid interface
260: */
261: public function filterByCvId($cvId = null, $comparison = null)
262: {
263: if (is_array($cvId)) {
264: $useMinMax = false;
265: if (isset($cvId['min'])) {
266: $this->addUsingAlias(CvPeer::CV_ID, $cvId['min'], Criteria::GREATER_EQUAL);
267: $useMinMax = true;
268: }
269: if (isset($cvId['max'])) {
270: $this->addUsingAlias(CvPeer::CV_ID, $cvId['max'], Criteria::LESS_EQUAL);
271: $useMinMax = true;
272: }
273: if ($useMinMax) {
274: return $this;
275: }
276: if (null === $comparison) {
277: $comparison = Criteria::IN;
278: }
279: }
280:
281: return $this->addUsingAlias(CvPeer::CV_ID, $cvId, $comparison);
282: }
283:
284: /**
285: * Filter the query on the name column
286: *
287: * Example usage:
288: * <code>
289: * $query->filterByName('fooValue'); // WHERE name = 'fooValue'
290: * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
291: * </code>
292: *
293: * @param string $name The value to use as filter.
294: * Accepts wildcards (* and % trigger a LIKE)
295: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
296: *
297: * @return CvQuery The current query, for fluid interface
298: */
299: public function filterByName($name = null, $comparison = null)
300: {
301: if (null === $comparison) {
302: if (is_array($name)) {
303: $comparison = Criteria::IN;
304: } elseif (preg_match('/[\%\*]/', $name)) {
305: $name = str_replace('*', '%', $name);
306: $comparison = Criteria::LIKE;
307: }
308: }
309:
310: return $this->addUsingAlias(CvPeer::NAME, $name, $comparison);
311: }
312:
313: /**
314: * Filter the query on the definition column
315: *
316: * Example usage:
317: * <code>
318: * $query->filterByDefinition('fooValue'); // WHERE definition = 'fooValue'
319: * $query->filterByDefinition('%fooValue%'); // WHERE definition LIKE '%fooValue%'
320: * </code>
321: *
322: * @param string $definition The value to use as filter.
323: * Accepts wildcards (* and % trigger a LIKE)
324: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
325: *
326: * @return CvQuery The current query, for fluid interface
327: */
328: public function filterByDefinition($definition = null, $comparison = null)
329: {
330: if (null === $comparison) {
331: if (is_array($definition)) {
332: $comparison = Criteria::IN;
333: } elseif (preg_match('/[\%\*]/', $definition)) {
334: $definition = str_replace('*', '%', $definition);
335: $comparison = Criteria::LIKE;
336: }
337: }
338:
339: return $this->addUsingAlias(CvPeer::DEFINITION, $definition, $comparison);
340: }
341:
342: /**
343: * Filter the query by a related Cvterm object
344: *
345: * @param Cvterm|PropelObjectCollection $cvterm the related object to use as filter
346: * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
347: *
348: * @return CvQuery The current query, for fluid interface
349: * @throws PropelException - if the provided filter is invalid.
350: */
351: public function filterByCvterm($cvterm, $comparison = null)
352: {
353: if ($cvterm instanceof Cvterm) {
354: return $this
355: ->addUsingAlias(CvPeer::CV_ID, $cvterm->getCvId(), $comparison);
356: } elseif ($cvterm instanceof PropelObjectCollection) {
357: return $this
358: ->useCvtermQuery()
359: ->filterByPrimaryKeys($cvterm->getPrimaryKeys())
360: ->endUse();
361: } else {
362: throw new PropelException('filterByCvterm() only accepts arguments of type Cvterm or PropelCollection');
363: }
364: }
365:
366: /**
367: * Adds a JOIN clause to the query using the Cvterm relation
368: *
369: * @param string $relationAlias optional alias for the relation
370: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
371: *
372: * @return CvQuery The current query, for fluid interface
373: */
374: public function joinCvterm($relationAlias = null, $joinType = Criteria::INNER_JOIN)
375: {
376: $tableMap = $this->getTableMap();
377: $relationMap = $tableMap->getRelation('Cvterm');
378:
379: // create a ModelJoin object for this join
380: $join = new ModelJoin();
381: $join->setJoinType($joinType);
382: $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
383: if ($previousJoin = $this->getPreviousJoin()) {
384: $join->setPreviousJoin($previousJoin);
385: }
386:
387: // add the ModelJoin to the current object
388: if ($relationAlias) {
389: $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
390: $this->addJoinObject($join, $relationAlias);
391: } else {
392: $this->addJoinObject($join, 'Cvterm');
393: }
394:
395: return $this;
396: }
397:
398: /**
399: * Use the Cvterm relation Cvterm object
400: *
401: * @see useQuery()
402: *
403: * @param string $relationAlias optional alias for the relation,
404: * to be used as main alias in the secondary query
405: * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
406: *
407: * @return \cli_db\propel\CvtermQuery A secondary query class using the current class as primary query
408: */
409: public function useCvtermQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
410: {
411: return $this
412: ->joinCvterm($relationAlias, $joinType)
413: ->useQuery($relationAlias ? $relationAlias : 'Cvterm', '\cli_db\propel\CvtermQuery');
414: }
415:
416: /**
417: * Exclude object from result
418: *
419: * @param Cv $cv Object to remove from the list of results
420: *
421: * @return CvQuery The current query, for fluid interface
422: */
423: public function prune($cv = null)
424: {
425: if ($cv) {
426: $this->addUsingAlias(CvPeer::CV_ID, $cv->getCvId(), Criteria::NOT_EQUAL);
427: }
428:
429: return $this;
430: }
431:
432: }
433: