@@ -64,7 +64,6 @@ discard block |
||
64 | 64 | * @method ChildChannel findOneById(int $id) Return the first ChildChannel filtered by the id column |
65 | 65 | * @method ChildChannel findOneByInstanceName(string $instance_name) Return the first ChildChannel filtered by the instance_name column |
66 | 66 | * @method ChildChannel findOneByName(string $name) Return the first ChildChannel filtered by the name column * |
67 | - |
|
68 | 67 | * @method ChildChannel requirePk($key, ConnectionInterface $con = null) Return the ChildChannel by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
69 | 68 | * @method ChildChannel requireOne(ConnectionInterface $con = null) Return the first ChildChannel matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
70 | 69 | * |
@@ -81,507 +80,507 @@ discard block |
||
81 | 80 | */ |
82 | 81 | abstract class ChannelQuery extends ModelCriteria |
83 | 82 | { |
84 | - protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
85 | - |
|
86 | - /** |
|
87 | - * Initializes internal state of \Jalle19\StatusManager\Database\Base\ChannelQuery object. |
|
88 | - * |
|
89 | - * @param string $dbName The database name |
|
90 | - * @param string $modelName The phpName of a model, e.g. 'Book' |
|
91 | - * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
92 | - */ |
|
93 | - public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Channel', $modelAlias = null) |
|
94 | - { |
|
95 | - parent::__construct($dbName, $modelName, $modelAlias); |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns a new ChildChannelQuery object. |
|
100 | - * |
|
101 | - * @param string $modelAlias The alias of a model in the query |
|
102 | - * @param Criteria $criteria Optional Criteria to build the query from |
|
103 | - * |
|
104 | - * @return ChildChannelQuery |
|
105 | - */ |
|
106 | - public static function create($modelAlias = null, Criteria $criteria = null) |
|
107 | - { |
|
108 | - if ($criteria instanceof ChildChannelQuery) { |
|
109 | - return $criteria; |
|
110 | - } |
|
111 | - $query = new ChildChannelQuery(); |
|
112 | - if (null !== $modelAlias) { |
|
113 | - $query->setModelAlias($modelAlias); |
|
114 | - } |
|
115 | - if ($criteria instanceof Criteria) { |
|
116 | - $query->mergeWith($criteria); |
|
117 | - } |
|
118 | - |
|
119 | - return $query; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * Find object by primary key. |
|
124 | - * Propel uses the instance pool to skip the database if the object exists. |
|
125 | - * Go fast if the query is untouched. |
|
126 | - * |
|
127 | - * <code> |
|
128 | - * $obj = $c->findPk(12, $con); |
|
129 | - * </code> |
|
130 | - * |
|
131 | - * @param mixed $key Primary key to use for the query |
|
132 | - * @param ConnectionInterface $con an optional connection object |
|
133 | - * |
|
134 | - * @return ChildChannel|array|mixed the result, formatted by the current formatter |
|
135 | - */ |
|
136 | - public function findPk($key, ConnectionInterface $con = null) |
|
137 | - { |
|
138 | - if ($key === null) { |
|
139 | - return null; |
|
140 | - } |
|
141 | - if ((null !== ($obj = ChannelTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
142 | - // the object is already in the instance pool |
|
143 | - return $obj; |
|
144 | - } |
|
145 | - if ($con === null) { |
|
146 | - $con = Propel::getServiceContainer()->getReadConnection(ChannelTableMap::DATABASE_NAME); |
|
147 | - } |
|
148 | - $this->basePreSelect($con); |
|
149 | - if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
150 | - || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
151 | - || $this->map || $this->having || $this->joins) { |
|
152 | - return $this->findPkComplex($key, $con); |
|
153 | - } else { |
|
154 | - return $this->findPkSimple($key, $con); |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Find object by primary key using raw SQL to go fast. |
|
160 | - * Bypass doSelect() and the object formatter by using generated code. |
|
161 | - * |
|
162 | - * @param mixed $key Primary key to use for the query |
|
163 | - * @param ConnectionInterface $con A connection object |
|
164 | - * |
|
165 | - * @throws \Propel\Runtime\Exception\PropelException |
|
166 | - * |
|
167 | - * @return ChildChannel A model object, or null if the key is not found |
|
168 | - */ |
|
169 | - protected function findPkSimple($key, ConnectionInterface $con) |
|
170 | - { |
|
171 | - $sql = 'SELECT id, instance_name, name FROM channel WHERE id = :p0'; |
|
172 | - try { |
|
173 | - $stmt = $con->prepare($sql); |
|
174 | - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
175 | - $stmt->execute(); |
|
176 | - } catch (Exception $e) { |
|
177 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
178 | - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
179 | - } |
|
180 | - $obj = null; |
|
181 | - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
182 | - /** @var ChildChannel $obj */ |
|
183 | - $obj = new ChildChannel(); |
|
184 | - $obj->hydrate($row); |
|
185 | - ChannelTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
186 | - } |
|
187 | - $stmt->closeCursor(); |
|
188 | - |
|
189 | - return $obj; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Find object by primary key. |
|
194 | - * |
|
195 | - * @param mixed $key Primary key to use for the query |
|
196 | - * @param ConnectionInterface $con A connection object |
|
197 | - * |
|
198 | - * @return ChildChannel|array|mixed the result, formatted by the current formatter |
|
199 | - */ |
|
200 | - protected function findPkComplex($key, ConnectionInterface $con) |
|
201 | - { |
|
202 | - // As the query uses a PK condition, no limit(1) is necessary. |
|
203 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
204 | - $dataFetcher = $criteria |
|
205 | - ->filterByPrimaryKey($key) |
|
206 | - ->doSelect($con); |
|
207 | - |
|
208 | - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Find objects by primary key |
|
213 | - * <code> |
|
214 | - * $objs = $c->findPks(array(12, 56, 832), $con); |
|
215 | - * </code> |
|
216 | - * @param array $keys Primary keys to use for the query |
|
217 | - * @param ConnectionInterface $con an optional connection object |
|
218 | - * |
|
219 | - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
220 | - */ |
|
221 | - public function findPks($keys, ConnectionInterface $con = null) |
|
222 | - { |
|
223 | - if (null === $con) { |
|
224 | - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
225 | - } |
|
226 | - $this->basePreSelect($con); |
|
227 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
228 | - $dataFetcher = $criteria |
|
229 | - ->filterByPrimaryKeys($keys) |
|
230 | - ->doSelect($con); |
|
231 | - |
|
232 | - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
233 | - } |
|
234 | - |
|
235 | - /** |
|
236 | - * Filter the query by primary key |
|
237 | - * |
|
238 | - * @param mixed $key Primary key to use for the query |
|
239 | - * |
|
240 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
241 | - */ |
|
242 | - public function filterByPrimaryKey($key) |
|
243 | - { |
|
244 | - |
|
245 | - return $this->addUsingAlias(ChannelTableMap::COL_ID, $key, Criteria::EQUAL); |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * Filter the query by a list of primary keys |
|
250 | - * |
|
251 | - * @param array $keys The list of primary key to use for the query |
|
252 | - * |
|
253 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
254 | - */ |
|
255 | - public function filterByPrimaryKeys($keys) |
|
256 | - { |
|
257 | - |
|
258 | - return $this->addUsingAlias(ChannelTableMap::COL_ID, $keys, Criteria::IN); |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Filter the query on the id column |
|
263 | - * |
|
264 | - * Example usage: |
|
265 | - * <code> |
|
266 | - * $query->filterById(1234); // WHERE id = 1234 |
|
267 | - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
268 | - * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
269 | - * </code> |
|
270 | - * |
|
271 | - * @param mixed $id The value to use as filter. |
|
272 | - * Use scalar values for equality. |
|
273 | - * Use array values for in_array() equivalent. |
|
274 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
275 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
276 | - * |
|
277 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
278 | - */ |
|
279 | - public function filterById($id = null, $comparison = null) |
|
280 | - { |
|
281 | - if (is_array($id)) { |
|
282 | - $useMinMax = false; |
|
283 | - if (isset($id['min'])) { |
|
284 | - $this->addUsingAlias(ChannelTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
285 | - $useMinMax = true; |
|
286 | - } |
|
287 | - if (isset($id['max'])) { |
|
288 | - $this->addUsingAlias(ChannelTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
289 | - $useMinMax = true; |
|
290 | - } |
|
291 | - if ($useMinMax) { |
|
292 | - return $this; |
|
293 | - } |
|
294 | - if (null === $comparison) { |
|
295 | - $comparison = Criteria::IN; |
|
296 | - } |
|
297 | - } |
|
298 | - |
|
299 | - return $this->addUsingAlias(ChannelTableMap::COL_ID, $id, $comparison); |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Filter the query on the instance_name column |
|
304 | - * |
|
305 | - * Example usage: |
|
306 | - * <code> |
|
307 | - * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
308 | - * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
309 | - * </code> |
|
310 | - * |
|
311 | - * @param string $instanceName The value to use as filter. |
|
312 | - * Accepts wildcards (* and % trigger a LIKE) |
|
313 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
314 | - * |
|
315 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
316 | - */ |
|
317 | - public function filterByInstanceName($instanceName = null, $comparison = null) |
|
318 | - { |
|
319 | - if (null === $comparison) { |
|
320 | - if (is_array($instanceName)) { |
|
321 | - $comparison = Criteria::IN; |
|
322 | - } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
323 | - $instanceName = str_replace('*', '%', $instanceName); |
|
324 | - $comparison = Criteria::LIKE; |
|
325 | - } |
|
326 | - } |
|
327 | - |
|
328 | - return $this->addUsingAlias(ChannelTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * Filter the query on the name column |
|
333 | - * |
|
334 | - * Example usage: |
|
335 | - * <code> |
|
336 | - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
|
337 | - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
|
338 | - * </code> |
|
339 | - * |
|
340 | - * @param string $name The value to use as filter. |
|
341 | - * Accepts wildcards (* and % trigger a LIKE) |
|
342 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
343 | - * |
|
344 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
345 | - */ |
|
346 | - public function filterByName($name = null, $comparison = null) |
|
347 | - { |
|
348 | - if (null === $comparison) { |
|
349 | - if (is_array($name)) { |
|
350 | - $comparison = Criteria::IN; |
|
351 | - } elseif (preg_match('/[\%\*]/', $name)) { |
|
352 | - $name = str_replace('*', '%', $name); |
|
353 | - $comparison = Criteria::LIKE; |
|
354 | - } |
|
355 | - } |
|
356 | - |
|
357 | - return $this->addUsingAlias(ChannelTableMap::COL_NAME, $name, $comparison); |
|
358 | - } |
|
359 | - |
|
360 | - /** |
|
361 | - * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
362 | - * |
|
363 | - * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
364 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
365 | - * |
|
366 | - * @throws \Propel\Runtime\Exception\PropelException |
|
367 | - * |
|
368 | - * @return ChildChannelQuery The current query, for fluid interface |
|
369 | - */ |
|
370 | - public function filterByInstance($instance, $comparison = null) |
|
371 | - { |
|
372 | - if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
373 | - return $this |
|
374 | - ->addUsingAlias(ChannelTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
375 | - } elseif ($instance instanceof ObjectCollection) { |
|
376 | - if (null === $comparison) { |
|
377 | - $comparison = Criteria::IN; |
|
378 | - } |
|
379 | - |
|
380 | - return $this |
|
381 | - ->addUsingAlias(ChannelTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
382 | - } else { |
|
383 | - throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
384 | - } |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Adds a JOIN clause to the query using the Instance relation |
|
389 | - * |
|
390 | - * @param string $relationAlias optional alias for the relation |
|
391 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
392 | - * |
|
393 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
394 | - */ |
|
395 | - public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
396 | - { |
|
397 | - $tableMap = $this->getTableMap(); |
|
398 | - $relationMap = $tableMap->getRelation('Instance'); |
|
399 | - |
|
400 | - // create a ModelJoin object for this join |
|
401 | - $join = new ModelJoin(); |
|
402 | - $join->setJoinType($joinType); |
|
403 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
404 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
405 | - $join->setPreviousJoin($previousJoin); |
|
406 | - } |
|
407 | - |
|
408 | - // add the ModelJoin to the current object |
|
409 | - if ($relationAlias) { |
|
410 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
411 | - $this->addJoinObject($join, $relationAlias); |
|
412 | - } else { |
|
413 | - $this->addJoinObject($join, 'Instance'); |
|
414 | - } |
|
415 | - |
|
416 | - return $this; |
|
417 | - } |
|
418 | - |
|
419 | - /** |
|
420 | - * Use the Instance relation Instance object |
|
421 | - * |
|
422 | - * @see useQuery() |
|
423 | - * |
|
424 | - * @param string $relationAlias optional alias for the relation, |
|
425 | - * to be used as main alias in the secondary query |
|
426 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
427 | - * |
|
428 | - * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
429 | - */ |
|
430 | - public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
431 | - { |
|
432 | - return $this |
|
433 | - ->joinInstance($relationAlias, $joinType) |
|
434 | - ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
435 | - } |
|
436 | - |
|
437 | - /** |
|
438 | - * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
439 | - * |
|
440 | - * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
441 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
442 | - * |
|
443 | - * @return ChildChannelQuery The current query, for fluid interface |
|
444 | - */ |
|
445 | - public function filterBySubscription($subscription, $comparison = null) |
|
446 | - { |
|
447 | - if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
448 | - return $this |
|
449 | - ->addUsingAlias(ChannelTableMap::COL_ID, $subscription->getChannelId(), $comparison); |
|
450 | - } elseif ($subscription instanceof ObjectCollection) { |
|
451 | - return $this |
|
452 | - ->useSubscriptionQuery() |
|
453 | - ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
454 | - ->endUse(); |
|
455 | - } else { |
|
456 | - throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
457 | - } |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * Adds a JOIN clause to the query using the Subscription relation |
|
462 | - * |
|
463 | - * @param string $relationAlias optional alias for the relation |
|
464 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
465 | - * |
|
466 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
467 | - */ |
|
468 | - public function joinSubscription($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
469 | - { |
|
470 | - $tableMap = $this->getTableMap(); |
|
471 | - $relationMap = $tableMap->getRelation('Subscription'); |
|
472 | - |
|
473 | - // create a ModelJoin object for this join |
|
474 | - $join = new ModelJoin(); |
|
475 | - $join->setJoinType($joinType); |
|
476 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
477 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
478 | - $join->setPreviousJoin($previousJoin); |
|
479 | - } |
|
480 | - |
|
481 | - // add the ModelJoin to the current object |
|
482 | - if ($relationAlias) { |
|
483 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
484 | - $this->addJoinObject($join, $relationAlias); |
|
485 | - } else { |
|
486 | - $this->addJoinObject($join, 'Subscription'); |
|
487 | - } |
|
488 | - |
|
489 | - return $this; |
|
490 | - } |
|
491 | - |
|
492 | - /** |
|
493 | - * Use the Subscription relation Subscription object |
|
494 | - * |
|
495 | - * @see useQuery() |
|
496 | - * |
|
497 | - * @param string $relationAlias optional alias for the relation, |
|
498 | - * to be used as main alias in the secondary query |
|
499 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
500 | - * |
|
501 | - * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
502 | - */ |
|
503 | - public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
504 | - { |
|
505 | - return $this |
|
506 | - ->joinSubscription($relationAlias, $joinType) |
|
507 | - ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * Exclude object from result |
|
512 | - * |
|
513 | - * @param ChildChannel $channel Object to remove from the list of results |
|
514 | - * |
|
515 | - * @return $this|ChildChannelQuery The current query, for fluid interface |
|
516 | - */ |
|
517 | - public function prune($channel = null) |
|
518 | - { |
|
519 | - if ($channel) { |
|
520 | - $this->addUsingAlias(ChannelTableMap::COL_ID, $channel->getId(), Criteria::NOT_EQUAL); |
|
521 | - } |
|
522 | - |
|
523 | - return $this; |
|
524 | - } |
|
525 | - |
|
526 | - /** |
|
527 | - * Deletes all rows from the channel table. |
|
528 | - * |
|
529 | - * @param ConnectionInterface $con the connection to use |
|
530 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
531 | - */ |
|
532 | - public function doDeleteAll(ConnectionInterface $con = null) |
|
533 | - { |
|
534 | - if (null === $con) { |
|
535 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
536 | - } |
|
537 | - |
|
538 | - // use transaction because $criteria could contain info |
|
539 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
540 | - return $con->transaction(function () use ($con) { |
|
541 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
542 | - $affectedRows += parent::doDeleteAll($con); |
|
543 | - // Because this db requires some delete cascade/set null emulation, we have to |
|
544 | - // clear the cached instance *after* the emulation has happened (since |
|
545 | - // instances get re-added by the select statement contained therein). |
|
546 | - ChannelTableMap::clearInstancePool(); |
|
547 | - ChannelTableMap::clearRelatedInstancePool(); |
|
548 | - |
|
549 | - return $affectedRows; |
|
550 | - }); |
|
551 | - } |
|
552 | - |
|
553 | - /** |
|
554 | - * Performs a DELETE on the database based on the current ModelCriteria |
|
555 | - * |
|
556 | - * @param ConnectionInterface $con the connection to use |
|
557 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
558 | - * if supported by native driver or if emulated using Propel. |
|
559 | - * @throws PropelException Any exceptions caught during processing will be |
|
560 | - * rethrown wrapped into a PropelException. |
|
561 | - */ |
|
562 | - public function delete(ConnectionInterface $con = null) |
|
563 | - { |
|
564 | - if (null === $con) { |
|
565 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
566 | - } |
|
567 | - |
|
568 | - $criteria = $this; |
|
569 | - |
|
570 | - // Set the correct dbName |
|
571 | - $criteria->setDbName(ChannelTableMap::DATABASE_NAME); |
|
572 | - |
|
573 | - // use transaction because $criteria could contain info |
|
574 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
575 | - return $con->transaction(function () use ($con, $criteria) { |
|
576 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
577 | - |
|
578 | - ChannelTableMap::removeInstanceFromPool($criteria); |
|
579 | - |
|
580 | - $affectedRows += ModelCriteria::delete($con); |
|
581 | - ChannelTableMap::clearRelatedInstancePool(); |
|
582 | - |
|
583 | - return $affectedRows; |
|
584 | - }); |
|
585 | - } |
|
83 | + protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
84 | + |
|
85 | + /** |
|
86 | + * Initializes internal state of \Jalle19\StatusManager\Database\Base\ChannelQuery object. |
|
87 | + * |
|
88 | + * @param string $dbName The database name |
|
89 | + * @param string $modelName The phpName of a model, e.g. 'Book' |
|
90 | + * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
91 | + */ |
|
92 | + public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Channel', $modelAlias = null) |
|
93 | + { |
|
94 | + parent::__construct($dbName, $modelName, $modelAlias); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Returns a new ChildChannelQuery object. |
|
99 | + * |
|
100 | + * @param string $modelAlias The alias of a model in the query |
|
101 | + * @param Criteria $criteria Optional Criteria to build the query from |
|
102 | + * |
|
103 | + * @return ChildChannelQuery |
|
104 | + */ |
|
105 | + public static function create($modelAlias = null, Criteria $criteria = null) |
|
106 | + { |
|
107 | + if ($criteria instanceof ChildChannelQuery) { |
|
108 | + return $criteria; |
|
109 | + } |
|
110 | + $query = new ChildChannelQuery(); |
|
111 | + if (null !== $modelAlias) { |
|
112 | + $query->setModelAlias($modelAlias); |
|
113 | + } |
|
114 | + if ($criteria instanceof Criteria) { |
|
115 | + $query->mergeWith($criteria); |
|
116 | + } |
|
117 | + |
|
118 | + return $query; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Find object by primary key. |
|
123 | + * Propel uses the instance pool to skip the database if the object exists. |
|
124 | + * Go fast if the query is untouched. |
|
125 | + * |
|
126 | + * <code> |
|
127 | + * $obj = $c->findPk(12, $con); |
|
128 | + * </code> |
|
129 | + * |
|
130 | + * @param mixed $key Primary key to use for the query |
|
131 | + * @param ConnectionInterface $con an optional connection object |
|
132 | + * |
|
133 | + * @return ChildChannel|array|mixed the result, formatted by the current formatter |
|
134 | + */ |
|
135 | + public function findPk($key, ConnectionInterface $con = null) |
|
136 | + { |
|
137 | + if ($key === null) { |
|
138 | + return null; |
|
139 | + } |
|
140 | + if ((null !== ($obj = ChannelTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
141 | + // the object is already in the instance pool |
|
142 | + return $obj; |
|
143 | + } |
|
144 | + if ($con === null) { |
|
145 | + $con = Propel::getServiceContainer()->getReadConnection(ChannelTableMap::DATABASE_NAME); |
|
146 | + } |
|
147 | + $this->basePreSelect($con); |
|
148 | + if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
149 | + || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
150 | + || $this->map || $this->having || $this->joins) { |
|
151 | + return $this->findPkComplex($key, $con); |
|
152 | + } else { |
|
153 | + return $this->findPkSimple($key, $con); |
|
154 | + } |
|
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 ConnectionInterface $con A connection object |
|
163 | + * |
|
164 | + * @throws \Propel\Runtime\Exception\PropelException |
|
165 | + * |
|
166 | + * @return ChildChannel A model object, or null if the key is not found |
|
167 | + */ |
|
168 | + protected function findPkSimple($key, ConnectionInterface $con) |
|
169 | + { |
|
170 | + $sql = 'SELECT id, instance_name, name FROM channel WHERE id = :p0'; |
|
171 | + try { |
|
172 | + $stmt = $con->prepare($sql); |
|
173 | + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
174 | + $stmt->execute(); |
|
175 | + } catch (Exception $e) { |
|
176 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
177 | + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
178 | + } |
|
179 | + $obj = null; |
|
180 | + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
181 | + /** @var ChildChannel $obj */ |
|
182 | + $obj = new ChildChannel(); |
|
183 | + $obj->hydrate($row); |
|
184 | + ChannelTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
185 | + } |
|
186 | + $stmt->closeCursor(); |
|
187 | + |
|
188 | + return $obj; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Find object by primary key. |
|
193 | + * |
|
194 | + * @param mixed $key Primary key to use for the query |
|
195 | + * @param ConnectionInterface $con A connection object |
|
196 | + * |
|
197 | + * @return ChildChannel|array|mixed the result, formatted by the current formatter |
|
198 | + */ |
|
199 | + protected function findPkComplex($key, ConnectionInterface $con) |
|
200 | + { |
|
201 | + // As the query uses a PK condition, no limit(1) is necessary. |
|
202 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
203 | + $dataFetcher = $criteria |
|
204 | + ->filterByPrimaryKey($key) |
|
205 | + ->doSelect($con); |
|
206 | + |
|
207 | + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Find objects by primary key |
|
212 | + * <code> |
|
213 | + * $objs = $c->findPks(array(12, 56, 832), $con); |
|
214 | + * </code> |
|
215 | + * @param array $keys Primary keys to use for the query |
|
216 | + * @param ConnectionInterface $con an optional connection object |
|
217 | + * |
|
218 | + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
219 | + */ |
|
220 | + public function findPks($keys, ConnectionInterface $con = null) |
|
221 | + { |
|
222 | + if (null === $con) { |
|
223 | + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
224 | + } |
|
225 | + $this->basePreSelect($con); |
|
226 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
227 | + $dataFetcher = $criteria |
|
228 | + ->filterByPrimaryKeys($keys) |
|
229 | + ->doSelect($con); |
|
230 | + |
|
231 | + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * Filter the query by primary key |
|
236 | + * |
|
237 | + * @param mixed $key Primary key to use for the query |
|
238 | + * |
|
239 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
240 | + */ |
|
241 | + public function filterByPrimaryKey($key) |
|
242 | + { |
|
243 | + |
|
244 | + return $this->addUsingAlias(ChannelTableMap::COL_ID, $key, Criteria::EQUAL); |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * Filter the query by a list of primary keys |
|
249 | + * |
|
250 | + * @param array $keys The list of primary key to use for the query |
|
251 | + * |
|
252 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
253 | + */ |
|
254 | + public function filterByPrimaryKeys($keys) |
|
255 | + { |
|
256 | + |
|
257 | + return $this->addUsingAlias(ChannelTableMap::COL_ID, $keys, Criteria::IN); |
|
258 | + } |
|
259 | + |
|
260 | + /** |
|
261 | + * Filter the query on the id column |
|
262 | + * |
|
263 | + * Example usage: |
|
264 | + * <code> |
|
265 | + * $query->filterById(1234); // WHERE id = 1234 |
|
266 | + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
267 | + * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
268 | + * </code> |
|
269 | + * |
|
270 | + * @param mixed $id The value to use as filter. |
|
271 | + * Use scalar values for equality. |
|
272 | + * Use array values for in_array() equivalent. |
|
273 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
274 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
275 | + * |
|
276 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
277 | + */ |
|
278 | + public function filterById($id = null, $comparison = null) |
|
279 | + { |
|
280 | + if (is_array($id)) { |
|
281 | + $useMinMax = false; |
|
282 | + if (isset($id['min'])) { |
|
283 | + $this->addUsingAlias(ChannelTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
284 | + $useMinMax = true; |
|
285 | + } |
|
286 | + if (isset($id['max'])) { |
|
287 | + $this->addUsingAlias(ChannelTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
288 | + $useMinMax = true; |
|
289 | + } |
|
290 | + if ($useMinMax) { |
|
291 | + return $this; |
|
292 | + } |
|
293 | + if (null === $comparison) { |
|
294 | + $comparison = Criteria::IN; |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + return $this->addUsingAlias(ChannelTableMap::COL_ID, $id, $comparison); |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Filter the query on the instance_name column |
|
303 | + * |
|
304 | + * Example usage: |
|
305 | + * <code> |
|
306 | + * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
307 | + * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
308 | + * </code> |
|
309 | + * |
|
310 | + * @param string $instanceName The value to use as filter. |
|
311 | + * Accepts wildcards (* and % trigger a LIKE) |
|
312 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
313 | + * |
|
314 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
315 | + */ |
|
316 | + public function filterByInstanceName($instanceName = null, $comparison = null) |
|
317 | + { |
|
318 | + if (null === $comparison) { |
|
319 | + if (is_array($instanceName)) { |
|
320 | + $comparison = Criteria::IN; |
|
321 | + } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
322 | + $instanceName = str_replace('*', '%', $instanceName); |
|
323 | + $comparison = Criteria::LIKE; |
|
324 | + } |
|
325 | + } |
|
326 | + |
|
327 | + return $this->addUsingAlias(ChannelTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Filter the query on the name column |
|
332 | + * |
|
333 | + * Example usage: |
|
334 | + * <code> |
|
335 | + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
|
336 | + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
|
337 | + * </code> |
|
338 | + * |
|
339 | + * @param string $name The value to use as filter. |
|
340 | + * Accepts wildcards (* and % trigger a LIKE) |
|
341 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
342 | + * |
|
343 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
344 | + */ |
|
345 | + public function filterByName($name = null, $comparison = null) |
|
346 | + { |
|
347 | + if (null === $comparison) { |
|
348 | + if (is_array($name)) { |
|
349 | + $comparison = Criteria::IN; |
|
350 | + } elseif (preg_match('/[\%\*]/', $name)) { |
|
351 | + $name = str_replace('*', '%', $name); |
|
352 | + $comparison = Criteria::LIKE; |
|
353 | + } |
|
354 | + } |
|
355 | + |
|
356 | + return $this->addUsingAlias(ChannelTableMap::COL_NAME, $name, $comparison); |
|
357 | + } |
|
358 | + |
|
359 | + /** |
|
360 | + * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
361 | + * |
|
362 | + * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
363 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
364 | + * |
|
365 | + * @throws \Propel\Runtime\Exception\PropelException |
|
366 | + * |
|
367 | + * @return ChildChannelQuery The current query, for fluid interface |
|
368 | + */ |
|
369 | + public function filterByInstance($instance, $comparison = null) |
|
370 | + { |
|
371 | + if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
372 | + return $this |
|
373 | + ->addUsingAlias(ChannelTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
374 | + } elseif ($instance instanceof ObjectCollection) { |
|
375 | + if (null === $comparison) { |
|
376 | + $comparison = Criteria::IN; |
|
377 | + } |
|
378 | + |
|
379 | + return $this |
|
380 | + ->addUsingAlias(ChannelTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
381 | + } else { |
|
382 | + throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Adds a JOIN clause to the query using the Instance relation |
|
388 | + * |
|
389 | + * @param string $relationAlias optional alias for the relation |
|
390 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
391 | + * |
|
392 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
393 | + */ |
|
394 | + public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
395 | + { |
|
396 | + $tableMap = $this->getTableMap(); |
|
397 | + $relationMap = $tableMap->getRelation('Instance'); |
|
398 | + |
|
399 | + // create a ModelJoin object for this join |
|
400 | + $join = new ModelJoin(); |
|
401 | + $join->setJoinType($joinType); |
|
402 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
403 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
404 | + $join->setPreviousJoin($previousJoin); |
|
405 | + } |
|
406 | + |
|
407 | + // add the ModelJoin to the current object |
|
408 | + if ($relationAlias) { |
|
409 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
410 | + $this->addJoinObject($join, $relationAlias); |
|
411 | + } else { |
|
412 | + $this->addJoinObject($join, 'Instance'); |
|
413 | + } |
|
414 | + |
|
415 | + return $this; |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Use the Instance relation Instance object |
|
420 | + * |
|
421 | + * @see useQuery() |
|
422 | + * |
|
423 | + * @param string $relationAlias optional alias for the relation, |
|
424 | + * to be used as main alias in the secondary query |
|
425 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
426 | + * |
|
427 | + * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
428 | + */ |
|
429 | + public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
430 | + { |
|
431 | + return $this |
|
432 | + ->joinInstance($relationAlias, $joinType) |
|
433 | + ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
434 | + } |
|
435 | + |
|
436 | + /** |
|
437 | + * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
438 | + * |
|
439 | + * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
440 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
441 | + * |
|
442 | + * @return ChildChannelQuery The current query, for fluid interface |
|
443 | + */ |
|
444 | + public function filterBySubscription($subscription, $comparison = null) |
|
445 | + { |
|
446 | + if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
447 | + return $this |
|
448 | + ->addUsingAlias(ChannelTableMap::COL_ID, $subscription->getChannelId(), $comparison); |
|
449 | + } elseif ($subscription instanceof ObjectCollection) { |
|
450 | + return $this |
|
451 | + ->useSubscriptionQuery() |
|
452 | + ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
453 | + ->endUse(); |
|
454 | + } else { |
|
455 | + throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
456 | + } |
|
457 | + } |
|
458 | + |
|
459 | + /** |
|
460 | + * Adds a JOIN clause to the query using the Subscription relation |
|
461 | + * |
|
462 | + * @param string $relationAlias optional alias for the relation |
|
463 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
464 | + * |
|
465 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
466 | + */ |
|
467 | + public function joinSubscription($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
468 | + { |
|
469 | + $tableMap = $this->getTableMap(); |
|
470 | + $relationMap = $tableMap->getRelation('Subscription'); |
|
471 | + |
|
472 | + // create a ModelJoin object for this join |
|
473 | + $join = new ModelJoin(); |
|
474 | + $join->setJoinType($joinType); |
|
475 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
476 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
477 | + $join->setPreviousJoin($previousJoin); |
|
478 | + } |
|
479 | + |
|
480 | + // add the ModelJoin to the current object |
|
481 | + if ($relationAlias) { |
|
482 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
483 | + $this->addJoinObject($join, $relationAlias); |
|
484 | + } else { |
|
485 | + $this->addJoinObject($join, 'Subscription'); |
|
486 | + } |
|
487 | + |
|
488 | + return $this; |
|
489 | + } |
|
490 | + |
|
491 | + /** |
|
492 | + * Use the Subscription relation Subscription object |
|
493 | + * |
|
494 | + * @see useQuery() |
|
495 | + * |
|
496 | + * @param string $relationAlias optional alias for the relation, |
|
497 | + * to be used as main alias in the secondary query |
|
498 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
499 | + * |
|
500 | + * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
501 | + */ |
|
502 | + public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
503 | + { |
|
504 | + return $this |
|
505 | + ->joinSubscription($relationAlias, $joinType) |
|
506 | + ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
507 | + } |
|
508 | + |
|
509 | + /** |
|
510 | + * Exclude object from result |
|
511 | + * |
|
512 | + * @param ChildChannel $channel Object to remove from the list of results |
|
513 | + * |
|
514 | + * @return $this|ChildChannelQuery The current query, for fluid interface |
|
515 | + */ |
|
516 | + public function prune($channel = null) |
|
517 | + { |
|
518 | + if ($channel) { |
|
519 | + $this->addUsingAlias(ChannelTableMap::COL_ID, $channel->getId(), Criteria::NOT_EQUAL); |
|
520 | + } |
|
521 | + |
|
522 | + return $this; |
|
523 | + } |
|
524 | + |
|
525 | + /** |
|
526 | + * Deletes all rows from the channel table. |
|
527 | + * |
|
528 | + * @param ConnectionInterface $con the connection to use |
|
529 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
530 | + */ |
|
531 | + public function doDeleteAll(ConnectionInterface $con = null) |
|
532 | + { |
|
533 | + if (null === $con) { |
|
534 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
535 | + } |
|
536 | + |
|
537 | + // use transaction because $criteria could contain info |
|
538 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
539 | + return $con->transaction(function () use ($con) { |
|
540 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
541 | + $affectedRows += parent::doDeleteAll($con); |
|
542 | + // Because this db requires some delete cascade/set null emulation, we have to |
|
543 | + // clear the cached instance *after* the emulation has happened (since |
|
544 | + // instances get re-added by the select statement contained therein). |
|
545 | + ChannelTableMap::clearInstancePool(); |
|
546 | + ChannelTableMap::clearRelatedInstancePool(); |
|
547 | + |
|
548 | + return $affectedRows; |
|
549 | + }); |
|
550 | + } |
|
551 | + |
|
552 | + /** |
|
553 | + * Performs a DELETE on the database based on the current ModelCriteria |
|
554 | + * |
|
555 | + * @param ConnectionInterface $con the connection to use |
|
556 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
557 | + * if supported by native driver or if emulated using Propel. |
|
558 | + * @throws PropelException Any exceptions caught during processing will be |
|
559 | + * rethrown wrapped into a PropelException. |
|
560 | + */ |
|
561 | + public function delete(ConnectionInterface $con = null) |
|
562 | + { |
|
563 | + if (null === $con) { |
|
564 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
565 | + } |
|
566 | + |
|
567 | + $criteria = $this; |
|
568 | + |
|
569 | + // Set the correct dbName |
|
570 | + $criteria->setDbName(ChannelTableMap::DATABASE_NAME); |
|
571 | + |
|
572 | + // use transaction because $criteria could contain info |
|
573 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
574 | + return $con->transaction(function () use ($con, $criteria) { |
|
575 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
576 | + |
|
577 | + ChannelTableMap::removeInstanceFromPool($criteria); |
|
578 | + |
|
579 | + $affectedRows += ModelCriteria::delete($con); |
|
580 | + ChannelTableMap::clearRelatedInstancePool(); |
|
581 | + |
|
582 | + return $affectedRows; |
|
583 | + }); |
|
584 | + } |
|
586 | 585 | |
587 | 586 | } // ChannelQuery |
@@ -33,1555 +33,1555 @@ |
||
33 | 33 | */ |
34 | 34 | abstract class Connection implements ActiveRecordInterface |
35 | 35 | { |
36 | - /** |
|
37 | - * TableMap class name |
|
38 | - */ |
|
39 | - const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\ConnectionTableMap'; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * attribute to determine if this object has previously been saved. |
|
44 | - * @var boolean |
|
45 | - */ |
|
46 | - protected $new = true; |
|
47 | - |
|
48 | - /** |
|
49 | - * attribute to determine whether this object has been deleted. |
|
50 | - * @var boolean |
|
51 | - */ |
|
52 | - protected $deleted = false; |
|
53 | - |
|
54 | - /** |
|
55 | - * The columns that have been modified in current object. |
|
56 | - * Tracking modified columns allows us to only update modified columns. |
|
57 | - * @var array |
|
58 | - */ |
|
59 | - protected $modifiedColumns = array(); |
|
60 | - |
|
61 | - /** |
|
62 | - * The (virtual) columns that are added at runtime |
|
63 | - * The formatters can add supplementary columns based on a resultset |
|
64 | - * @var array |
|
65 | - */ |
|
66 | - protected $virtualColumns = array(); |
|
67 | - |
|
68 | - /** |
|
69 | - * The value for the id field. |
|
70 | - * |
|
71 | - * @var int |
|
72 | - */ |
|
73 | - protected $id; |
|
74 | - |
|
75 | - /** |
|
76 | - * The value for the instance_name field. |
|
77 | - * |
|
78 | - * @var string |
|
79 | - */ |
|
80 | - protected $instance_name; |
|
81 | - |
|
82 | - /** |
|
83 | - * The value for the user_id field. |
|
84 | - * |
|
85 | - * @var int |
|
86 | - */ |
|
87 | - protected $user_id; |
|
88 | - |
|
89 | - /** |
|
90 | - * The value for the peer field. |
|
91 | - * |
|
92 | - * @var string |
|
93 | - */ |
|
94 | - protected $peer; |
|
95 | - |
|
96 | - /** |
|
97 | - * The value for the started field. |
|
98 | - * |
|
99 | - * @var \DateTime |
|
100 | - */ |
|
101 | - protected $started; |
|
102 | - |
|
103 | - /** |
|
104 | - * The value for the type field. |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
108 | - protected $type; |
|
109 | - |
|
110 | - /** |
|
111 | - * @var ChildInstance |
|
112 | - */ |
|
113 | - protected $aInstance; |
|
114 | - |
|
115 | - /** |
|
116 | - * @var ChildUser |
|
117 | - */ |
|
118 | - protected $aUser; |
|
119 | - |
|
120 | - /** |
|
121 | - * Flag to prevent endless save loop, if this object is referenced |
|
122 | - * by another object which falls in this transaction. |
|
123 | - * |
|
124 | - * @var boolean |
|
125 | - */ |
|
126 | - protected $alreadyInSave = false; |
|
127 | - |
|
128 | - /** |
|
129 | - * Initializes internal state of Jalle19\StatusManager\Database\Base\Connection object. |
|
130 | - */ |
|
131 | - public function __construct() |
|
132 | - { |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * Returns whether the object has been modified. |
|
137 | - * |
|
138 | - * @return boolean True if the object has been modified. |
|
139 | - */ |
|
140 | - public function isModified() |
|
141 | - { |
|
142 | - return !!$this->modifiedColumns; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Has specified column been modified? |
|
147 | - * |
|
148 | - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
149 | - * @return boolean True if $col has been modified. |
|
150 | - */ |
|
151 | - public function isColumnModified($col) |
|
152 | - { |
|
153 | - return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Get the columns that have been modified in this object. |
|
158 | - * @return array A unique list of the modified column names for this object. |
|
159 | - */ |
|
160 | - public function getModifiedColumns() |
|
161 | - { |
|
162 | - return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Returns whether the object has ever been saved. This will |
|
167 | - * be false, if the object was retrieved from storage or was created |
|
168 | - * and then saved. |
|
169 | - * |
|
170 | - * @return boolean true, if the object has never been persisted. |
|
171 | - */ |
|
172 | - public function isNew() |
|
173 | - { |
|
174 | - return $this->new; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * Setter for the isNew attribute. This method will be called |
|
179 | - * by Propel-generated children and objects. |
|
180 | - * |
|
181 | - * @param boolean $b the state of the object. |
|
182 | - */ |
|
183 | - public function setNew($b) |
|
184 | - { |
|
185 | - $this->new = (boolean) $b; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Whether this object has been deleted. |
|
190 | - * @return boolean The deleted state of this object. |
|
191 | - */ |
|
192 | - public function isDeleted() |
|
193 | - { |
|
194 | - return $this->deleted; |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Specify whether this object has been deleted. |
|
199 | - * @param boolean $b The deleted state of this object. |
|
200 | - * @return void |
|
201 | - */ |
|
202 | - public function setDeleted($b) |
|
203 | - { |
|
204 | - $this->deleted = (boolean) $b; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Sets the modified state for the object to be false. |
|
209 | - * @param string $col If supplied, only the specified column is reset. |
|
210 | - * @return void |
|
211 | - */ |
|
212 | - public function resetModified($col = null) |
|
213 | - { |
|
214 | - if (null !== $col) { |
|
215 | - if (isset($this->modifiedColumns[$col])) { |
|
216 | - unset($this->modifiedColumns[$col]); |
|
217 | - } |
|
218 | - } else { |
|
219 | - $this->modifiedColumns = array(); |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Compares this with another <code>Connection</code> instance. If |
|
225 | - * <code>obj</code> is an instance of <code>Connection</code>, delegates to |
|
226 | - * <code>equals(Connection)</code>. Otherwise, returns <code>false</code>. |
|
227 | - * |
|
228 | - * @param mixed $obj The object to compare to. |
|
229 | - * @return boolean Whether equal to the object specified. |
|
230 | - */ |
|
231 | - public function equals($obj) |
|
232 | - { |
|
233 | - if (!$obj instanceof static) { |
|
234 | - return false; |
|
235 | - } |
|
236 | - |
|
237 | - if ($this === $obj) { |
|
238 | - return true; |
|
239 | - } |
|
240 | - |
|
241 | - if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
242 | - return false; |
|
243 | - } |
|
244 | - |
|
245 | - return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * Get the associative array of the virtual columns in this object |
|
250 | - * |
|
251 | - * @return array |
|
252 | - */ |
|
253 | - public function getVirtualColumns() |
|
254 | - { |
|
255 | - return $this->virtualColumns; |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Checks the existence of a virtual column in this object |
|
260 | - * |
|
261 | - * @param string $name The virtual column name |
|
262 | - * @return boolean |
|
263 | - */ |
|
264 | - public function hasVirtualColumn($name) |
|
265 | - { |
|
266 | - return array_key_exists($name, $this->virtualColumns); |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * Get the value of a virtual column in this object |
|
271 | - * |
|
272 | - * @param string $name The virtual column name |
|
273 | - * @return mixed |
|
274 | - * |
|
275 | - * @throws PropelException |
|
276 | - */ |
|
277 | - public function getVirtualColumn($name) |
|
278 | - { |
|
279 | - if (!$this->hasVirtualColumn($name)) { |
|
280 | - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
281 | - } |
|
282 | - |
|
283 | - return $this->virtualColumns[$name]; |
|
284 | - } |
|
285 | - |
|
286 | - /** |
|
287 | - * Set the value of a virtual column in this object |
|
288 | - * |
|
289 | - * @param string $name The virtual column name |
|
290 | - * @param mixed $value The value to give to the virtual column |
|
291 | - * |
|
292 | - * @return $this|Connection The current object, for fluid interface |
|
293 | - */ |
|
294 | - public function setVirtualColumn($name, $value) |
|
295 | - { |
|
296 | - $this->virtualColumns[$name] = $value; |
|
297 | - |
|
298 | - return $this; |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * Logs a message using Propel::log(). |
|
303 | - * |
|
304 | - * @param string $msg |
|
305 | - * @param int $priority One of the Propel::LOG_* logging levels |
|
306 | - * @return boolean |
|
307 | - */ |
|
308 | - protected function log($msg, $priority = Propel::LOG_INFO) |
|
309 | - { |
|
310 | - return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Export the current object properties to a string, using a given parser format |
|
315 | - * <code> |
|
316 | - * $book = BookQuery::create()->findPk(9012); |
|
317 | - * echo $book->exportTo('JSON'); |
|
318 | - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
319 | - * </code> |
|
320 | - * |
|
321 | - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
322 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
323 | - * @return string The exported data |
|
324 | - */ |
|
325 | - public function exportTo($parser, $includeLazyLoadColumns = true) |
|
326 | - { |
|
327 | - if (!$parser instanceof AbstractParser) { |
|
328 | - $parser = AbstractParser::getParser($parser); |
|
329 | - } |
|
330 | - |
|
331 | - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * Clean up internal collections prior to serializing |
|
336 | - * Avoids recursive loops that turn into segmentation faults when serializing |
|
337 | - */ |
|
338 | - public function __sleep() |
|
339 | - { |
|
340 | - $this->clearAllReferences(); |
|
341 | - |
|
342 | - $cls = new \ReflectionClass($this); |
|
343 | - $propertyNames = []; |
|
344 | - $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
345 | - |
|
346 | - foreach($serializableProperties as $property) { |
|
347 | - $propertyNames[] = $property->getName(); |
|
348 | - } |
|
349 | - |
|
350 | - return $propertyNames; |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Get the [id] column value. |
|
355 | - * |
|
356 | - * @return int |
|
357 | - */ |
|
358 | - public function getId() |
|
359 | - { |
|
360 | - return $this->id; |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Get the [instance_name] column value. |
|
365 | - * |
|
366 | - * @return string |
|
367 | - */ |
|
368 | - public function getInstanceName() |
|
369 | - { |
|
370 | - return $this->instance_name; |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Get the [user_id] column value. |
|
375 | - * |
|
376 | - * @return int |
|
377 | - */ |
|
378 | - public function getUserId() |
|
379 | - { |
|
380 | - return $this->user_id; |
|
381 | - } |
|
382 | - |
|
383 | - /** |
|
384 | - * Get the [peer] column value. |
|
385 | - * |
|
386 | - * @return string |
|
387 | - */ |
|
388 | - public function getPeer() |
|
389 | - { |
|
390 | - return $this->peer; |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Get the [optionally formatted] temporal [started] column value. |
|
395 | - * |
|
396 | - * |
|
397 | - * @param string $format The date/time format string (either date()-style or strftime()-style). |
|
398 | - * If format is NULL, then the raw DateTime object will be returned. |
|
399 | - * |
|
400 | - * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
|
401 | - * |
|
402 | - * @throws PropelException - if unable to parse/validate the date/time value. |
|
403 | - */ |
|
404 | - public function getStarted($format = NULL) |
|
405 | - { |
|
406 | - if ($format === null) { |
|
407 | - return $this->started; |
|
408 | - } else { |
|
409 | - return $this->started instanceof \DateTime ? $this->started->format($format) : null; |
|
410 | - } |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Get the [type] column value. |
|
415 | - * |
|
416 | - * @return string |
|
417 | - */ |
|
418 | - public function getType() |
|
419 | - { |
|
420 | - return $this->type; |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Set the value of [id] column. |
|
425 | - * |
|
426 | - * @param int $v new value |
|
427 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
428 | - */ |
|
429 | - public function setId($v) |
|
430 | - { |
|
431 | - if ($v !== null) { |
|
432 | - $v = (int) $v; |
|
433 | - } |
|
434 | - |
|
435 | - if ($this->id !== $v) { |
|
436 | - $this->id = $v; |
|
437 | - $this->modifiedColumns[ConnectionTableMap::COL_ID] = true; |
|
438 | - } |
|
439 | - |
|
440 | - return $this; |
|
441 | - } // setId() |
|
442 | - |
|
443 | - /** |
|
444 | - * Set the value of [instance_name] column. |
|
445 | - * |
|
446 | - * @param string $v new value |
|
447 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
448 | - */ |
|
449 | - public function setInstanceName($v) |
|
450 | - { |
|
451 | - if ($v !== null) { |
|
452 | - $v = (string) $v; |
|
453 | - } |
|
454 | - |
|
455 | - if ($this->instance_name !== $v) { |
|
456 | - $this->instance_name = $v; |
|
457 | - $this->modifiedColumns[ConnectionTableMap::COL_INSTANCE_NAME] = true; |
|
458 | - } |
|
459 | - |
|
460 | - if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
461 | - $this->aInstance = null; |
|
462 | - } |
|
463 | - |
|
464 | - return $this; |
|
465 | - } // setInstanceName() |
|
466 | - |
|
467 | - /** |
|
468 | - * Set the value of [user_id] column. |
|
469 | - * |
|
470 | - * @param int $v new value |
|
471 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
472 | - */ |
|
473 | - public function setUserId($v) |
|
474 | - { |
|
475 | - if ($v !== null) { |
|
476 | - $v = (int) $v; |
|
477 | - } |
|
478 | - |
|
479 | - if ($this->user_id !== $v) { |
|
480 | - $this->user_id = $v; |
|
481 | - $this->modifiedColumns[ConnectionTableMap::COL_USER_ID] = true; |
|
482 | - } |
|
483 | - |
|
484 | - if ($this->aUser !== null && $this->aUser->getId() !== $v) { |
|
485 | - $this->aUser = null; |
|
486 | - } |
|
487 | - |
|
488 | - return $this; |
|
489 | - } // setUserId() |
|
490 | - |
|
491 | - /** |
|
492 | - * Set the value of [peer] column. |
|
493 | - * |
|
494 | - * @param string $v new value |
|
495 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
496 | - */ |
|
497 | - public function setPeer($v) |
|
498 | - { |
|
499 | - if ($v !== null) { |
|
500 | - $v = (string) $v; |
|
501 | - } |
|
502 | - |
|
503 | - if ($this->peer !== $v) { |
|
504 | - $this->peer = $v; |
|
505 | - $this->modifiedColumns[ConnectionTableMap::COL_PEER] = true; |
|
506 | - } |
|
507 | - |
|
508 | - return $this; |
|
509 | - } // setPeer() |
|
510 | - |
|
511 | - /** |
|
512 | - * Sets the value of [started] column to a normalized version of the date/time value specified. |
|
513 | - * |
|
514 | - * @param mixed $v string, integer (timestamp), or \DateTime value. |
|
515 | - * Empty strings are treated as NULL. |
|
516 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
517 | - */ |
|
518 | - public function setStarted($v) |
|
519 | - { |
|
520 | - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
|
521 | - if ($this->started !== null || $dt !== null) { |
|
522 | - if ($this->started === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->started->format("Y-m-d H:i:s")) { |
|
523 | - $this->started = $dt === null ? null : clone $dt; |
|
524 | - $this->modifiedColumns[ConnectionTableMap::COL_STARTED] = true; |
|
525 | - } |
|
526 | - } // if either are not null |
|
527 | - |
|
528 | - return $this; |
|
529 | - } // setStarted() |
|
530 | - |
|
531 | - /** |
|
532 | - * Set the value of [type] column. |
|
533 | - * |
|
534 | - * @param string $v new value |
|
535 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
536 | - */ |
|
537 | - public function setType($v) |
|
538 | - { |
|
539 | - if ($v !== null) { |
|
540 | - $v = (string) $v; |
|
541 | - } |
|
542 | - |
|
543 | - if ($this->type !== $v) { |
|
544 | - $this->type = $v; |
|
545 | - $this->modifiedColumns[ConnectionTableMap::COL_TYPE] = true; |
|
546 | - } |
|
547 | - |
|
548 | - return $this; |
|
549 | - } // setType() |
|
550 | - |
|
551 | - /** |
|
552 | - * Indicates whether the columns in this object are only set to default values. |
|
553 | - * |
|
554 | - * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
555 | - * modified _and_ has some values set which are non-default. |
|
556 | - * |
|
557 | - * @return boolean Whether the columns in this object are only been set with default values. |
|
558 | - */ |
|
559 | - public function hasOnlyDefaultValues() |
|
560 | - { |
|
561 | - // otherwise, everything was equal, so return TRUE |
|
562 | - return true; |
|
563 | - } // hasOnlyDefaultValues() |
|
564 | - |
|
565 | - /** |
|
566 | - * Hydrates (populates) the object variables with values from the database resultset. |
|
567 | - * |
|
568 | - * An offset (0-based "start column") is specified so that objects can be hydrated |
|
569 | - * with a subset of the columns in the resultset rows. This is needed, for example, |
|
570 | - * for results of JOIN queries where the resultset row includes columns from two or |
|
571 | - * more tables. |
|
572 | - * |
|
573 | - * @param array $row The row returned by DataFetcher->fetch(). |
|
574 | - * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
575 | - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
576 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
36 | + /** |
|
37 | + * TableMap class name |
|
38 | + */ |
|
39 | + const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\ConnectionTableMap'; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * attribute to determine if this object has previously been saved. |
|
44 | + * @var boolean |
|
45 | + */ |
|
46 | + protected $new = true; |
|
47 | + |
|
48 | + /** |
|
49 | + * attribute to determine whether this object has been deleted. |
|
50 | + * @var boolean |
|
51 | + */ |
|
52 | + protected $deleted = false; |
|
53 | + |
|
54 | + /** |
|
55 | + * The columns that have been modified in current object. |
|
56 | + * Tracking modified columns allows us to only update modified columns. |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + protected $modifiedColumns = array(); |
|
60 | + |
|
61 | + /** |
|
62 | + * The (virtual) columns that are added at runtime |
|
63 | + * The formatters can add supplementary columns based on a resultset |
|
64 | + * @var array |
|
65 | + */ |
|
66 | + protected $virtualColumns = array(); |
|
67 | + |
|
68 | + /** |
|
69 | + * The value for the id field. |
|
70 | + * |
|
71 | + * @var int |
|
72 | + */ |
|
73 | + protected $id; |
|
74 | + |
|
75 | + /** |
|
76 | + * The value for the instance_name field. |
|
77 | + * |
|
78 | + * @var string |
|
79 | + */ |
|
80 | + protected $instance_name; |
|
81 | + |
|
82 | + /** |
|
83 | + * The value for the user_id field. |
|
84 | + * |
|
85 | + * @var int |
|
86 | + */ |
|
87 | + protected $user_id; |
|
88 | + |
|
89 | + /** |
|
90 | + * The value for the peer field. |
|
91 | + * |
|
92 | + * @var string |
|
93 | + */ |
|
94 | + protected $peer; |
|
95 | + |
|
96 | + /** |
|
97 | + * The value for the started field. |
|
98 | + * |
|
99 | + * @var \DateTime |
|
100 | + */ |
|
101 | + protected $started; |
|
102 | + |
|
103 | + /** |
|
104 | + * The value for the type field. |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | + protected $type; |
|
109 | + |
|
110 | + /** |
|
111 | + * @var ChildInstance |
|
112 | + */ |
|
113 | + protected $aInstance; |
|
114 | + |
|
115 | + /** |
|
116 | + * @var ChildUser |
|
117 | + */ |
|
118 | + protected $aUser; |
|
119 | + |
|
120 | + /** |
|
121 | + * Flag to prevent endless save loop, if this object is referenced |
|
122 | + * by another object which falls in this transaction. |
|
123 | + * |
|
124 | + * @var boolean |
|
125 | + */ |
|
126 | + protected $alreadyInSave = false; |
|
127 | + |
|
128 | + /** |
|
129 | + * Initializes internal state of Jalle19\StatusManager\Database\Base\Connection object. |
|
130 | + */ |
|
131 | + public function __construct() |
|
132 | + { |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * Returns whether the object has been modified. |
|
137 | + * |
|
138 | + * @return boolean True if the object has been modified. |
|
139 | + */ |
|
140 | + public function isModified() |
|
141 | + { |
|
142 | + return !!$this->modifiedColumns; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Has specified column been modified? |
|
147 | + * |
|
148 | + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
149 | + * @return boolean True if $col has been modified. |
|
150 | + */ |
|
151 | + public function isColumnModified($col) |
|
152 | + { |
|
153 | + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Get the columns that have been modified in this object. |
|
158 | + * @return array A unique list of the modified column names for this object. |
|
159 | + */ |
|
160 | + public function getModifiedColumns() |
|
161 | + { |
|
162 | + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Returns whether the object has ever been saved. This will |
|
167 | + * be false, if the object was retrieved from storage or was created |
|
168 | + * and then saved. |
|
169 | + * |
|
170 | + * @return boolean true, if the object has never been persisted. |
|
171 | + */ |
|
172 | + public function isNew() |
|
173 | + { |
|
174 | + return $this->new; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * Setter for the isNew attribute. This method will be called |
|
179 | + * by Propel-generated children and objects. |
|
180 | + * |
|
181 | + * @param boolean $b the state of the object. |
|
182 | + */ |
|
183 | + public function setNew($b) |
|
184 | + { |
|
185 | + $this->new = (boolean) $b; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Whether this object has been deleted. |
|
190 | + * @return boolean The deleted state of this object. |
|
191 | + */ |
|
192 | + public function isDeleted() |
|
193 | + { |
|
194 | + return $this->deleted; |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Specify whether this object has been deleted. |
|
199 | + * @param boolean $b The deleted state of this object. |
|
200 | + * @return void |
|
201 | + */ |
|
202 | + public function setDeleted($b) |
|
203 | + { |
|
204 | + $this->deleted = (boolean) $b; |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Sets the modified state for the object to be false. |
|
209 | + * @param string $col If supplied, only the specified column is reset. |
|
210 | + * @return void |
|
211 | + */ |
|
212 | + public function resetModified($col = null) |
|
213 | + { |
|
214 | + if (null !== $col) { |
|
215 | + if (isset($this->modifiedColumns[$col])) { |
|
216 | + unset($this->modifiedColumns[$col]); |
|
217 | + } |
|
218 | + } else { |
|
219 | + $this->modifiedColumns = array(); |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Compares this with another <code>Connection</code> instance. If |
|
225 | + * <code>obj</code> is an instance of <code>Connection</code>, delegates to |
|
226 | + * <code>equals(Connection)</code>. Otherwise, returns <code>false</code>. |
|
227 | + * |
|
228 | + * @param mixed $obj The object to compare to. |
|
229 | + * @return boolean Whether equal to the object specified. |
|
230 | + */ |
|
231 | + public function equals($obj) |
|
232 | + { |
|
233 | + if (!$obj instanceof static) { |
|
234 | + return false; |
|
235 | + } |
|
236 | + |
|
237 | + if ($this === $obj) { |
|
238 | + return true; |
|
239 | + } |
|
240 | + |
|
241 | + if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
242 | + return false; |
|
243 | + } |
|
244 | + |
|
245 | + return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * Get the associative array of the virtual columns in this object |
|
250 | + * |
|
251 | + * @return array |
|
252 | + */ |
|
253 | + public function getVirtualColumns() |
|
254 | + { |
|
255 | + return $this->virtualColumns; |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Checks the existence of a virtual column in this object |
|
260 | + * |
|
261 | + * @param string $name The virtual column name |
|
262 | + * @return boolean |
|
263 | + */ |
|
264 | + public function hasVirtualColumn($name) |
|
265 | + { |
|
266 | + return array_key_exists($name, $this->virtualColumns); |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * Get the value of a virtual column in this object |
|
271 | + * |
|
272 | + * @param string $name The virtual column name |
|
273 | + * @return mixed |
|
274 | + * |
|
275 | + * @throws PropelException |
|
276 | + */ |
|
277 | + public function getVirtualColumn($name) |
|
278 | + { |
|
279 | + if (!$this->hasVirtualColumn($name)) { |
|
280 | + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
281 | + } |
|
282 | + |
|
283 | + return $this->virtualColumns[$name]; |
|
284 | + } |
|
285 | + |
|
286 | + /** |
|
287 | + * Set the value of a virtual column in this object |
|
288 | + * |
|
289 | + * @param string $name The virtual column name |
|
290 | + * @param mixed $value The value to give to the virtual column |
|
291 | + * |
|
292 | + * @return $this|Connection The current object, for fluid interface |
|
293 | + */ |
|
294 | + public function setVirtualColumn($name, $value) |
|
295 | + { |
|
296 | + $this->virtualColumns[$name] = $value; |
|
297 | + |
|
298 | + return $this; |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Logs a message using Propel::log(). |
|
303 | + * |
|
304 | + * @param string $msg |
|
305 | + * @param int $priority One of the Propel::LOG_* logging levels |
|
306 | + * @return boolean |
|
307 | + */ |
|
308 | + protected function log($msg, $priority = Propel::LOG_INFO) |
|
309 | + { |
|
310 | + return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Export the current object properties to a string, using a given parser format |
|
315 | + * <code> |
|
316 | + * $book = BookQuery::create()->findPk(9012); |
|
317 | + * echo $book->exportTo('JSON'); |
|
318 | + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
319 | + * </code> |
|
320 | + * |
|
321 | + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
322 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
323 | + * @return string The exported data |
|
324 | + */ |
|
325 | + public function exportTo($parser, $includeLazyLoadColumns = true) |
|
326 | + { |
|
327 | + if (!$parser instanceof AbstractParser) { |
|
328 | + $parser = AbstractParser::getParser($parser); |
|
329 | + } |
|
330 | + |
|
331 | + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * Clean up internal collections prior to serializing |
|
336 | + * Avoids recursive loops that turn into segmentation faults when serializing |
|
337 | + */ |
|
338 | + public function __sleep() |
|
339 | + { |
|
340 | + $this->clearAllReferences(); |
|
341 | + |
|
342 | + $cls = new \ReflectionClass($this); |
|
343 | + $propertyNames = []; |
|
344 | + $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
345 | + |
|
346 | + foreach($serializableProperties as $property) { |
|
347 | + $propertyNames[] = $property->getName(); |
|
348 | + } |
|
349 | + |
|
350 | + return $propertyNames; |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * Get the [id] column value. |
|
355 | + * |
|
356 | + * @return int |
|
357 | + */ |
|
358 | + public function getId() |
|
359 | + { |
|
360 | + return $this->id; |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Get the [instance_name] column value. |
|
365 | + * |
|
366 | + * @return string |
|
367 | + */ |
|
368 | + public function getInstanceName() |
|
369 | + { |
|
370 | + return $this->instance_name; |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Get the [user_id] column value. |
|
375 | + * |
|
376 | + * @return int |
|
377 | + */ |
|
378 | + public function getUserId() |
|
379 | + { |
|
380 | + return $this->user_id; |
|
381 | + } |
|
382 | + |
|
383 | + /** |
|
384 | + * Get the [peer] column value. |
|
385 | + * |
|
386 | + * @return string |
|
387 | + */ |
|
388 | + public function getPeer() |
|
389 | + { |
|
390 | + return $this->peer; |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Get the [optionally formatted] temporal [started] column value. |
|
395 | + * |
|
396 | + * |
|
397 | + * @param string $format The date/time format string (either date()-style or strftime()-style). |
|
398 | + * If format is NULL, then the raw DateTime object will be returned. |
|
399 | + * |
|
400 | + * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
|
401 | + * |
|
402 | + * @throws PropelException - if unable to parse/validate the date/time value. |
|
403 | + */ |
|
404 | + public function getStarted($format = NULL) |
|
405 | + { |
|
406 | + if ($format === null) { |
|
407 | + return $this->started; |
|
408 | + } else { |
|
409 | + return $this->started instanceof \DateTime ? $this->started->format($format) : null; |
|
410 | + } |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Get the [type] column value. |
|
415 | + * |
|
416 | + * @return string |
|
417 | + */ |
|
418 | + public function getType() |
|
419 | + { |
|
420 | + return $this->type; |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * Set the value of [id] column. |
|
425 | + * |
|
426 | + * @param int $v new value |
|
427 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
428 | + */ |
|
429 | + public function setId($v) |
|
430 | + { |
|
431 | + if ($v !== null) { |
|
432 | + $v = (int) $v; |
|
433 | + } |
|
434 | + |
|
435 | + if ($this->id !== $v) { |
|
436 | + $this->id = $v; |
|
437 | + $this->modifiedColumns[ConnectionTableMap::COL_ID] = true; |
|
438 | + } |
|
439 | + |
|
440 | + return $this; |
|
441 | + } // setId() |
|
442 | + |
|
443 | + /** |
|
444 | + * Set the value of [instance_name] column. |
|
445 | + * |
|
446 | + * @param string $v new value |
|
447 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
448 | + */ |
|
449 | + public function setInstanceName($v) |
|
450 | + { |
|
451 | + if ($v !== null) { |
|
452 | + $v = (string) $v; |
|
453 | + } |
|
454 | + |
|
455 | + if ($this->instance_name !== $v) { |
|
456 | + $this->instance_name = $v; |
|
457 | + $this->modifiedColumns[ConnectionTableMap::COL_INSTANCE_NAME] = true; |
|
458 | + } |
|
459 | + |
|
460 | + if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
461 | + $this->aInstance = null; |
|
462 | + } |
|
463 | + |
|
464 | + return $this; |
|
465 | + } // setInstanceName() |
|
466 | + |
|
467 | + /** |
|
468 | + * Set the value of [user_id] column. |
|
469 | + * |
|
470 | + * @param int $v new value |
|
471 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
472 | + */ |
|
473 | + public function setUserId($v) |
|
474 | + { |
|
475 | + if ($v !== null) { |
|
476 | + $v = (int) $v; |
|
477 | + } |
|
478 | + |
|
479 | + if ($this->user_id !== $v) { |
|
480 | + $this->user_id = $v; |
|
481 | + $this->modifiedColumns[ConnectionTableMap::COL_USER_ID] = true; |
|
482 | + } |
|
483 | + |
|
484 | + if ($this->aUser !== null && $this->aUser->getId() !== $v) { |
|
485 | + $this->aUser = null; |
|
486 | + } |
|
487 | + |
|
488 | + return $this; |
|
489 | + } // setUserId() |
|
490 | + |
|
491 | + /** |
|
492 | + * Set the value of [peer] column. |
|
493 | + * |
|
494 | + * @param string $v new value |
|
495 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
496 | + */ |
|
497 | + public function setPeer($v) |
|
498 | + { |
|
499 | + if ($v !== null) { |
|
500 | + $v = (string) $v; |
|
501 | + } |
|
502 | + |
|
503 | + if ($this->peer !== $v) { |
|
504 | + $this->peer = $v; |
|
505 | + $this->modifiedColumns[ConnectionTableMap::COL_PEER] = true; |
|
506 | + } |
|
507 | + |
|
508 | + return $this; |
|
509 | + } // setPeer() |
|
510 | + |
|
511 | + /** |
|
512 | + * Sets the value of [started] column to a normalized version of the date/time value specified. |
|
513 | + * |
|
514 | + * @param mixed $v string, integer (timestamp), or \DateTime value. |
|
515 | + * Empty strings are treated as NULL. |
|
516 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
517 | + */ |
|
518 | + public function setStarted($v) |
|
519 | + { |
|
520 | + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
|
521 | + if ($this->started !== null || $dt !== null) { |
|
522 | + if ($this->started === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->started->format("Y-m-d H:i:s")) { |
|
523 | + $this->started = $dt === null ? null : clone $dt; |
|
524 | + $this->modifiedColumns[ConnectionTableMap::COL_STARTED] = true; |
|
525 | + } |
|
526 | + } // if either are not null |
|
527 | + |
|
528 | + return $this; |
|
529 | + } // setStarted() |
|
530 | + |
|
531 | + /** |
|
532 | + * Set the value of [type] column. |
|
533 | + * |
|
534 | + * @param string $v new value |
|
535 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
536 | + */ |
|
537 | + public function setType($v) |
|
538 | + { |
|
539 | + if ($v !== null) { |
|
540 | + $v = (string) $v; |
|
541 | + } |
|
542 | + |
|
543 | + if ($this->type !== $v) { |
|
544 | + $this->type = $v; |
|
545 | + $this->modifiedColumns[ConnectionTableMap::COL_TYPE] = true; |
|
546 | + } |
|
547 | + |
|
548 | + return $this; |
|
549 | + } // setType() |
|
550 | + |
|
551 | + /** |
|
552 | + * Indicates whether the columns in this object are only set to default values. |
|
553 | + * |
|
554 | + * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
555 | + * modified _and_ has some values set which are non-default. |
|
556 | + * |
|
557 | + * @return boolean Whether the columns in this object are only been set with default values. |
|
558 | + */ |
|
559 | + public function hasOnlyDefaultValues() |
|
560 | + { |
|
561 | + // otherwise, everything was equal, so return TRUE |
|
562 | + return true; |
|
563 | + } // hasOnlyDefaultValues() |
|
564 | + |
|
565 | + /** |
|
566 | + * Hydrates (populates) the object variables with values from the database resultset. |
|
567 | + * |
|
568 | + * An offset (0-based "start column") is specified so that objects can be hydrated |
|
569 | + * with a subset of the columns in the resultset rows. This is needed, for example, |
|
570 | + * for results of JOIN queries where the resultset row includes columns from two or |
|
571 | + * more tables. |
|
572 | + * |
|
573 | + * @param array $row The row returned by DataFetcher->fetch(). |
|
574 | + * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
575 | + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
576 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
577 | 577 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
578 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
579 | - * |
|
580 | - * @return int next starting column |
|
581 | - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
582 | - */ |
|
583 | - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
584 | - { |
|
585 | - try { |
|
586 | - |
|
587 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ConnectionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
588 | - $this->id = (null !== $col) ? (int) $col : null; |
|
589 | - |
|
590 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ConnectionTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
591 | - $this->instance_name = (null !== $col) ? (string) $col : null; |
|
592 | - |
|
593 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ConnectionTableMap::translateFieldName('UserId', TableMap::TYPE_PHPNAME, $indexType)]; |
|
594 | - $this->user_id = (null !== $col) ? (int) $col : null; |
|
595 | - |
|
596 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ConnectionTableMap::translateFieldName('Peer', TableMap::TYPE_PHPNAME, $indexType)]; |
|
597 | - $this->peer = (null !== $col) ? (string) $col : null; |
|
598 | - |
|
599 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ConnectionTableMap::translateFieldName('Started', TableMap::TYPE_PHPNAME, $indexType)]; |
|
600 | - $this->started = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
|
601 | - |
|
602 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ConnectionTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; |
|
603 | - $this->type = (null !== $col) ? (string) $col : null; |
|
604 | - $this->resetModified(); |
|
605 | - |
|
606 | - $this->setNew(false); |
|
607 | - |
|
608 | - if ($rehydrate) { |
|
609 | - $this->ensureConsistency(); |
|
610 | - } |
|
611 | - |
|
612 | - return $startcol + 6; // 6 = ConnectionTableMap::NUM_HYDRATE_COLUMNS. |
|
613 | - |
|
614 | - } catch (Exception $e) { |
|
615 | - throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Connection'), 0, $e); |
|
616 | - } |
|
617 | - } |
|
618 | - |
|
619 | - /** |
|
620 | - * Checks and repairs the internal consistency of the object. |
|
621 | - * |
|
622 | - * This method is executed after an already-instantiated object is re-hydrated |
|
623 | - * from the database. It exists to check any foreign keys to make sure that |
|
624 | - * the objects related to the current object are correct based on foreign key. |
|
625 | - * |
|
626 | - * You can override this method in the stub class, but you should always invoke |
|
627 | - * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
628 | - * in case your model changes. |
|
629 | - * |
|
630 | - * @throws PropelException |
|
631 | - */ |
|
632 | - public function ensureConsistency() |
|
633 | - { |
|
634 | - if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
635 | - $this->aInstance = null; |
|
636 | - } |
|
637 | - if ($this->aUser !== null && $this->user_id !== $this->aUser->getId()) { |
|
638 | - $this->aUser = null; |
|
639 | - } |
|
640 | - } // ensureConsistency |
|
641 | - |
|
642 | - /** |
|
643 | - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
644 | - * |
|
645 | - * This will only work if the object has been saved and has a valid primary key set. |
|
646 | - * |
|
647 | - * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
648 | - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
649 | - * @return void |
|
650 | - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
651 | - */ |
|
652 | - public function reload($deep = false, ConnectionInterface $con = null) |
|
653 | - { |
|
654 | - if ($this->isDeleted()) { |
|
655 | - throw new PropelException("Cannot reload a deleted object."); |
|
656 | - } |
|
657 | - |
|
658 | - if ($this->isNew()) { |
|
659 | - throw new PropelException("Cannot reload an unsaved object."); |
|
660 | - } |
|
661 | - |
|
662 | - if ($con === null) { |
|
663 | - $con = Propel::getServiceContainer()->getReadConnection(ConnectionTableMap::DATABASE_NAME); |
|
664 | - } |
|
665 | - |
|
666 | - // We don't need to alter the object instance pool; we're just modifying this instance |
|
667 | - // already in the pool. |
|
668 | - |
|
669 | - $dataFetcher = ChildConnectionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
670 | - $row = $dataFetcher->fetch(); |
|
671 | - $dataFetcher->close(); |
|
672 | - if (!$row) { |
|
673 | - throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
674 | - } |
|
675 | - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
676 | - |
|
677 | - if ($deep) { // also de-associate any related objects? |
|
678 | - |
|
679 | - $this->aInstance = null; |
|
680 | - $this->aUser = null; |
|
681 | - } // if (deep) |
|
682 | - } |
|
683 | - |
|
684 | - /** |
|
685 | - * Removes this object from datastore and sets delete attribute. |
|
686 | - * |
|
687 | - * @param ConnectionInterface $con |
|
688 | - * @return void |
|
689 | - * @throws PropelException |
|
690 | - * @see Connection::setDeleted() |
|
691 | - * @see Connection::isDeleted() |
|
692 | - */ |
|
693 | - public function delete(ConnectionInterface $con = null) |
|
694 | - { |
|
695 | - if ($this->isDeleted()) { |
|
696 | - throw new PropelException("This object has already been deleted."); |
|
697 | - } |
|
698 | - |
|
699 | - if ($con === null) { |
|
700 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
701 | - } |
|
702 | - |
|
703 | - $con->transaction(function () use ($con) { |
|
704 | - $deleteQuery = ChildConnectionQuery::create() |
|
705 | - ->filterByPrimaryKey($this->getPrimaryKey()); |
|
706 | - $ret = $this->preDelete($con); |
|
707 | - if ($ret) { |
|
708 | - $deleteQuery->delete($con); |
|
709 | - $this->postDelete($con); |
|
710 | - $this->setDeleted(true); |
|
711 | - } |
|
712 | - }); |
|
713 | - } |
|
714 | - |
|
715 | - /** |
|
716 | - * Persists this object to the database. |
|
717 | - * |
|
718 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
719 | - * All modified related objects will also be persisted in the doSave() |
|
720 | - * method. This method wraps all precipitate database operations in a |
|
721 | - * single transaction. |
|
722 | - * |
|
723 | - * @param ConnectionInterface $con |
|
724 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
725 | - * @throws PropelException |
|
726 | - * @see doSave() |
|
727 | - */ |
|
728 | - public function save(ConnectionInterface $con = null) |
|
729 | - { |
|
730 | - if ($this->isDeleted()) { |
|
731 | - throw new PropelException("You cannot save an object that has been deleted."); |
|
732 | - } |
|
733 | - |
|
734 | - if ($con === null) { |
|
735 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
736 | - } |
|
737 | - |
|
738 | - return $con->transaction(function () use ($con) { |
|
739 | - $isInsert = $this->isNew(); |
|
740 | - $ret = $this->preSave($con); |
|
741 | - if ($isInsert) { |
|
742 | - $ret = $ret && $this->preInsert($con); |
|
743 | - } else { |
|
744 | - $ret = $ret && $this->preUpdate($con); |
|
745 | - } |
|
746 | - if ($ret) { |
|
747 | - $affectedRows = $this->doSave($con); |
|
748 | - if ($isInsert) { |
|
749 | - $this->postInsert($con); |
|
750 | - } else { |
|
751 | - $this->postUpdate($con); |
|
752 | - } |
|
753 | - $this->postSave($con); |
|
754 | - ConnectionTableMap::addInstanceToPool($this); |
|
755 | - } else { |
|
756 | - $affectedRows = 0; |
|
757 | - } |
|
758 | - |
|
759 | - return $affectedRows; |
|
760 | - }); |
|
761 | - } |
|
762 | - |
|
763 | - /** |
|
764 | - * Performs the work of inserting or updating the row in the database. |
|
765 | - * |
|
766 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
767 | - * All related objects are also updated in this method. |
|
768 | - * |
|
769 | - * @param ConnectionInterface $con |
|
770 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
771 | - * @throws PropelException |
|
772 | - * @see save() |
|
773 | - */ |
|
774 | - protected function doSave(ConnectionInterface $con) |
|
775 | - { |
|
776 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
777 | - if (!$this->alreadyInSave) { |
|
778 | - $this->alreadyInSave = true; |
|
779 | - |
|
780 | - // We call the save method on the following object(s) if they |
|
781 | - // were passed to this object by their corresponding set |
|
782 | - // method. This object relates to these object(s) by a |
|
783 | - // foreign key reference. |
|
784 | - |
|
785 | - if ($this->aInstance !== null) { |
|
786 | - if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
787 | - $affectedRows += $this->aInstance->save($con); |
|
788 | - } |
|
789 | - $this->setInstance($this->aInstance); |
|
790 | - } |
|
791 | - |
|
792 | - if ($this->aUser !== null) { |
|
793 | - if ($this->aUser->isModified() || $this->aUser->isNew()) { |
|
794 | - $affectedRows += $this->aUser->save($con); |
|
795 | - } |
|
796 | - $this->setUser($this->aUser); |
|
797 | - } |
|
798 | - |
|
799 | - if ($this->isNew() || $this->isModified()) { |
|
800 | - // persist changes |
|
801 | - if ($this->isNew()) { |
|
802 | - $this->doInsert($con); |
|
803 | - $affectedRows += 1; |
|
804 | - } else { |
|
805 | - $affectedRows += $this->doUpdate($con); |
|
806 | - } |
|
807 | - $this->resetModified(); |
|
808 | - } |
|
809 | - |
|
810 | - $this->alreadyInSave = false; |
|
811 | - |
|
812 | - } |
|
813 | - |
|
814 | - return $affectedRows; |
|
815 | - } // doSave() |
|
816 | - |
|
817 | - /** |
|
818 | - * Insert the row in the database. |
|
819 | - * |
|
820 | - * @param ConnectionInterface $con |
|
821 | - * |
|
822 | - * @throws PropelException |
|
823 | - * @see doSave() |
|
824 | - */ |
|
825 | - protected function doInsert(ConnectionInterface $con) |
|
826 | - { |
|
827 | - $modifiedColumns = array(); |
|
828 | - $index = 0; |
|
829 | - |
|
830 | - $this->modifiedColumns[ConnectionTableMap::COL_ID] = true; |
|
831 | - if (null !== $this->id) { |
|
832 | - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConnectionTableMap::COL_ID . ')'); |
|
833 | - } |
|
834 | - |
|
835 | - // check the columns in natural order for more readable SQL queries |
|
836 | - if ($this->isColumnModified(ConnectionTableMap::COL_ID)) { |
|
837 | - $modifiedColumns[':p' . $index++] = 'id'; |
|
838 | - } |
|
839 | - if ($this->isColumnModified(ConnectionTableMap::COL_INSTANCE_NAME)) { |
|
840 | - $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
841 | - } |
|
842 | - if ($this->isColumnModified(ConnectionTableMap::COL_USER_ID)) { |
|
843 | - $modifiedColumns[':p' . $index++] = 'user_id'; |
|
844 | - } |
|
845 | - if ($this->isColumnModified(ConnectionTableMap::COL_PEER)) { |
|
846 | - $modifiedColumns[':p' . $index++] = 'peer'; |
|
847 | - } |
|
848 | - if ($this->isColumnModified(ConnectionTableMap::COL_STARTED)) { |
|
849 | - $modifiedColumns[':p' . $index++] = 'started'; |
|
850 | - } |
|
851 | - if ($this->isColumnModified(ConnectionTableMap::COL_TYPE)) { |
|
852 | - $modifiedColumns[':p' . $index++] = 'type'; |
|
853 | - } |
|
854 | - |
|
855 | - $sql = sprintf( |
|
856 | - 'INSERT INTO connection (%s) VALUES (%s)', |
|
857 | - implode(', ', $modifiedColumns), |
|
858 | - implode(', ', array_keys($modifiedColumns)) |
|
859 | - ); |
|
860 | - |
|
861 | - try { |
|
862 | - $stmt = $con->prepare($sql); |
|
863 | - foreach ($modifiedColumns as $identifier => $columnName) { |
|
864 | - switch ($columnName) { |
|
865 | - case 'id': |
|
866 | - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
867 | - break; |
|
868 | - case 'instance_name': |
|
869 | - $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
870 | - break; |
|
871 | - case 'user_id': |
|
872 | - $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT); |
|
873 | - break; |
|
874 | - case 'peer': |
|
875 | - $stmt->bindValue($identifier, $this->peer, PDO::PARAM_STR); |
|
876 | - break; |
|
877 | - case 'started': |
|
878 | - $stmt->bindValue($identifier, $this->started ? $this->started->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
|
879 | - break; |
|
880 | - case 'type': |
|
881 | - $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); |
|
882 | - break; |
|
883 | - } |
|
884 | - } |
|
885 | - $stmt->execute(); |
|
886 | - } catch (Exception $e) { |
|
887 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
888 | - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
889 | - } |
|
890 | - |
|
891 | - try { |
|
892 | - $pk = $con->lastInsertId(); |
|
893 | - } catch (Exception $e) { |
|
894 | - throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
895 | - } |
|
896 | - $this->setId($pk); |
|
897 | - |
|
898 | - $this->setNew(false); |
|
899 | - } |
|
900 | - |
|
901 | - /** |
|
902 | - * Update the row in the database. |
|
903 | - * |
|
904 | - * @param ConnectionInterface $con |
|
905 | - * |
|
906 | - * @return Integer Number of updated rows |
|
907 | - * @see doSave() |
|
908 | - */ |
|
909 | - protected function doUpdate(ConnectionInterface $con) |
|
910 | - { |
|
911 | - $selectCriteria = $this->buildPkeyCriteria(); |
|
912 | - $valuesCriteria = $this->buildCriteria(); |
|
913 | - |
|
914 | - return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
915 | - } |
|
916 | - |
|
917 | - /** |
|
918 | - * Retrieves a field from the object by name passed in as a string. |
|
919 | - * |
|
920 | - * @param string $name name |
|
921 | - * @param string $type The type of fieldname the $name is of: |
|
922 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
923 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
924 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
925 | - * @return mixed Value of field. |
|
926 | - */ |
|
927 | - public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
928 | - { |
|
929 | - $pos = ConnectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
930 | - $field = $this->getByPosition($pos); |
|
931 | - |
|
932 | - return $field; |
|
933 | - } |
|
934 | - |
|
935 | - /** |
|
936 | - * Retrieves a field from the object by Position as specified in the xml schema. |
|
937 | - * Zero-based. |
|
938 | - * |
|
939 | - * @param int $pos position in xml schema |
|
940 | - * @return mixed Value of field at $pos |
|
941 | - */ |
|
942 | - public function getByPosition($pos) |
|
943 | - { |
|
944 | - switch ($pos) { |
|
945 | - case 0: |
|
946 | - return $this->getId(); |
|
947 | - break; |
|
948 | - case 1: |
|
949 | - return $this->getInstanceName(); |
|
950 | - break; |
|
951 | - case 2: |
|
952 | - return $this->getUserId(); |
|
953 | - break; |
|
954 | - case 3: |
|
955 | - return $this->getPeer(); |
|
956 | - break; |
|
957 | - case 4: |
|
958 | - return $this->getStarted(); |
|
959 | - break; |
|
960 | - case 5: |
|
961 | - return $this->getType(); |
|
962 | - break; |
|
963 | - default: |
|
964 | - return null; |
|
965 | - break; |
|
966 | - } // switch() |
|
967 | - } |
|
968 | - |
|
969 | - /** |
|
970 | - * Exports the object as an array. |
|
971 | - * |
|
972 | - * You can specify the key type of the array by passing one of the class |
|
973 | - * type constants. |
|
974 | - * |
|
975 | - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
976 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
977 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
978 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
979 | - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
980 | - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
981 | - * |
|
982 | - * @return array an associative array containing the field names (as keys) and field values |
|
983 | - */ |
|
984 | - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
985 | - { |
|
986 | - |
|
987 | - if (isset($alreadyDumpedObjects['Connection'][$this->hashCode()])) { |
|
988 | - return '*RECURSION*'; |
|
989 | - } |
|
990 | - $alreadyDumpedObjects['Connection'][$this->hashCode()] = true; |
|
991 | - $keys = ConnectionTableMap::getFieldNames($keyType); |
|
992 | - $result = array( |
|
993 | - $keys[0] => $this->getId(), |
|
994 | - $keys[1] => $this->getInstanceName(), |
|
995 | - $keys[2] => $this->getUserId(), |
|
996 | - $keys[3] => $this->getPeer(), |
|
997 | - $keys[4] => $this->getStarted(), |
|
998 | - $keys[5] => $this->getType(), |
|
999 | - ); |
|
1000 | - if ($result[$keys[4]] instanceof \DateTime) { |
|
1001 | - $result[$keys[4]] = $result[$keys[4]]->format('c'); |
|
1002 | - } |
|
1003 | - |
|
1004 | - $virtualColumns = $this->virtualColumns; |
|
1005 | - foreach ($virtualColumns as $key => $virtualColumn) { |
|
1006 | - $result[$key] = $virtualColumn; |
|
1007 | - } |
|
1008 | - |
|
1009 | - if ($includeForeignObjects) { |
|
1010 | - if (null !== $this->aInstance) { |
|
1011 | - |
|
1012 | - switch ($keyType) { |
|
1013 | - case TableMap::TYPE_CAMELNAME: |
|
1014 | - $key = 'instance'; |
|
1015 | - break; |
|
1016 | - case TableMap::TYPE_FIELDNAME: |
|
1017 | - $key = 'instance'; |
|
1018 | - break; |
|
1019 | - default: |
|
1020 | - $key = 'Instance'; |
|
1021 | - } |
|
1022 | - |
|
1023 | - $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
1024 | - } |
|
1025 | - if (null !== $this->aUser) { |
|
1026 | - |
|
1027 | - switch ($keyType) { |
|
1028 | - case TableMap::TYPE_CAMELNAME: |
|
1029 | - $key = 'user'; |
|
1030 | - break; |
|
1031 | - case TableMap::TYPE_FIELDNAME: |
|
1032 | - $key = 'user'; |
|
1033 | - break; |
|
1034 | - default: |
|
1035 | - $key = 'User'; |
|
1036 | - } |
|
1037 | - |
|
1038 | - $result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
1039 | - } |
|
1040 | - } |
|
1041 | - |
|
1042 | - return $result; |
|
1043 | - } |
|
1044 | - |
|
1045 | - /** |
|
1046 | - * Sets a field from the object by name passed in as a string. |
|
1047 | - * |
|
1048 | - * @param string $name |
|
1049 | - * @param mixed $value field value |
|
1050 | - * @param string $type The type of fieldname the $name is of: |
|
1051 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
1052 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
1053 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
1054 | - * @return $this|\Jalle19\StatusManager\Database\Connection |
|
1055 | - */ |
|
1056 | - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
1057 | - { |
|
1058 | - $pos = ConnectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
1059 | - |
|
1060 | - return $this->setByPosition($pos, $value); |
|
1061 | - } |
|
1062 | - |
|
1063 | - /** |
|
1064 | - * Sets a field from the object by Position as specified in the xml schema. |
|
1065 | - * Zero-based. |
|
1066 | - * |
|
1067 | - * @param int $pos position in xml schema |
|
1068 | - * @param mixed $value field value |
|
1069 | - * @return $this|\Jalle19\StatusManager\Database\Connection |
|
1070 | - */ |
|
1071 | - public function setByPosition($pos, $value) |
|
1072 | - { |
|
1073 | - switch ($pos) { |
|
1074 | - case 0: |
|
1075 | - $this->setId($value); |
|
1076 | - break; |
|
1077 | - case 1: |
|
1078 | - $this->setInstanceName($value); |
|
1079 | - break; |
|
1080 | - case 2: |
|
1081 | - $this->setUserId($value); |
|
1082 | - break; |
|
1083 | - case 3: |
|
1084 | - $this->setPeer($value); |
|
1085 | - break; |
|
1086 | - case 4: |
|
1087 | - $this->setStarted($value); |
|
1088 | - break; |
|
1089 | - case 5: |
|
1090 | - $this->setType($value); |
|
1091 | - break; |
|
1092 | - } // switch() |
|
1093 | - |
|
1094 | - return $this; |
|
1095 | - } |
|
1096 | - |
|
1097 | - /** |
|
1098 | - * Populates the object using an array. |
|
1099 | - * |
|
1100 | - * This is particularly useful when populating an object from one of the |
|
1101 | - * request arrays (e.g. $_POST). This method goes through the column |
|
1102 | - * names, checking to see whether a matching key exists in populated |
|
1103 | - * array. If so the setByName() method is called for that column. |
|
1104 | - * |
|
1105 | - * You can specify the key type of the array by additionally passing one |
|
1106 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
1107 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
1108 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
1109 | - * |
|
1110 | - * @param array $arr An array to populate the object from. |
|
1111 | - * @param string $keyType The type of keys the array uses. |
|
1112 | - * @return void |
|
1113 | - */ |
|
1114 | - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
1115 | - { |
|
1116 | - $keys = ConnectionTableMap::getFieldNames($keyType); |
|
1117 | - |
|
1118 | - if (array_key_exists($keys[0], $arr)) { |
|
1119 | - $this->setId($arr[$keys[0]]); |
|
1120 | - } |
|
1121 | - if (array_key_exists($keys[1], $arr)) { |
|
1122 | - $this->setInstanceName($arr[$keys[1]]); |
|
1123 | - } |
|
1124 | - if (array_key_exists($keys[2], $arr)) { |
|
1125 | - $this->setUserId($arr[$keys[2]]); |
|
1126 | - } |
|
1127 | - if (array_key_exists($keys[3], $arr)) { |
|
1128 | - $this->setPeer($arr[$keys[3]]); |
|
1129 | - } |
|
1130 | - if (array_key_exists($keys[4], $arr)) { |
|
1131 | - $this->setStarted($arr[$keys[4]]); |
|
1132 | - } |
|
1133 | - if (array_key_exists($keys[5], $arr)) { |
|
1134 | - $this->setType($arr[$keys[5]]); |
|
1135 | - } |
|
1136 | - } |
|
1137 | - |
|
1138 | - /** |
|
1139 | - * Populate the current object from a string, using a given parser format |
|
1140 | - * <code> |
|
1141 | - * $book = new Book(); |
|
1142 | - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
1143 | - * </code> |
|
1144 | - * |
|
1145 | - * You can specify the key type of the array by additionally passing one |
|
1146 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
1147 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
1148 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
1149 | - * |
|
1150 | - * @param mixed $parser A AbstractParser instance, |
|
1151 | - * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
1152 | - * @param string $data The source data to import from |
|
1153 | - * @param string $keyType The type of keys the array uses. |
|
1154 | - * |
|
1155 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object, for fluid interface |
|
1156 | - */ |
|
1157 | - public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
1158 | - { |
|
1159 | - if (!$parser instanceof AbstractParser) { |
|
1160 | - $parser = AbstractParser::getParser($parser); |
|
1161 | - } |
|
1162 | - |
|
1163 | - $this->fromArray($parser->toArray($data), $keyType); |
|
1164 | - |
|
1165 | - return $this; |
|
1166 | - } |
|
1167 | - |
|
1168 | - /** |
|
1169 | - * Build a Criteria object containing the values of all modified columns in this object. |
|
1170 | - * |
|
1171 | - * @return Criteria The Criteria object containing all modified values. |
|
1172 | - */ |
|
1173 | - public function buildCriteria() |
|
1174 | - { |
|
1175 | - $criteria = new Criteria(ConnectionTableMap::DATABASE_NAME); |
|
1176 | - |
|
1177 | - if ($this->isColumnModified(ConnectionTableMap::COL_ID)) { |
|
1178 | - $criteria->add(ConnectionTableMap::COL_ID, $this->id); |
|
1179 | - } |
|
1180 | - if ($this->isColumnModified(ConnectionTableMap::COL_INSTANCE_NAME)) { |
|
1181 | - $criteria->add(ConnectionTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
1182 | - } |
|
1183 | - if ($this->isColumnModified(ConnectionTableMap::COL_USER_ID)) { |
|
1184 | - $criteria->add(ConnectionTableMap::COL_USER_ID, $this->user_id); |
|
1185 | - } |
|
1186 | - if ($this->isColumnModified(ConnectionTableMap::COL_PEER)) { |
|
1187 | - $criteria->add(ConnectionTableMap::COL_PEER, $this->peer); |
|
1188 | - } |
|
1189 | - if ($this->isColumnModified(ConnectionTableMap::COL_STARTED)) { |
|
1190 | - $criteria->add(ConnectionTableMap::COL_STARTED, $this->started); |
|
1191 | - } |
|
1192 | - if ($this->isColumnModified(ConnectionTableMap::COL_TYPE)) { |
|
1193 | - $criteria->add(ConnectionTableMap::COL_TYPE, $this->type); |
|
1194 | - } |
|
1195 | - |
|
1196 | - return $criteria; |
|
1197 | - } |
|
1198 | - |
|
1199 | - /** |
|
1200 | - * Builds a Criteria object containing the primary key for this object. |
|
1201 | - * |
|
1202 | - * Unlike buildCriteria() this method includes the primary key values regardless |
|
1203 | - * of whether or not they have been modified. |
|
1204 | - * |
|
1205 | - * @throws LogicException if no primary key is defined |
|
1206 | - * |
|
1207 | - * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
1208 | - */ |
|
1209 | - public function buildPkeyCriteria() |
|
1210 | - { |
|
1211 | - $criteria = ChildConnectionQuery::create(); |
|
1212 | - $criteria->add(ConnectionTableMap::COL_ID, $this->id); |
|
1213 | - |
|
1214 | - return $criteria; |
|
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * If the primary key is not null, return the hashcode of the |
|
1219 | - * primary key. Otherwise, return the hash code of the object. |
|
1220 | - * |
|
1221 | - * @return int Hashcode |
|
1222 | - */ |
|
1223 | - public function hashCode() |
|
1224 | - { |
|
1225 | - $validPk = null !== $this->getId(); |
|
1226 | - |
|
1227 | - $validPrimaryKeyFKs = 0; |
|
1228 | - $primaryKeyFKs = []; |
|
1229 | - |
|
1230 | - if ($validPk) { |
|
1231 | - return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
1232 | - } elseif ($validPrimaryKeyFKs) { |
|
1233 | - return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
1234 | - } |
|
1235 | - |
|
1236 | - return spl_object_hash($this); |
|
1237 | - } |
|
1238 | - |
|
1239 | - /** |
|
1240 | - * Returns the primary key for this object (row). |
|
1241 | - * @return int |
|
1242 | - */ |
|
1243 | - public function getPrimaryKey() |
|
1244 | - { |
|
1245 | - return $this->getId(); |
|
1246 | - } |
|
1247 | - |
|
1248 | - /** |
|
1249 | - * Generic method to set the primary key (id column). |
|
1250 | - * |
|
1251 | - * @param int $key Primary key. |
|
1252 | - * @return void |
|
1253 | - */ |
|
1254 | - public function setPrimaryKey($key) |
|
1255 | - { |
|
1256 | - $this->setId($key); |
|
1257 | - } |
|
1258 | - |
|
1259 | - /** |
|
1260 | - * Returns true if the primary key for this object is null. |
|
1261 | - * @return boolean |
|
1262 | - */ |
|
1263 | - public function isPrimaryKeyNull() |
|
1264 | - { |
|
1265 | - return null === $this->getId(); |
|
1266 | - } |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * Sets contents of passed object to values from current object. |
|
1270 | - * |
|
1271 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
1272 | - * objects. |
|
1273 | - * |
|
1274 | - * @param object $copyObj An object of \Jalle19\StatusManager\Database\Connection (or compatible) type. |
|
1275 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
1276 | - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
1277 | - * @throws PropelException |
|
1278 | - */ |
|
1279 | - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
1280 | - { |
|
1281 | - $copyObj->setInstanceName($this->getInstanceName()); |
|
1282 | - $copyObj->setUserId($this->getUserId()); |
|
1283 | - $copyObj->setPeer($this->getPeer()); |
|
1284 | - $copyObj->setStarted($this->getStarted()); |
|
1285 | - $copyObj->setType($this->getType()); |
|
1286 | - if ($makeNew) { |
|
1287 | - $copyObj->setNew(true); |
|
1288 | - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
|
1289 | - } |
|
1290 | - } |
|
1291 | - |
|
1292 | - /** |
|
1293 | - * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
1294 | - * It creates a new object filling in the simple attributes, but skipping any primary |
|
1295 | - * keys that are defined for the table. |
|
1296 | - * |
|
1297 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
1298 | - * objects. |
|
1299 | - * |
|
1300 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
1301 | - * @return \Jalle19\StatusManager\Database\Connection Clone of current object. |
|
1302 | - * @throws PropelException |
|
1303 | - */ |
|
1304 | - public function copy($deepCopy = false) |
|
1305 | - { |
|
1306 | - // we use get_class(), because this might be a subclass |
|
1307 | - $clazz = get_class($this); |
|
1308 | - $copyObj = new $clazz(); |
|
1309 | - $this->copyInto($copyObj, $deepCopy); |
|
1310 | - |
|
1311 | - return $copyObj; |
|
1312 | - } |
|
1313 | - |
|
1314 | - /** |
|
1315 | - * Declares an association between this object and a ChildInstance object. |
|
1316 | - * |
|
1317 | - * @param ChildInstance $v |
|
1318 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
1319 | - * @throws PropelException |
|
1320 | - */ |
|
1321 | - public function setInstance(ChildInstance $v = null) |
|
1322 | - { |
|
1323 | - if ($v === null) { |
|
1324 | - $this->setInstanceName(NULL); |
|
1325 | - } else { |
|
1326 | - $this->setInstanceName($v->getName()); |
|
1327 | - } |
|
1328 | - |
|
1329 | - $this->aInstance = $v; |
|
1330 | - |
|
1331 | - // Add binding for other direction of this n:n relationship. |
|
1332 | - // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
1333 | - if ($v !== null) { |
|
1334 | - $v->addConnection($this); |
|
1335 | - } |
|
1336 | - |
|
1337 | - |
|
1338 | - return $this; |
|
1339 | - } |
|
1340 | - |
|
1341 | - |
|
1342 | - /** |
|
1343 | - * Get the associated ChildInstance object |
|
1344 | - * |
|
1345 | - * @param ConnectionInterface $con Optional Connection object. |
|
1346 | - * @return ChildInstance The associated ChildInstance object. |
|
1347 | - * @throws PropelException |
|
1348 | - */ |
|
1349 | - public function getInstance(ConnectionInterface $con = null) |
|
1350 | - { |
|
1351 | - if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
1352 | - $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
1353 | - /* The following can be used additionally to |
|
578 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
579 | + * |
|
580 | + * @return int next starting column |
|
581 | + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
582 | + */ |
|
583 | + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
584 | + { |
|
585 | + try { |
|
586 | + |
|
587 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ConnectionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
588 | + $this->id = (null !== $col) ? (int) $col : null; |
|
589 | + |
|
590 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ConnectionTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
591 | + $this->instance_name = (null !== $col) ? (string) $col : null; |
|
592 | + |
|
593 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ConnectionTableMap::translateFieldName('UserId', TableMap::TYPE_PHPNAME, $indexType)]; |
|
594 | + $this->user_id = (null !== $col) ? (int) $col : null; |
|
595 | + |
|
596 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ConnectionTableMap::translateFieldName('Peer', TableMap::TYPE_PHPNAME, $indexType)]; |
|
597 | + $this->peer = (null !== $col) ? (string) $col : null; |
|
598 | + |
|
599 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ConnectionTableMap::translateFieldName('Started', TableMap::TYPE_PHPNAME, $indexType)]; |
|
600 | + $this->started = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
|
601 | + |
|
602 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ConnectionTableMap::translateFieldName('Type', TableMap::TYPE_PHPNAME, $indexType)]; |
|
603 | + $this->type = (null !== $col) ? (string) $col : null; |
|
604 | + $this->resetModified(); |
|
605 | + |
|
606 | + $this->setNew(false); |
|
607 | + |
|
608 | + if ($rehydrate) { |
|
609 | + $this->ensureConsistency(); |
|
610 | + } |
|
611 | + |
|
612 | + return $startcol + 6; // 6 = ConnectionTableMap::NUM_HYDRATE_COLUMNS. |
|
613 | + |
|
614 | + } catch (Exception $e) { |
|
615 | + throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Connection'), 0, $e); |
|
616 | + } |
|
617 | + } |
|
618 | + |
|
619 | + /** |
|
620 | + * Checks and repairs the internal consistency of the object. |
|
621 | + * |
|
622 | + * This method is executed after an already-instantiated object is re-hydrated |
|
623 | + * from the database. It exists to check any foreign keys to make sure that |
|
624 | + * the objects related to the current object are correct based on foreign key. |
|
625 | + * |
|
626 | + * You can override this method in the stub class, but you should always invoke |
|
627 | + * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
628 | + * in case your model changes. |
|
629 | + * |
|
630 | + * @throws PropelException |
|
631 | + */ |
|
632 | + public function ensureConsistency() |
|
633 | + { |
|
634 | + if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
635 | + $this->aInstance = null; |
|
636 | + } |
|
637 | + if ($this->aUser !== null && $this->user_id !== $this->aUser->getId()) { |
|
638 | + $this->aUser = null; |
|
639 | + } |
|
640 | + } // ensureConsistency |
|
641 | + |
|
642 | + /** |
|
643 | + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
644 | + * |
|
645 | + * This will only work if the object has been saved and has a valid primary key set. |
|
646 | + * |
|
647 | + * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
648 | + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
649 | + * @return void |
|
650 | + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
651 | + */ |
|
652 | + public function reload($deep = false, ConnectionInterface $con = null) |
|
653 | + { |
|
654 | + if ($this->isDeleted()) { |
|
655 | + throw new PropelException("Cannot reload a deleted object."); |
|
656 | + } |
|
657 | + |
|
658 | + if ($this->isNew()) { |
|
659 | + throw new PropelException("Cannot reload an unsaved object."); |
|
660 | + } |
|
661 | + |
|
662 | + if ($con === null) { |
|
663 | + $con = Propel::getServiceContainer()->getReadConnection(ConnectionTableMap::DATABASE_NAME); |
|
664 | + } |
|
665 | + |
|
666 | + // We don't need to alter the object instance pool; we're just modifying this instance |
|
667 | + // already in the pool. |
|
668 | + |
|
669 | + $dataFetcher = ChildConnectionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
670 | + $row = $dataFetcher->fetch(); |
|
671 | + $dataFetcher->close(); |
|
672 | + if (!$row) { |
|
673 | + throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
674 | + } |
|
675 | + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
676 | + |
|
677 | + if ($deep) { // also de-associate any related objects? |
|
678 | + |
|
679 | + $this->aInstance = null; |
|
680 | + $this->aUser = null; |
|
681 | + } // if (deep) |
|
682 | + } |
|
683 | + |
|
684 | + /** |
|
685 | + * Removes this object from datastore and sets delete attribute. |
|
686 | + * |
|
687 | + * @param ConnectionInterface $con |
|
688 | + * @return void |
|
689 | + * @throws PropelException |
|
690 | + * @see Connection::setDeleted() |
|
691 | + * @see Connection::isDeleted() |
|
692 | + */ |
|
693 | + public function delete(ConnectionInterface $con = null) |
|
694 | + { |
|
695 | + if ($this->isDeleted()) { |
|
696 | + throw new PropelException("This object has already been deleted."); |
|
697 | + } |
|
698 | + |
|
699 | + if ($con === null) { |
|
700 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
701 | + } |
|
702 | + |
|
703 | + $con->transaction(function () use ($con) { |
|
704 | + $deleteQuery = ChildConnectionQuery::create() |
|
705 | + ->filterByPrimaryKey($this->getPrimaryKey()); |
|
706 | + $ret = $this->preDelete($con); |
|
707 | + if ($ret) { |
|
708 | + $deleteQuery->delete($con); |
|
709 | + $this->postDelete($con); |
|
710 | + $this->setDeleted(true); |
|
711 | + } |
|
712 | + }); |
|
713 | + } |
|
714 | + |
|
715 | + /** |
|
716 | + * Persists this object to the database. |
|
717 | + * |
|
718 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
719 | + * All modified related objects will also be persisted in the doSave() |
|
720 | + * method. This method wraps all precipitate database operations in a |
|
721 | + * single transaction. |
|
722 | + * |
|
723 | + * @param ConnectionInterface $con |
|
724 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
725 | + * @throws PropelException |
|
726 | + * @see doSave() |
|
727 | + */ |
|
728 | + public function save(ConnectionInterface $con = null) |
|
729 | + { |
|
730 | + if ($this->isDeleted()) { |
|
731 | + throw new PropelException("You cannot save an object that has been deleted."); |
|
732 | + } |
|
733 | + |
|
734 | + if ($con === null) { |
|
735 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
736 | + } |
|
737 | + |
|
738 | + return $con->transaction(function () use ($con) { |
|
739 | + $isInsert = $this->isNew(); |
|
740 | + $ret = $this->preSave($con); |
|
741 | + if ($isInsert) { |
|
742 | + $ret = $ret && $this->preInsert($con); |
|
743 | + } else { |
|
744 | + $ret = $ret && $this->preUpdate($con); |
|
745 | + } |
|
746 | + if ($ret) { |
|
747 | + $affectedRows = $this->doSave($con); |
|
748 | + if ($isInsert) { |
|
749 | + $this->postInsert($con); |
|
750 | + } else { |
|
751 | + $this->postUpdate($con); |
|
752 | + } |
|
753 | + $this->postSave($con); |
|
754 | + ConnectionTableMap::addInstanceToPool($this); |
|
755 | + } else { |
|
756 | + $affectedRows = 0; |
|
757 | + } |
|
758 | + |
|
759 | + return $affectedRows; |
|
760 | + }); |
|
761 | + } |
|
762 | + |
|
763 | + /** |
|
764 | + * Performs the work of inserting or updating the row in the database. |
|
765 | + * |
|
766 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
767 | + * All related objects are also updated in this method. |
|
768 | + * |
|
769 | + * @param ConnectionInterface $con |
|
770 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
771 | + * @throws PropelException |
|
772 | + * @see save() |
|
773 | + */ |
|
774 | + protected function doSave(ConnectionInterface $con) |
|
775 | + { |
|
776 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
777 | + if (!$this->alreadyInSave) { |
|
778 | + $this->alreadyInSave = true; |
|
779 | + |
|
780 | + // We call the save method on the following object(s) if they |
|
781 | + // were passed to this object by their corresponding set |
|
782 | + // method. This object relates to these object(s) by a |
|
783 | + // foreign key reference. |
|
784 | + |
|
785 | + if ($this->aInstance !== null) { |
|
786 | + if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
787 | + $affectedRows += $this->aInstance->save($con); |
|
788 | + } |
|
789 | + $this->setInstance($this->aInstance); |
|
790 | + } |
|
791 | + |
|
792 | + if ($this->aUser !== null) { |
|
793 | + if ($this->aUser->isModified() || $this->aUser->isNew()) { |
|
794 | + $affectedRows += $this->aUser->save($con); |
|
795 | + } |
|
796 | + $this->setUser($this->aUser); |
|
797 | + } |
|
798 | + |
|
799 | + if ($this->isNew() || $this->isModified()) { |
|
800 | + // persist changes |
|
801 | + if ($this->isNew()) { |
|
802 | + $this->doInsert($con); |
|
803 | + $affectedRows += 1; |
|
804 | + } else { |
|
805 | + $affectedRows += $this->doUpdate($con); |
|
806 | + } |
|
807 | + $this->resetModified(); |
|
808 | + } |
|
809 | + |
|
810 | + $this->alreadyInSave = false; |
|
811 | + |
|
812 | + } |
|
813 | + |
|
814 | + return $affectedRows; |
|
815 | + } // doSave() |
|
816 | + |
|
817 | + /** |
|
818 | + * Insert the row in the database. |
|
819 | + * |
|
820 | + * @param ConnectionInterface $con |
|
821 | + * |
|
822 | + * @throws PropelException |
|
823 | + * @see doSave() |
|
824 | + */ |
|
825 | + protected function doInsert(ConnectionInterface $con) |
|
826 | + { |
|
827 | + $modifiedColumns = array(); |
|
828 | + $index = 0; |
|
829 | + |
|
830 | + $this->modifiedColumns[ConnectionTableMap::COL_ID] = true; |
|
831 | + if (null !== $this->id) { |
|
832 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ConnectionTableMap::COL_ID . ')'); |
|
833 | + } |
|
834 | + |
|
835 | + // check the columns in natural order for more readable SQL queries |
|
836 | + if ($this->isColumnModified(ConnectionTableMap::COL_ID)) { |
|
837 | + $modifiedColumns[':p' . $index++] = 'id'; |
|
838 | + } |
|
839 | + if ($this->isColumnModified(ConnectionTableMap::COL_INSTANCE_NAME)) { |
|
840 | + $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
841 | + } |
|
842 | + if ($this->isColumnModified(ConnectionTableMap::COL_USER_ID)) { |
|
843 | + $modifiedColumns[':p' . $index++] = 'user_id'; |
|
844 | + } |
|
845 | + if ($this->isColumnModified(ConnectionTableMap::COL_PEER)) { |
|
846 | + $modifiedColumns[':p' . $index++] = 'peer'; |
|
847 | + } |
|
848 | + if ($this->isColumnModified(ConnectionTableMap::COL_STARTED)) { |
|
849 | + $modifiedColumns[':p' . $index++] = 'started'; |
|
850 | + } |
|
851 | + if ($this->isColumnModified(ConnectionTableMap::COL_TYPE)) { |
|
852 | + $modifiedColumns[':p' . $index++] = 'type'; |
|
853 | + } |
|
854 | + |
|
855 | + $sql = sprintf( |
|
856 | + 'INSERT INTO connection (%s) VALUES (%s)', |
|
857 | + implode(', ', $modifiedColumns), |
|
858 | + implode(', ', array_keys($modifiedColumns)) |
|
859 | + ); |
|
860 | + |
|
861 | + try { |
|
862 | + $stmt = $con->prepare($sql); |
|
863 | + foreach ($modifiedColumns as $identifier => $columnName) { |
|
864 | + switch ($columnName) { |
|
865 | + case 'id': |
|
866 | + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
867 | + break; |
|
868 | + case 'instance_name': |
|
869 | + $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
870 | + break; |
|
871 | + case 'user_id': |
|
872 | + $stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT); |
|
873 | + break; |
|
874 | + case 'peer': |
|
875 | + $stmt->bindValue($identifier, $this->peer, PDO::PARAM_STR); |
|
876 | + break; |
|
877 | + case 'started': |
|
878 | + $stmt->bindValue($identifier, $this->started ? $this->started->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
|
879 | + break; |
|
880 | + case 'type': |
|
881 | + $stmt->bindValue($identifier, $this->type, PDO::PARAM_STR); |
|
882 | + break; |
|
883 | + } |
|
884 | + } |
|
885 | + $stmt->execute(); |
|
886 | + } catch (Exception $e) { |
|
887 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
888 | + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
889 | + } |
|
890 | + |
|
891 | + try { |
|
892 | + $pk = $con->lastInsertId(); |
|
893 | + } catch (Exception $e) { |
|
894 | + throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
895 | + } |
|
896 | + $this->setId($pk); |
|
897 | + |
|
898 | + $this->setNew(false); |
|
899 | + } |
|
900 | + |
|
901 | + /** |
|
902 | + * Update the row in the database. |
|
903 | + * |
|
904 | + * @param ConnectionInterface $con |
|
905 | + * |
|
906 | + * @return Integer Number of updated rows |
|
907 | + * @see doSave() |
|
908 | + */ |
|
909 | + protected function doUpdate(ConnectionInterface $con) |
|
910 | + { |
|
911 | + $selectCriteria = $this->buildPkeyCriteria(); |
|
912 | + $valuesCriteria = $this->buildCriteria(); |
|
913 | + |
|
914 | + return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
915 | + } |
|
916 | + |
|
917 | + /** |
|
918 | + * Retrieves a field from the object by name passed in as a string. |
|
919 | + * |
|
920 | + * @param string $name name |
|
921 | + * @param string $type The type of fieldname the $name is of: |
|
922 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
923 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
924 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
925 | + * @return mixed Value of field. |
|
926 | + */ |
|
927 | + public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
928 | + { |
|
929 | + $pos = ConnectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
930 | + $field = $this->getByPosition($pos); |
|
931 | + |
|
932 | + return $field; |
|
933 | + } |
|
934 | + |
|
935 | + /** |
|
936 | + * Retrieves a field from the object by Position as specified in the xml schema. |
|
937 | + * Zero-based. |
|
938 | + * |
|
939 | + * @param int $pos position in xml schema |
|
940 | + * @return mixed Value of field at $pos |
|
941 | + */ |
|
942 | + public function getByPosition($pos) |
|
943 | + { |
|
944 | + switch ($pos) { |
|
945 | + case 0: |
|
946 | + return $this->getId(); |
|
947 | + break; |
|
948 | + case 1: |
|
949 | + return $this->getInstanceName(); |
|
950 | + break; |
|
951 | + case 2: |
|
952 | + return $this->getUserId(); |
|
953 | + break; |
|
954 | + case 3: |
|
955 | + return $this->getPeer(); |
|
956 | + break; |
|
957 | + case 4: |
|
958 | + return $this->getStarted(); |
|
959 | + break; |
|
960 | + case 5: |
|
961 | + return $this->getType(); |
|
962 | + break; |
|
963 | + default: |
|
964 | + return null; |
|
965 | + break; |
|
966 | + } // switch() |
|
967 | + } |
|
968 | + |
|
969 | + /** |
|
970 | + * Exports the object as an array. |
|
971 | + * |
|
972 | + * You can specify the key type of the array by passing one of the class |
|
973 | + * type constants. |
|
974 | + * |
|
975 | + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
976 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
977 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
978 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
979 | + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
980 | + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
981 | + * |
|
982 | + * @return array an associative array containing the field names (as keys) and field values |
|
983 | + */ |
|
984 | + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
985 | + { |
|
986 | + |
|
987 | + if (isset($alreadyDumpedObjects['Connection'][$this->hashCode()])) { |
|
988 | + return '*RECURSION*'; |
|
989 | + } |
|
990 | + $alreadyDumpedObjects['Connection'][$this->hashCode()] = true; |
|
991 | + $keys = ConnectionTableMap::getFieldNames($keyType); |
|
992 | + $result = array( |
|
993 | + $keys[0] => $this->getId(), |
|
994 | + $keys[1] => $this->getInstanceName(), |
|
995 | + $keys[2] => $this->getUserId(), |
|
996 | + $keys[3] => $this->getPeer(), |
|
997 | + $keys[4] => $this->getStarted(), |
|
998 | + $keys[5] => $this->getType(), |
|
999 | + ); |
|
1000 | + if ($result[$keys[4]] instanceof \DateTime) { |
|
1001 | + $result[$keys[4]] = $result[$keys[4]]->format('c'); |
|
1002 | + } |
|
1003 | + |
|
1004 | + $virtualColumns = $this->virtualColumns; |
|
1005 | + foreach ($virtualColumns as $key => $virtualColumn) { |
|
1006 | + $result[$key] = $virtualColumn; |
|
1007 | + } |
|
1008 | + |
|
1009 | + if ($includeForeignObjects) { |
|
1010 | + if (null !== $this->aInstance) { |
|
1011 | + |
|
1012 | + switch ($keyType) { |
|
1013 | + case TableMap::TYPE_CAMELNAME: |
|
1014 | + $key = 'instance'; |
|
1015 | + break; |
|
1016 | + case TableMap::TYPE_FIELDNAME: |
|
1017 | + $key = 'instance'; |
|
1018 | + break; |
|
1019 | + default: |
|
1020 | + $key = 'Instance'; |
|
1021 | + } |
|
1022 | + |
|
1023 | + $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
1024 | + } |
|
1025 | + if (null !== $this->aUser) { |
|
1026 | + |
|
1027 | + switch ($keyType) { |
|
1028 | + case TableMap::TYPE_CAMELNAME: |
|
1029 | + $key = 'user'; |
|
1030 | + break; |
|
1031 | + case TableMap::TYPE_FIELDNAME: |
|
1032 | + $key = 'user'; |
|
1033 | + break; |
|
1034 | + default: |
|
1035 | + $key = 'User'; |
|
1036 | + } |
|
1037 | + |
|
1038 | + $result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
1039 | + } |
|
1040 | + } |
|
1041 | + |
|
1042 | + return $result; |
|
1043 | + } |
|
1044 | + |
|
1045 | + /** |
|
1046 | + * Sets a field from the object by name passed in as a string. |
|
1047 | + * |
|
1048 | + * @param string $name |
|
1049 | + * @param mixed $value field value |
|
1050 | + * @param string $type The type of fieldname the $name is of: |
|
1051 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
1052 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
1053 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
1054 | + * @return $this|\Jalle19\StatusManager\Database\Connection |
|
1055 | + */ |
|
1056 | + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
1057 | + { |
|
1058 | + $pos = ConnectionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
1059 | + |
|
1060 | + return $this->setByPosition($pos, $value); |
|
1061 | + } |
|
1062 | + |
|
1063 | + /** |
|
1064 | + * Sets a field from the object by Position as specified in the xml schema. |
|
1065 | + * Zero-based. |
|
1066 | + * |
|
1067 | + * @param int $pos position in xml schema |
|
1068 | + * @param mixed $value field value |
|
1069 | + * @return $this|\Jalle19\StatusManager\Database\Connection |
|
1070 | + */ |
|
1071 | + public function setByPosition($pos, $value) |
|
1072 | + { |
|
1073 | + switch ($pos) { |
|
1074 | + case 0: |
|
1075 | + $this->setId($value); |
|
1076 | + break; |
|
1077 | + case 1: |
|
1078 | + $this->setInstanceName($value); |
|
1079 | + break; |
|
1080 | + case 2: |
|
1081 | + $this->setUserId($value); |
|
1082 | + break; |
|
1083 | + case 3: |
|
1084 | + $this->setPeer($value); |
|
1085 | + break; |
|
1086 | + case 4: |
|
1087 | + $this->setStarted($value); |
|
1088 | + break; |
|
1089 | + case 5: |
|
1090 | + $this->setType($value); |
|
1091 | + break; |
|
1092 | + } // switch() |
|
1093 | + |
|
1094 | + return $this; |
|
1095 | + } |
|
1096 | + |
|
1097 | + /** |
|
1098 | + * Populates the object using an array. |
|
1099 | + * |
|
1100 | + * This is particularly useful when populating an object from one of the |
|
1101 | + * request arrays (e.g. $_POST). This method goes through the column |
|
1102 | + * names, checking to see whether a matching key exists in populated |
|
1103 | + * array. If so the setByName() method is called for that column. |
|
1104 | + * |
|
1105 | + * You can specify the key type of the array by additionally passing one |
|
1106 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
1107 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
1108 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
1109 | + * |
|
1110 | + * @param array $arr An array to populate the object from. |
|
1111 | + * @param string $keyType The type of keys the array uses. |
|
1112 | + * @return void |
|
1113 | + */ |
|
1114 | + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
1115 | + { |
|
1116 | + $keys = ConnectionTableMap::getFieldNames($keyType); |
|
1117 | + |
|
1118 | + if (array_key_exists($keys[0], $arr)) { |
|
1119 | + $this->setId($arr[$keys[0]]); |
|
1120 | + } |
|
1121 | + if (array_key_exists($keys[1], $arr)) { |
|
1122 | + $this->setInstanceName($arr[$keys[1]]); |
|
1123 | + } |
|
1124 | + if (array_key_exists($keys[2], $arr)) { |
|
1125 | + $this->setUserId($arr[$keys[2]]); |
|
1126 | + } |
|
1127 | + if (array_key_exists($keys[3], $arr)) { |
|
1128 | + $this->setPeer($arr[$keys[3]]); |
|
1129 | + } |
|
1130 | + if (array_key_exists($keys[4], $arr)) { |
|
1131 | + $this->setStarted($arr[$keys[4]]); |
|
1132 | + } |
|
1133 | + if (array_key_exists($keys[5], $arr)) { |
|
1134 | + $this->setType($arr[$keys[5]]); |
|
1135 | + } |
|
1136 | + } |
|
1137 | + |
|
1138 | + /** |
|
1139 | + * Populate the current object from a string, using a given parser format |
|
1140 | + * <code> |
|
1141 | + * $book = new Book(); |
|
1142 | + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
1143 | + * </code> |
|
1144 | + * |
|
1145 | + * You can specify the key type of the array by additionally passing one |
|
1146 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
1147 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
1148 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
1149 | + * |
|
1150 | + * @param mixed $parser A AbstractParser instance, |
|
1151 | + * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
1152 | + * @param string $data The source data to import from |
|
1153 | + * @param string $keyType The type of keys the array uses. |
|
1154 | + * |
|
1155 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object, for fluid interface |
|
1156 | + */ |
|
1157 | + public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
1158 | + { |
|
1159 | + if (!$parser instanceof AbstractParser) { |
|
1160 | + $parser = AbstractParser::getParser($parser); |
|
1161 | + } |
|
1162 | + |
|
1163 | + $this->fromArray($parser->toArray($data), $keyType); |
|
1164 | + |
|
1165 | + return $this; |
|
1166 | + } |
|
1167 | + |
|
1168 | + /** |
|
1169 | + * Build a Criteria object containing the values of all modified columns in this object. |
|
1170 | + * |
|
1171 | + * @return Criteria The Criteria object containing all modified values. |
|
1172 | + */ |
|
1173 | + public function buildCriteria() |
|
1174 | + { |
|
1175 | + $criteria = new Criteria(ConnectionTableMap::DATABASE_NAME); |
|
1176 | + |
|
1177 | + if ($this->isColumnModified(ConnectionTableMap::COL_ID)) { |
|
1178 | + $criteria->add(ConnectionTableMap::COL_ID, $this->id); |
|
1179 | + } |
|
1180 | + if ($this->isColumnModified(ConnectionTableMap::COL_INSTANCE_NAME)) { |
|
1181 | + $criteria->add(ConnectionTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
1182 | + } |
|
1183 | + if ($this->isColumnModified(ConnectionTableMap::COL_USER_ID)) { |
|
1184 | + $criteria->add(ConnectionTableMap::COL_USER_ID, $this->user_id); |
|
1185 | + } |
|
1186 | + if ($this->isColumnModified(ConnectionTableMap::COL_PEER)) { |
|
1187 | + $criteria->add(ConnectionTableMap::COL_PEER, $this->peer); |
|
1188 | + } |
|
1189 | + if ($this->isColumnModified(ConnectionTableMap::COL_STARTED)) { |
|
1190 | + $criteria->add(ConnectionTableMap::COL_STARTED, $this->started); |
|
1191 | + } |
|
1192 | + if ($this->isColumnModified(ConnectionTableMap::COL_TYPE)) { |
|
1193 | + $criteria->add(ConnectionTableMap::COL_TYPE, $this->type); |
|
1194 | + } |
|
1195 | + |
|
1196 | + return $criteria; |
|
1197 | + } |
|
1198 | + |
|
1199 | + /** |
|
1200 | + * Builds a Criteria object containing the primary key for this object. |
|
1201 | + * |
|
1202 | + * Unlike buildCriteria() this method includes the primary key values regardless |
|
1203 | + * of whether or not they have been modified. |
|
1204 | + * |
|
1205 | + * @throws LogicException if no primary key is defined |
|
1206 | + * |
|
1207 | + * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
1208 | + */ |
|
1209 | + public function buildPkeyCriteria() |
|
1210 | + { |
|
1211 | + $criteria = ChildConnectionQuery::create(); |
|
1212 | + $criteria->add(ConnectionTableMap::COL_ID, $this->id); |
|
1213 | + |
|
1214 | + return $criteria; |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * If the primary key is not null, return the hashcode of the |
|
1219 | + * primary key. Otherwise, return the hash code of the object. |
|
1220 | + * |
|
1221 | + * @return int Hashcode |
|
1222 | + */ |
|
1223 | + public function hashCode() |
|
1224 | + { |
|
1225 | + $validPk = null !== $this->getId(); |
|
1226 | + |
|
1227 | + $validPrimaryKeyFKs = 0; |
|
1228 | + $primaryKeyFKs = []; |
|
1229 | + |
|
1230 | + if ($validPk) { |
|
1231 | + return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
1232 | + } elseif ($validPrimaryKeyFKs) { |
|
1233 | + return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
1234 | + } |
|
1235 | + |
|
1236 | + return spl_object_hash($this); |
|
1237 | + } |
|
1238 | + |
|
1239 | + /** |
|
1240 | + * Returns the primary key for this object (row). |
|
1241 | + * @return int |
|
1242 | + */ |
|
1243 | + public function getPrimaryKey() |
|
1244 | + { |
|
1245 | + return $this->getId(); |
|
1246 | + } |
|
1247 | + |
|
1248 | + /** |
|
1249 | + * Generic method to set the primary key (id column). |
|
1250 | + * |
|
1251 | + * @param int $key Primary key. |
|
1252 | + * @return void |
|
1253 | + */ |
|
1254 | + public function setPrimaryKey($key) |
|
1255 | + { |
|
1256 | + $this->setId($key); |
|
1257 | + } |
|
1258 | + |
|
1259 | + /** |
|
1260 | + * Returns true if the primary key for this object is null. |
|
1261 | + * @return boolean |
|
1262 | + */ |
|
1263 | + public function isPrimaryKeyNull() |
|
1264 | + { |
|
1265 | + return null === $this->getId(); |
|
1266 | + } |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * Sets contents of passed object to values from current object. |
|
1270 | + * |
|
1271 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
1272 | + * objects. |
|
1273 | + * |
|
1274 | + * @param object $copyObj An object of \Jalle19\StatusManager\Database\Connection (or compatible) type. |
|
1275 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
1276 | + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
1277 | + * @throws PropelException |
|
1278 | + */ |
|
1279 | + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
1280 | + { |
|
1281 | + $copyObj->setInstanceName($this->getInstanceName()); |
|
1282 | + $copyObj->setUserId($this->getUserId()); |
|
1283 | + $copyObj->setPeer($this->getPeer()); |
|
1284 | + $copyObj->setStarted($this->getStarted()); |
|
1285 | + $copyObj->setType($this->getType()); |
|
1286 | + if ($makeNew) { |
|
1287 | + $copyObj->setNew(true); |
|
1288 | + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
|
1289 | + } |
|
1290 | + } |
|
1291 | + |
|
1292 | + /** |
|
1293 | + * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
1294 | + * It creates a new object filling in the simple attributes, but skipping any primary |
|
1295 | + * keys that are defined for the table. |
|
1296 | + * |
|
1297 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
1298 | + * objects. |
|
1299 | + * |
|
1300 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
1301 | + * @return \Jalle19\StatusManager\Database\Connection Clone of current object. |
|
1302 | + * @throws PropelException |
|
1303 | + */ |
|
1304 | + public function copy($deepCopy = false) |
|
1305 | + { |
|
1306 | + // we use get_class(), because this might be a subclass |
|
1307 | + $clazz = get_class($this); |
|
1308 | + $copyObj = new $clazz(); |
|
1309 | + $this->copyInto($copyObj, $deepCopy); |
|
1310 | + |
|
1311 | + return $copyObj; |
|
1312 | + } |
|
1313 | + |
|
1314 | + /** |
|
1315 | + * Declares an association between this object and a ChildInstance object. |
|
1316 | + * |
|
1317 | + * @param ChildInstance $v |
|
1318 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
1319 | + * @throws PropelException |
|
1320 | + */ |
|
1321 | + public function setInstance(ChildInstance $v = null) |
|
1322 | + { |
|
1323 | + if ($v === null) { |
|
1324 | + $this->setInstanceName(NULL); |
|
1325 | + } else { |
|
1326 | + $this->setInstanceName($v->getName()); |
|
1327 | + } |
|
1328 | + |
|
1329 | + $this->aInstance = $v; |
|
1330 | + |
|
1331 | + // Add binding for other direction of this n:n relationship. |
|
1332 | + // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
1333 | + if ($v !== null) { |
|
1334 | + $v->addConnection($this); |
|
1335 | + } |
|
1336 | + |
|
1337 | + |
|
1338 | + return $this; |
|
1339 | + } |
|
1340 | + |
|
1341 | + |
|
1342 | + /** |
|
1343 | + * Get the associated ChildInstance object |
|
1344 | + * |
|
1345 | + * @param ConnectionInterface $con Optional Connection object. |
|
1346 | + * @return ChildInstance The associated ChildInstance object. |
|
1347 | + * @throws PropelException |
|
1348 | + */ |
|
1349 | + public function getInstance(ConnectionInterface $con = null) |
|
1350 | + { |
|
1351 | + if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
1352 | + $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
1353 | + /* The following can be used additionally to |
|
1354 | 1354 | guarantee the related object contains a reference |
1355 | 1355 | to this object. This level of coupling may, however, be |
1356 | 1356 | undesirable since it could result in an only partially populated collection |
1357 | 1357 | in the referenced object. |
1358 | 1358 | $this->aInstance->addConnections($this); |
1359 | 1359 | */ |
1360 | - } |
|
1361 | - |
|
1362 | - return $this->aInstance; |
|
1363 | - } |
|
1364 | - |
|
1365 | - /** |
|
1366 | - * Declares an association between this object and a ChildUser object. |
|
1367 | - * |
|
1368 | - * @param ChildUser $v |
|
1369 | - * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
1370 | - * @throws PropelException |
|
1371 | - */ |
|
1372 | - public function setUser(ChildUser $v = null) |
|
1373 | - { |
|
1374 | - if ($v === null) { |
|
1375 | - $this->setUserId(NULL); |
|
1376 | - } else { |
|
1377 | - $this->setUserId($v->getId()); |
|
1378 | - } |
|
1379 | - |
|
1380 | - $this->aUser = $v; |
|
1381 | - |
|
1382 | - // Add binding for other direction of this n:n relationship. |
|
1383 | - // If this object has already been added to the ChildUser object, it will not be re-added. |
|
1384 | - if ($v !== null) { |
|
1385 | - $v->addConnection($this); |
|
1386 | - } |
|
1387 | - |
|
1388 | - |
|
1389 | - return $this; |
|
1390 | - } |
|
1391 | - |
|
1392 | - |
|
1393 | - /** |
|
1394 | - * Get the associated ChildUser object |
|
1395 | - * |
|
1396 | - * @param ConnectionInterface $con Optional Connection object. |
|
1397 | - * @return ChildUser The associated ChildUser object. |
|
1398 | - * @throws PropelException |
|
1399 | - */ |
|
1400 | - public function getUser(ConnectionInterface $con = null) |
|
1401 | - { |
|
1402 | - if ($this->aUser === null && ($this->user_id !== null)) { |
|
1403 | - $this->aUser = ChildUserQuery::create()->findPk($this->user_id, $con); |
|
1404 | - /* The following can be used additionally to |
|
1360 | + } |
|
1361 | + |
|
1362 | + return $this->aInstance; |
|
1363 | + } |
|
1364 | + |
|
1365 | + /** |
|
1366 | + * Declares an association between this object and a ChildUser object. |
|
1367 | + * |
|
1368 | + * @param ChildUser $v |
|
1369 | + * @return $this|\Jalle19\StatusManager\Database\Connection The current object (for fluent API support) |
|
1370 | + * @throws PropelException |
|
1371 | + */ |
|
1372 | + public function setUser(ChildUser $v = null) |
|
1373 | + { |
|
1374 | + if ($v === null) { |
|
1375 | + $this->setUserId(NULL); |
|
1376 | + } else { |
|
1377 | + $this->setUserId($v->getId()); |
|
1378 | + } |
|
1379 | + |
|
1380 | + $this->aUser = $v; |
|
1381 | + |
|
1382 | + // Add binding for other direction of this n:n relationship. |
|
1383 | + // If this object has already been added to the ChildUser object, it will not be re-added. |
|
1384 | + if ($v !== null) { |
|
1385 | + $v->addConnection($this); |
|
1386 | + } |
|
1387 | + |
|
1388 | + |
|
1389 | + return $this; |
|
1390 | + } |
|
1391 | + |
|
1392 | + |
|
1393 | + /** |
|
1394 | + * Get the associated ChildUser object |
|
1395 | + * |
|
1396 | + * @param ConnectionInterface $con Optional Connection object. |
|
1397 | + * @return ChildUser The associated ChildUser object. |
|
1398 | + * @throws PropelException |
|
1399 | + */ |
|
1400 | + public function getUser(ConnectionInterface $con = null) |
|
1401 | + { |
|
1402 | + if ($this->aUser === null && ($this->user_id !== null)) { |
|
1403 | + $this->aUser = ChildUserQuery::create()->findPk($this->user_id, $con); |
|
1404 | + /* The following can be used additionally to |
|
1405 | 1405 | guarantee the related object contains a reference |
1406 | 1406 | to this object. This level of coupling may, however, be |
1407 | 1407 | undesirable since it could result in an only partially populated collection |
1408 | 1408 | in the referenced object. |
1409 | 1409 | $this->aUser->addConnections($this); |
1410 | 1410 | */ |
1411 | - } |
|
1412 | - |
|
1413 | - return $this->aUser; |
|
1414 | - } |
|
1415 | - |
|
1416 | - /** |
|
1417 | - * Clears the current object, sets all attributes to their default values and removes |
|
1418 | - * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
1419 | - * change of those foreign objects when you call `save` there). |
|
1420 | - */ |
|
1421 | - public function clear() |
|
1422 | - { |
|
1423 | - if (null !== $this->aInstance) { |
|
1424 | - $this->aInstance->removeConnection($this); |
|
1425 | - } |
|
1426 | - if (null !== $this->aUser) { |
|
1427 | - $this->aUser->removeConnection($this); |
|
1428 | - } |
|
1429 | - $this->id = null; |
|
1430 | - $this->instance_name = null; |
|
1431 | - $this->user_id = null; |
|
1432 | - $this->peer = null; |
|
1433 | - $this->started = null; |
|
1434 | - $this->type = null; |
|
1435 | - $this->alreadyInSave = false; |
|
1436 | - $this->clearAllReferences(); |
|
1437 | - $this->resetModified(); |
|
1438 | - $this->setNew(true); |
|
1439 | - $this->setDeleted(false); |
|
1440 | - } |
|
1441 | - |
|
1442 | - /** |
|
1443 | - * Resets all references and back-references to other model objects or collections of model objects. |
|
1444 | - * |
|
1445 | - * This method is used to reset all php object references (not the actual reference in the database). |
|
1446 | - * Necessary for object serialisation. |
|
1447 | - * |
|
1448 | - * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
1449 | - */ |
|
1450 | - public function clearAllReferences($deep = false) |
|
1451 | - { |
|
1452 | - if ($deep) { |
|
1453 | - } // if ($deep) |
|
1454 | - |
|
1455 | - $this->aInstance = null; |
|
1456 | - $this->aUser = null; |
|
1457 | - } |
|
1458 | - |
|
1459 | - /** |
|
1460 | - * Return the string representation of this object |
|
1461 | - * |
|
1462 | - * @return string |
|
1463 | - */ |
|
1464 | - public function __toString() |
|
1465 | - { |
|
1466 | - return (string) $this->exportTo(ConnectionTableMap::DEFAULT_STRING_FORMAT); |
|
1467 | - } |
|
1468 | - |
|
1469 | - /** |
|
1470 | - * Code to be run before persisting the object |
|
1471 | - * @param ConnectionInterface $con |
|
1472 | - * @return boolean |
|
1473 | - */ |
|
1474 | - public function preSave(ConnectionInterface $con = null) |
|
1475 | - { |
|
1476 | - return true; |
|
1477 | - } |
|
1478 | - |
|
1479 | - /** |
|
1480 | - * Code to be run after persisting the object |
|
1481 | - * @param ConnectionInterface $con |
|
1482 | - */ |
|
1483 | - public function postSave(ConnectionInterface $con = null) |
|
1484 | - { |
|
1485 | - |
|
1486 | - } |
|
1487 | - |
|
1488 | - /** |
|
1489 | - * Code to be run before inserting to database |
|
1490 | - * @param ConnectionInterface $con |
|
1491 | - * @return boolean |
|
1492 | - */ |
|
1493 | - public function preInsert(ConnectionInterface $con = null) |
|
1494 | - { |
|
1495 | - return true; |
|
1496 | - } |
|
1497 | - |
|
1498 | - /** |
|
1499 | - * Code to be run after inserting to database |
|
1500 | - * @param ConnectionInterface $con |
|
1501 | - */ |
|
1502 | - public function postInsert(ConnectionInterface $con = null) |
|
1503 | - { |
|
1504 | - |
|
1505 | - } |
|
1506 | - |
|
1507 | - /** |
|
1508 | - * Code to be run before updating the object in database |
|
1509 | - * @param ConnectionInterface $con |
|
1510 | - * @return boolean |
|
1511 | - */ |
|
1512 | - public function preUpdate(ConnectionInterface $con = null) |
|
1513 | - { |
|
1514 | - return true; |
|
1515 | - } |
|
1516 | - |
|
1517 | - /** |
|
1518 | - * Code to be run after updating the object in database |
|
1519 | - * @param ConnectionInterface $con |
|
1520 | - */ |
|
1521 | - public function postUpdate(ConnectionInterface $con = null) |
|
1522 | - { |
|
1523 | - |
|
1524 | - } |
|
1525 | - |
|
1526 | - /** |
|
1527 | - * Code to be run before deleting the object in database |
|
1528 | - * @param ConnectionInterface $con |
|
1529 | - * @return boolean |
|
1530 | - */ |
|
1531 | - public function preDelete(ConnectionInterface $con = null) |
|
1532 | - { |
|
1533 | - return true; |
|
1534 | - } |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * Code to be run after deleting the object in database |
|
1538 | - * @param ConnectionInterface $con |
|
1539 | - */ |
|
1540 | - public function postDelete(ConnectionInterface $con = null) |
|
1541 | - { |
|
1542 | - |
|
1543 | - } |
|
1544 | - |
|
1545 | - |
|
1546 | - /** |
|
1547 | - * Derived method to catches calls to undefined methods. |
|
1548 | - * |
|
1549 | - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
1550 | - * Allows to define default __call() behavior if you overwrite __call() |
|
1551 | - * |
|
1552 | - * @param string $name |
|
1553 | - * @param mixed $params |
|
1554 | - * |
|
1555 | - * @return array|string |
|
1556 | - */ |
|
1557 | - public function __call($name, $params) |
|
1558 | - { |
|
1559 | - if (0 === strpos($name, 'get')) { |
|
1560 | - $virtualColumn = substr($name, 3); |
|
1561 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
1562 | - return $this->getVirtualColumn($virtualColumn); |
|
1563 | - } |
|
1564 | - |
|
1565 | - $virtualColumn = lcfirst($virtualColumn); |
|
1566 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
1567 | - return $this->getVirtualColumn($virtualColumn); |
|
1568 | - } |
|
1569 | - } |
|
1570 | - |
|
1571 | - if (0 === strpos($name, 'from')) { |
|
1572 | - $format = substr($name, 4); |
|
1573 | - |
|
1574 | - return $this->importFrom($format, reset($params)); |
|
1575 | - } |
|
1576 | - |
|
1577 | - if (0 === strpos($name, 'to')) { |
|
1578 | - $format = substr($name, 2); |
|
1579 | - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
1580 | - |
|
1581 | - return $this->exportTo($format, $includeLazyLoadColumns); |
|
1582 | - } |
|
1583 | - |
|
1584 | - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
1585 | - } |
|
1411 | + } |
|
1412 | + |
|
1413 | + return $this->aUser; |
|
1414 | + } |
|
1415 | + |
|
1416 | + /** |
|
1417 | + * Clears the current object, sets all attributes to their default values and removes |
|
1418 | + * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
1419 | + * change of those foreign objects when you call `save` there). |
|
1420 | + */ |
|
1421 | + public function clear() |
|
1422 | + { |
|
1423 | + if (null !== $this->aInstance) { |
|
1424 | + $this->aInstance->removeConnection($this); |
|
1425 | + } |
|
1426 | + if (null !== $this->aUser) { |
|
1427 | + $this->aUser->removeConnection($this); |
|
1428 | + } |
|
1429 | + $this->id = null; |
|
1430 | + $this->instance_name = null; |
|
1431 | + $this->user_id = null; |
|
1432 | + $this->peer = null; |
|
1433 | + $this->started = null; |
|
1434 | + $this->type = null; |
|
1435 | + $this->alreadyInSave = false; |
|
1436 | + $this->clearAllReferences(); |
|
1437 | + $this->resetModified(); |
|
1438 | + $this->setNew(true); |
|
1439 | + $this->setDeleted(false); |
|
1440 | + } |
|
1441 | + |
|
1442 | + /** |
|
1443 | + * Resets all references and back-references to other model objects or collections of model objects. |
|
1444 | + * |
|
1445 | + * This method is used to reset all php object references (not the actual reference in the database). |
|
1446 | + * Necessary for object serialisation. |
|
1447 | + * |
|
1448 | + * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
1449 | + */ |
|
1450 | + public function clearAllReferences($deep = false) |
|
1451 | + { |
|
1452 | + if ($deep) { |
|
1453 | + } // if ($deep) |
|
1454 | + |
|
1455 | + $this->aInstance = null; |
|
1456 | + $this->aUser = null; |
|
1457 | + } |
|
1458 | + |
|
1459 | + /** |
|
1460 | + * Return the string representation of this object |
|
1461 | + * |
|
1462 | + * @return string |
|
1463 | + */ |
|
1464 | + public function __toString() |
|
1465 | + { |
|
1466 | + return (string) $this->exportTo(ConnectionTableMap::DEFAULT_STRING_FORMAT); |
|
1467 | + } |
|
1468 | + |
|
1469 | + /** |
|
1470 | + * Code to be run before persisting the object |
|
1471 | + * @param ConnectionInterface $con |
|
1472 | + * @return boolean |
|
1473 | + */ |
|
1474 | + public function preSave(ConnectionInterface $con = null) |
|
1475 | + { |
|
1476 | + return true; |
|
1477 | + } |
|
1478 | + |
|
1479 | + /** |
|
1480 | + * Code to be run after persisting the object |
|
1481 | + * @param ConnectionInterface $con |
|
1482 | + */ |
|
1483 | + public function postSave(ConnectionInterface $con = null) |
|
1484 | + { |
|
1485 | + |
|
1486 | + } |
|
1487 | + |
|
1488 | + /** |
|
1489 | + * Code to be run before inserting to database |
|
1490 | + * @param ConnectionInterface $con |
|
1491 | + * @return boolean |
|
1492 | + */ |
|
1493 | + public function preInsert(ConnectionInterface $con = null) |
|
1494 | + { |
|
1495 | + return true; |
|
1496 | + } |
|
1497 | + |
|
1498 | + /** |
|
1499 | + * Code to be run after inserting to database |
|
1500 | + * @param ConnectionInterface $con |
|
1501 | + */ |
|
1502 | + public function postInsert(ConnectionInterface $con = null) |
|
1503 | + { |
|
1504 | + |
|
1505 | + } |
|
1506 | + |
|
1507 | + /** |
|
1508 | + * Code to be run before updating the object in database |
|
1509 | + * @param ConnectionInterface $con |
|
1510 | + * @return boolean |
|
1511 | + */ |
|
1512 | + public function preUpdate(ConnectionInterface $con = null) |
|
1513 | + { |
|
1514 | + return true; |
|
1515 | + } |
|
1516 | + |
|
1517 | + /** |
|
1518 | + * Code to be run after updating the object in database |
|
1519 | + * @param ConnectionInterface $con |
|
1520 | + */ |
|
1521 | + public function postUpdate(ConnectionInterface $con = null) |
|
1522 | + { |
|
1523 | + |
|
1524 | + } |
|
1525 | + |
|
1526 | + /** |
|
1527 | + * Code to be run before deleting the object in database |
|
1528 | + * @param ConnectionInterface $con |
|
1529 | + * @return boolean |
|
1530 | + */ |
|
1531 | + public function preDelete(ConnectionInterface $con = null) |
|
1532 | + { |
|
1533 | + return true; |
|
1534 | + } |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * Code to be run after deleting the object in database |
|
1538 | + * @param ConnectionInterface $con |
|
1539 | + */ |
|
1540 | + public function postDelete(ConnectionInterface $con = null) |
|
1541 | + { |
|
1542 | + |
|
1543 | + } |
|
1544 | + |
|
1545 | + |
|
1546 | + /** |
|
1547 | + * Derived method to catches calls to undefined methods. |
|
1548 | + * |
|
1549 | + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
1550 | + * Allows to define default __call() behavior if you overwrite __call() |
|
1551 | + * |
|
1552 | + * @param string $name |
|
1553 | + * @param mixed $params |
|
1554 | + * |
|
1555 | + * @return array|string |
|
1556 | + */ |
|
1557 | + public function __call($name, $params) |
|
1558 | + { |
|
1559 | + if (0 === strpos($name, 'get')) { |
|
1560 | + $virtualColumn = substr($name, 3); |
|
1561 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
1562 | + return $this->getVirtualColumn($virtualColumn); |
|
1563 | + } |
|
1564 | + |
|
1565 | + $virtualColumn = lcfirst($virtualColumn); |
|
1566 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
1567 | + return $this->getVirtualColumn($virtualColumn); |
|
1568 | + } |
|
1569 | + } |
|
1570 | + |
|
1571 | + if (0 === strpos($name, 'from')) { |
|
1572 | + $format = substr($name, 4); |
|
1573 | + |
|
1574 | + return $this->importFrom($format, reset($params)); |
|
1575 | + } |
|
1576 | + |
|
1577 | + if (0 === strpos($name, 'to')) { |
|
1578 | + $format = substr($name, 2); |
|
1579 | + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
1580 | + |
|
1581 | + return $this->exportTo($format, $includeLazyLoadColumns); |
|
1582 | + } |
|
1583 | + |
|
1584 | + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
1585 | + } |
|
1586 | 1586 | |
1587 | 1587 | } |
@@ -73,7 +73,6 @@ discard block |
||
73 | 73 | * @method ChildConnection findOneByPeer(string $peer) Return the first ChildConnection filtered by the peer column |
74 | 74 | * @method ChildConnection findOneByStarted(string $started) Return the first ChildConnection filtered by the started column |
75 | 75 | * @method ChildConnection findOneByType(string $type) Return the first ChildConnection filtered by the type column * |
76 | - |
|
77 | 76 | * @method ChildConnection requirePk($key, ConnectionInterface $con = null) Return the ChildConnection by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
78 | 77 | * @method ChildConnection requireOne(ConnectionInterface $con = null) Return the first ChildConnection matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
79 | 78 | * |
@@ -96,626 +95,626 @@ discard block |
||
96 | 95 | */ |
97 | 96 | abstract class ConnectionQuery extends ModelCriteria |
98 | 97 | { |
99 | - protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
100 | - |
|
101 | - /** |
|
102 | - * Initializes internal state of \Jalle19\StatusManager\Database\Base\ConnectionQuery object. |
|
103 | - * |
|
104 | - * @param string $dbName The database name |
|
105 | - * @param string $modelName The phpName of a model, e.g. 'Book' |
|
106 | - * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
107 | - */ |
|
108 | - public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Connection', $modelAlias = null) |
|
109 | - { |
|
110 | - parent::__construct($dbName, $modelName, $modelAlias); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Returns a new ChildConnectionQuery object. |
|
115 | - * |
|
116 | - * @param string $modelAlias The alias of a model in the query |
|
117 | - * @param Criteria $criteria Optional Criteria to build the query from |
|
118 | - * |
|
119 | - * @return ChildConnectionQuery |
|
120 | - */ |
|
121 | - public static function create($modelAlias = null, Criteria $criteria = null) |
|
122 | - { |
|
123 | - if ($criteria instanceof ChildConnectionQuery) { |
|
124 | - return $criteria; |
|
125 | - } |
|
126 | - $query = new ChildConnectionQuery(); |
|
127 | - if (null !== $modelAlias) { |
|
128 | - $query->setModelAlias($modelAlias); |
|
129 | - } |
|
130 | - if ($criteria instanceof Criteria) { |
|
131 | - $query->mergeWith($criteria); |
|
132 | - } |
|
133 | - |
|
134 | - return $query; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Find object by primary key. |
|
139 | - * Propel uses the instance pool to skip the database if the object exists. |
|
140 | - * Go fast if the query is untouched. |
|
141 | - * |
|
142 | - * <code> |
|
143 | - * $obj = $c->findPk(12, $con); |
|
144 | - * </code> |
|
145 | - * |
|
146 | - * @param mixed $key Primary key to use for the query |
|
147 | - * @param ConnectionInterface $con an optional connection object |
|
148 | - * |
|
149 | - * @return ChildConnection|array|mixed the result, formatted by the current formatter |
|
150 | - */ |
|
151 | - public function findPk($key, ConnectionInterface $con = null) |
|
152 | - { |
|
153 | - if ($key === null) { |
|
154 | - return null; |
|
155 | - } |
|
156 | - if ((null !== ($obj = ConnectionTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
157 | - // the object is already in the instance pool |
|
158 | - return $obj; |
|
159 | - } |
|
160 | - if ($con === null) { |
|
161 | - $con = Propel::getServiceContainer()->getReadConnection(ConnectionTableMap::DATABASE_NAME); |
|
162 | - } |
|
163 | - $this->basePreSelect($con); |
|
164 | - if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
165 | - || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
166 | - || $this->map || $this->having || $this->joins) { |
|
167 | - return $this->findPkComplex($key, $con); |
|
168 | - } else { |
|
169 | - return $this->findPkSimple($key, $con); |
|
170 | - } |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Find object by primary key using raw SQL to go fast. |
|
175 | - * Bypass doSelect() and the object formatter by using generated code. |
|
176 | - * |
|
177 | - * @param mixed $key Primary key to use for the query |
|
178 | - * @param ConnectionInterface $con A connection object |
|
179 | - * |
|
180 | - * @throws \Propel\Runtime\Exception\PropelException |
|
181 | - * |
|
182 | - * @return ChildConnection A model object, or null if the key is not found |
|
183 | - */ |
|
184 | - protected function findPkSimple($key, ConnectionInterface $con) |
|
185 | - { |
|
186 | - $sql = 'SELECT id, instance_name, user_id, peer, started, type FROM connection WHERE id = :p0'; |
|
187 | - try { |
|
188 | - $stmt = $con->prepare($sql); |
|
189 | - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
190 | - $stmt->execute(); |
|
191 | - } catch (Exception $e) { |
|
192 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
193 | - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
194 | - } |
|
195 | - $obj = null; |
|
196 | - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
197 | - /** @var ChildConnection $obj */ |
|
198 | - $obj = new ChildConnection(); |
|
199 | - $obj->hydrate($row); |
|
200 | - ConnectionTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
201 | - } |
|
202 | - $stmt->closeCursor(); |
|
203 | - |
|
204 | - return $obj; |
|
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Find object by primary key. |
|
209 | - * |
|
210 | - * @param mixed $key Primary key to use for the query |
|
211 | - * @param ConnectionInterface $con A connection object |
|
212 | - * |
|
213 | - * @return ChildConnection|array|mixed the result, formatted by the current formatter |
|
214 | - */ |
|
215 | - protected function findPkComplex($key, ConnectionInterface $con) |
|
216 | - { |
|
217 | - // As the query uses a PK condition, no limit(1) is necessary. |
|
218 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
219 | - $dataFetcher = $criteria |
|
220 | - ->filterByPrimaryKey($key) |
|
221 | - ->doSelect($con); |
|
222 | - |
|
223 | - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Find objects by primary key |
|
228 | - * <code> |
|
229 | - * $objs = $c->findPks(array(12, 56, 832), $con); |
|
230 | - * </code> |
|
231 | - * @param array $keys Primary keys to use for the query |
|
232 | - * @param ConnectionInterface $con an optional connection object |
|
233 | - * |
|
234 | - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
235 | - */ |
|
236 | - public function findPks($keys, ConnectionInterface $con = null) |
|
237 | - { |
|
238 | - if (null === $con) { |
|
239 | - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
240 | - } |
|
241 | - $this->basePreSelect($con); |
|
242 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
243 | - $dataFetcher = $criteria |
|
244 | - ->filterByPrimaryKeys($keys) |
|
245 | - ->doSelect($con); |
|
246 | - |
|
247 | - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Filter the query by primary key |
|
252 | - * |
|
253 | - * @param mixed $key Primary key to use for the query |
|
254 | - * |
|
255 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
256 | - */ |
|
257 | - public function filterByPrimaryKey($key) |
|
258 | - { |
|
259 | - |
|
260 | - return $this->addUsingAlias(ConnectionTableMap::COL_ID, $key, Criteria::EQUAL); |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * Filter the query by a list of primary keys |
|
265 | - * |
|
266 | - * @param array $keys The list of primary key to use for the query |
|
267 | - * |
|
268 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
269 | - */ |
|
270 | - public function filterByPrimaryKeys($keys) |
|
271 | - { |
|
272 | - |
|
273 | - return $this->addUsingAlias(ConnectionTableMap::COL_ID, $keys, Criteria::IN); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Filter the query on the id column |
|
278 | - * |
|
279 | - * Example usage: |
|
280 | - * <code> |
|
281 | - * $query->filterById(1234); // WHERE id = 1234 |
|
282 | - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
283 | - * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
284 | - * </code> |
|
285 | - * |
|
286 | - * @param mixed $id The value to use as filter. |
|
287 | - * Use scalar values for equality. |
|
288 | - * Use array values for in_array() equivalent. |
|
289 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
290 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
291 | - * |
|
292 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
293 | - */ |
|
294 | - public function filterById($id = null, $comparison = null) |
|
295 | - { |
|
296 | - if (is_array($id)) { |
|
297 | - $useMinMax = false; |
|
298 | - if (isset($id['min'])) { |
|
299 | - $this->addUsingAlias(ConnectionTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
300 | - $useMinMax = true; |
|
301 | - } |
|
302 | - if (isset($id['max'])) { |
|
303 | - $this->addUsingAlias(ConnectionTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
304 | - $useMinMax = true; |
|
305 | - } |
|
306 | - if ($useMinMax) { |
|
307 | - return $this; |
|
308 | - } |
|
309 | - if (null === $comparison) { |
|
310 | - $comparison = Criteria::IN; |
|
311 | - } |
|
312 | - } |
|
313 | - |
|
314 | - return $this->addUsingAlias(ConnectionTableMap::COL_ID, $id, $comparison); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * Filter the query on the instance_name column |
|
319 | - * |
|
320 | - * Example usage: |
|
321 | - * <code> |
|
322 | - * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
323 | - * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
324 | - * </code> |
|
325 | - * |
|
326 | - * @param string $instanceName The value to use as filter. |
|
327 | - * Accepts wildcards (* and % trigger a LIKE) |
|
328 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
329 | - * |
|
330 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
331 | - */ |
|
332 | - public function filterByInstanceName($instanceName = null, $comparison = null) |
|
333 | - { |
|
334 | - if (null === $comparison) { |
|
335 | - if (is_array($instanceName)) { |
|
336 | - $comparison = Criteria::IN; |
|
337 | - } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
338 | - $instanceName = str_replace('*', '%', $instanceName); |
|
339 | - $comparison = Criteria::LIKE; |
|
340 | - } |
|
341 | - } |
|
342 | - |
|
343 | - return $this->addUsingAlias(ConnectionTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Filter the query on the user_id column |
|
348 | - * |
|
349 | - * Example usage: |
|
350 | - * <code> |
|
351 | - * $query->filterByUserId(1234); // WHERE user_id = 1234 |
|
352 | - * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34) |
|
353 | - * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12 |
|
354 | - * </code> |
|
355 | - * |
|
356 | - * @see filterByUser() |
|
357 | - * |
|
358 | - * @param mixed $userId The value to use as filter. |
|
359 | - * Use scalar values for equality. |
|
360 | - * Use array values for in_array() equivalent. |
|
361 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
362 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
363 | - * |
|
364 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
365 | - */ |
|
366 | - public function filterByUserId($userId = null, $comparison = null) |
|
367 | - { |
|
368 | - if (is_array($userId)) { |
|
369 | - $useMinMax = false; |
|
370 | - if (isset($userId['min'])) { |
|
371 | - $this->addUsingAlias(ConnectionTableMap::COL_USER_ID, $userId['min'], Criteria::GREATER_EQUAL); |
|
372 | - $useMinMax = true; |
|
373 | - } |
|
374 | - if (isset($userId['max'])) { |
|
375 | - $this->addUsingAlias(ConnectionTableMap::COL_USER_ID, $userId['max'], Criteria::LESS_EQUAL); |
|
376 | - $useMinMax = true; |
|
377 | - } |
|
378 | - if ($useMinMax) { |
|
379 | - return $this; |
|
380 | - } |
|
381 | - if (null === $comparison) { |
|
382 | - $comparison = Criteria::IN; |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - return $this->addUsingAlias(ConnectionTableMap::COL_USER_ID, $userId, $comparison); |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * Filter the query on the peer column |
|
391 | - * |
|
392 | - * Example usage: |
|
393 | - * <code> |
|
394 | - * $query->filterByPeer('fooValue'); // WHERE peer = 'fooValue' |
|
395 | - * $query->filterByPeer('%fooValue%'); // WHERE peer LIKE '%fooValue%' |
|
396 | - * </code> |
|
397 | - * |
|
398 | - * @param string $peer The value to use as filter. |
|
399 | - * Accepts wildcards (* and % trigger a LIKE) |
|
400 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
401 | - * |
|
402 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
403 | - */ |
|
404 | - public function filterByPeer($peer = null, $comparison = null) |
|
405 | - { |
|
406 | - if (null === $comparison) { |
|
407 | - if (is_array($peer)) { |
|
408 | - $comparison = Criteria::IN; |
|
409 | - } elseif (preg_match('/[\%\*]/', $peer)) { |
|
410 | - $peer = str_replace('*', '%', $peer); |
|
411 | - $comparison = Criteria::LIKE; |
|
412 | - } |
|
413 | - } |
|
414 | - |
|
415 | - return $this->addUsingAlias(ConnectionTableMap::COL_PEER, $peer, $comparison); |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Filter the query on the started column |
|
420 | - * |
|
421 | - * Example usage: |
|
422 | - * <code> |
|
423 | - * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
|
424 | - * $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
|
425 | - * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
|
426 | - * </code> |
|
427 | - * |
|
428 | - * @param mixed $started The value to use as filter. |
|
429 | - * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
430 | - * Empty strings are treated as NULL. |
|
431 | - * Use scalar values for equality. |
|
432 | - * Use array values for in_array() equivalent. |
|
433 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
434 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
435 | - * |
|
436 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
437 | - */ |
|
438 | - public function filterByStarted($started = null, $comparison = null) |
|
439 | - { |
|
440 | - if (is_array($started)) { |
|
441 | - $useMinMax = false; |
|
442 | - if (isset($started['min'])) { |
|
443 | - $this->addUsingAlias(ConnectionTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
|
444 | - $useMinMax = true; |
|
445 | - } |
|
446 | - if (isset($started['max'])) { |
|
447 | - $this->addUsingAlias(ConnectionTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
|
448 | - $useMinMax = true; |
|
449 | - } |
|
450 | - if ($useMinMax) { |
|
451 | - return $this; |
|
452 | - } |
|
453 | - if (null === $comparison) { |
|
454 | - $comparison = Criteria::IN; |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - return $this->addUsingAlias(ConnectionTableMap::COL_STARTED, $started, $comparison); |
|
459 | - } |
|
460 | - |
|
461 | - /** |
|
462 | - * Filter the query on the type column |
|
463 | - * |
|
464 | - * Example usage: |
|
465 | - * <code> |
|
466 | - * $query->filterByType('fooValue'); // WHERE type = 'fooValue' |
|
467 | - * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' |
|
468 | - * </code> |
|
469 | - * |
|
470 | - * @param string $type The value to use as filter. |
|
471 | - * Accepts wildcards (* and % trigger a LIKE) |
|
472 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
473 | - * |
|
474 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
475 | - */ |
|
476 | - public function filterByType($type = null, $comparison = null) |
|
477 | - { |
|
478 | - if (null === $comparison) { |
|
479 | - if (is_array($type)) { |
|
480 | - $comparison = Criteria::IN; |
|
481 | - } elseif (preg_match('/[\%\*]/', $type)) { |
|
482 | - $type = str_replace('*', '%', $type); |
|
483 | - $comparison = Criteria::LIKE; |
|
484 | - } |
|
485 | - } |
|
486 | - |
|
487 | - return $this->addUsingAlias(ConnectionTableMap::COL_TYPE, $type, $comparison); |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
492 | - * |
|
493 | - * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
494 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
495 | - * |
|
496 | - * @throws \Propel\Runtime\Exception\PropelException |
|
497 | - * |
|
498 | - * @return ChildConnectionQuery The current query, for fluid interface |
|
499 | - */ |
|
500 | - public function filterByInstance($instance, $comparison = null) |
|
501 | - { |
|
502 | - if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
503 | - return $this |
|
504 | - ->addUsingAlias(ConnectionTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
505 | - } elseif ($instance instanceof ObjectCollection) { |
|
506 | - if (null === $comparison) { |
|
507 | - $comparison = Criteria::IN; |
|
508 | - } |
|
509 | - |
|
510 | - return $this |
|
511 | - ->addUsingAlias(ConnectionTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
512 | - } else { |
|
513 | - throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
514 | - } |
|
515 | - } |
|
516 | - |
|
517 | - /** |
|
518 | - * Adds a JOIN clause to the query using the Instance relation |
|
519 | - * |
|
520 | - * @param string $relationAlias optional alias for the relation |
|
521 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
522 | - * |
|
523 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
524 | - */ |
|
525 | - public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
526 | - { |
|
527 | - $tableMap = $this->getTableMap(); |
|
528 | - $relationMap = $tableMap->getRelation('Instance'); |
|
529 | - |
|
530 | - // create a ModelJoin object for this join |
|
531 | - $join = new ModelJoin(); |
|
532 | - $join->setJoinType($joinType); |
|
533 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
534 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
535 | - $join->setPreviousJoin($previousJoin); |
|
536 | - } |
|
537 | - |
|
538 | - // add the ModelJoin to the current object |
|
539 | - if ($relationAlias) { |
|
540 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
541 | - $this->addJoinObject($join, $relationAlias); |
|
542 | - } else { |
|
543 | - $this->addJoinObject($join, 'Instance'); |
|
544 | - } |
|
545 | - |
|
546 | - return $this; |
|
547 | - } |
|
548 | - |
|
549 | - /** |
|
550 | - * Use the Instance relation Instance object |
|
551 | - * |
|
552 | - * @see useQuery() |
|
553 | - * |
|
554 | - * @param string $relationAlias optional alias for the relation, |
|
555 | - * to be used as main alias in the secondary query |
|
556 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
557 | - * |
|
558 | - * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
559 | - */ |
|
560 | - public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
561 | - { |
|
562 | - return $this |
|
563 | - ->joinInstance($relationAlias, $joinType) |
|
564 | - ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
565 | - } |
|
566 | - |
|
567 | - /** |
|
568 | - * Filter the query by a related \Jalle19\StatusManager\Database\User object |
|
569 | - * |
|
570 | - * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user The related object(s) to use as filter |
|
571 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
572 | - * |
|
573 | - * @throws \Propel\Runtime\Exception\PropelException |
|
574 | - * |
|
575 | - * @return ChildConnectionQuery The current query, for fluid interface |
|
576 | - */ |
|
577 | - public function filterByUser($user, $comparison = null) |
|
578 | - { |
|
579 | - if ($user instanceof \Jalle19\StatusManager\Database\User) { |
|
580 | - return $this |
|
581 | - ->addUsingAlias(ConnectionTableMap::COL_USER_ID, $user->getId(), $comparison); |
|
582 | - } elseif ($user instanceof ObjectCollection) { |
|
583 | - if (null === $comparison) { |
|
584 | - $comparison = Criteria::IN; |
|
585 | - } |
|
586 | - |
|
587 | - return $this |
|
588 | - ->addUsingAlias(ConnectionTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); |
|
589 | - } else { |
|
590 | - throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection'); |
|
591 | - } |
|
592 | - } |
|
593 | - |
|
594 | - /** |
|
595 | - * Adds a JOIN clause to the query using the User relation |
|
596 | - * |
|
597 | - * @param string $relationAlias optional alias for the relation |
|
598 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
599 | - * |
|
600 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
601 | - */ |
|
602 | - public function joinUser($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
603 | - { |
|
604 | - $tableMap = $this->getTableMap(); |
|
605 | - $relationMap = $tableMap->getRelation('User'); |
|
606 | - |
|
607 | - // create a ModelJoin object for this join |
|
608 | - $join = new ModelJoin(); |
|
609 | - $join->setJoinType($joinType); |
|
610 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
611 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
612 | - $join->setPreviousJoin($previousJoin); |
|
613 | - } |
|
614 | - |
|
615 | - // add the ModelJoin to the current object |
|
616 | - if ($relationAlias) { |
|
617 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
618 | - $this->addJoinObject($join, $relationAlias); |
|
619 | - } else { |
|
620 | - $this->addJoinObject($join, 'User'); |
|
621 | - } |
|
622 | - |
|
623 | - return $this; |
|
624 | - } |
|
625 | - |
|
626 | - /** |
|
627 | - * Use the User relation User object |
|
628 | - * |
|
629 | - * @see useQuery() |
|
630 | - * |
|
631 | - * @param string $relationAlias optional alias for the relation, |
|
632 | - * to be used as main alias in the secondary query |
|
633 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
634 | - * |
|
635 | - * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query |
|
636 | - */ |
|
637 | - public function useUserQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
638 | - { |
|
639 | - return $this |
|
640 | - ->joinUser($relationAlias, $joinType) |
|
641 | - ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery'); |
|
642 | - } |
|
643 | - |
|
644 | - /** |
|
645 | - * Exclude object from result |
|
646 | - * |
|
647 | - * @param ChildConnection $connection Object to remove from the list of results |
|
648 | - * |
|
649 | - * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
650 | - */ |
|
651 | - public function prune($connection = null) |
|
652 | - { |
|
653 | - if ($connection) { |
|
654 | - $this->addUsingAlias(ConnectionTableMap::COL_ID, $connection->getId(), Criteria::NOT_EQUAL); |
|
655 | - } |
|
656 | - |
|
657 | - return $this; |
|
658 | - } |
|
659 | - |
|
660 | - /** |
|
661 | - * Deletes all rows from the connection table. |
|
662 | - * |
|
663 | - * @param ConnectionInterface $con the connection to use |
|
664 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
665 | - */ |
|
666 | - public function doDeleteAll(ConnectionInterface $con = null) |
|
667 | - { |
|
668 | - if (null === $con) { |
|
669 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
670 | - } |
|
671 | - |
|
672 | - // use transaction because $criteria could contain info |
|
673 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
674 | - return $con->transaction(function () use ($con) { |
|
675 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
676 | - $affectedRows += parent::doDeleteAll($con); |
|
677 | - // Because this db requires some delete cascade/set null emulation, we have to |
|
678 | - // clear the cached instance *after* the emulation has happened (since |
|
679 | - // instances get re-added by the select statement contained therein). |
|
680 | - ConnectionTableMap::clearInstancePool(); |
|
681 | - ConnectionTableMap::clearRelatedInstancePool(); |
|
682 | - |
|
683 | - return $affectedRows; |
|
684 | - }); |
|
685 | - } |
|
686 | - |
|
687 | - /** |
|
688 | - * Performs a DELETE on the database based on the current ModelCriteria |
|
689 | - * |
|
690 | - * @param ConnectionInterface $con the connection to use |
|
691 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
692 | - * if supported by native driver or if emulated using Propel. |
|
693 | - * @throws PropelException Any exceptions caught during processing will be |
|
694 | - * rethrown wrapped into a PropelException. |
|
695 | - */ |
|
696 | - public function delete(ConnectionInterface $con = null) |
|
697 | - { |
|
698 | - if (null === $con) { |
|
699 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
700 | - } |
|
701 | - |
|
702 | - $criteria = $this; |
|
703 | - |
|
704 | - // Set the correct dbName |
|
705 | - $criteria->setDbName(ConnectionTableMap::DATABASE_NAME); |
|
706 | - |
|
707 | - // use transaction because $criteria could contain info |
|
708 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
709 | - return $con->transaction(function () use ($con, $criteria) { |
|
710 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
711 | - |
|
712 | - ConnectionTableMap::removeInstanceFromPool($criteria); |
|
713 | - |
|
714 | - $affectedRows += ModelCriteria::delete($con); |
|
715 | - ConnectionTableMap::clearRelatedInstancePool(); |
|
716 | - |
|
717 | - return $affectedRows; |
|
718 | - }); |
|
719 | - } |
|
98 | + protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
99 | + |
|
100 | + /** |
|
101 | + * Initializes internal state of \Jalle19\StatusManager\Database\Base\ConnectionQuery object. |
|
102 | + * |
|
103 | + * @param string $dbName The database name |
|
104 | + * @param string $modelName The phpName of a model, e.g. 'Book' |
|
105 | + * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
106 | + */ |
|
107 | + public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Connection', $modelAlias = null) |
|
108 | + { |
|
109 | + parent::__construct($dbName, $modelName, $modelAlias); |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Returns a new ChildConnectionQuery object. |
|
114 | + * |
|
115 | + * @param string $modelAlias The alias of a model in the query |
|
116 | + * @param Criteria $criteria Optional Criteria to build the query from |
|
117 | + * |
|
118 | + * @return ChildConnectionQuery |
|
119 | + */ |
|
120 | + public static function create($modelAlias = null, Criteria $criteria = null) |
|
121 | + { |
|
122 | + if ($criteria instanceof ChildConnectionQuery) { |
|
123 | + return $criteria; |
|
124 | + } |
|
125 | + $query = new ChildConnectionQuery(); |
|
126 | + if (null !== $modelAlias) { |
|
127 | + $query->setModelAlias($modelAlias); |
|
128 | + } |
|
129 | + if ($criteria instanceof Criteria) { |
|
130 | + $query->mergeWith($criteria); |
|
131 | + } |
|
132 | + |
|
133 | + return $query; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Find object by primary key. |
|
138 | + * Propel uses the instance pool to skip the database if the object exists. |
|
139 | + * Go fast if the query is untouched. |
|
140 | + * |
|
141 | + * <code> |
|
142 | + * $obj = $c->findPk(12, $con); |
|
143 | + * </code> |
|
144 | + * |
|
145 | + * @param mixed $key Primary key to use for the query |
|
146 | + * @param ConnectionInterface $con an optional connection object |
|
147 | + * |
|
148 | + * @return ChildConnection|array|mixed the result, formatted by the current formatter |
|
149 | + */ |
|
150 | + public function findPk($key, ConnectionInterface $con = null) |
|
151 | + { |
|
152 | + if ($key === null) { |
|
153 | + return null; |
|
154 | + } |
|
155 | + if ((null !== ($obj = ConnectionTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
156 | + // the object is already in the instance pool |
|
157 | + return $obj; |
|
158 | + } |
|
159 | + if ($con === null) { |
|
160 | + $con = Propel::getServiceContainer()->getReadConnection(ConnectionTableMap::DATABASE_NAME); |
|
161 | + } |
|
162 | + $this->basePreSelect($con); |
|
163 | + if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
164 | + || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
165 | + || $this->map || $this->having || $this->joins) { |
|
166 | + return $this->findPkComplex($key, $con); |
|
167 | + } else { |
|
168 | + return $this->findPkSimple($key, $con); |
|
169 | + } |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Find object by primary key using raw SQL to go fast. |
|
174 | + * Bypass doSelect() and the object formatter by using generated code. |
|
175 | + * |
|
176 | + * @param mixed $key Primary key to use for the query |
|
177 | + * @param ConnectionInterface $con A connection object |
|
178 | + * |
|
179 | + * @throws \Propel\Runtime\Exception\PropelException |
|
180 | + * |
|
181 | + * @return ChildConnection A model object, or null if the key is not found |
|
182 | + */ |
|
183 | + protected function findPkSimple($key, ConnectionInterface $con) |
|
184 | + { |
|
185 | + $sql = 'SELECT id, instance_name, user_id, peer, started, type FROM connection WHERE id = :p0'; |
|
186 | + try { |
|
187 | + $stmt = $con->prepare($sql); |
|
188 | + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
189 | + $stmt->execute(); |
|
190 | + } catch (Exception $e) { |
|
191 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
192 | + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
193 | + } |
|
194 | + $obj = null; |
|
195 | + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
196 | + /** @var ChildConnection $obj */ |
|
197 | + $obj = new ChildConnection(); |
|
198 | + $obj->hydrate($row); |
|
199 | + ConnectionTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
200 | + } |
|
201 | + $stmt->closeCursor(); |
|
202 | + |
|
203 | + return $obj; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Find object by primary key. |
|
208 | + * |
|
209 | + * @param mixed $key Primary key to use for the query |
|
210 | + * @param ConnectionInterface $con A connection object |
|
211 | + * |
|
212 | + * @return ChildConnection|array|mixed the result, formatted by the current formatter |
|
213 | + */ |
|
214 | + protected function findPkComplex($key, ConnectionInterface $con) |
|
215 | + { |
|
216 | + // As the query uses a PK condition, no limit(1) is necessary. |
|
217 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
218 | + $dataFetcher = $criteria |
|
219 | + ->filterByPrimaryKey($key) |
|
220 | + ->doSelect($con); |
|
221 | + |
|
222 | + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Find objects by primary key |
|
227 | + * <code> |
|
228 | + * $objs = $c->findPks(array(12, 56, 832), $con); |
|
229 | + * </code> |
|
230 | + * @param array $keys Primary keys to use for the query |
|
231 | + * @param ConnectionInterface $con an optional connection object |
|
232 | + * |
|
233 | + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
234 | + */ |
|
235 | + public function findPks($keys, ConnectionInterface $con = null) |
|
236 | + { |
|
237 | + if (null === $con) { |
|
238 | + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
239 | + } |
|
240 | + $this->basePreSelect($con); |
|
241 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
242 | + $dataFetcher = $criteria |
|
243 | + ->filterByPrimaryKeys($keys) |
|
244 | + ->doSelect($con); |
|
245 | + |
|
246 | + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Filter the query by primary key |
|
251 | + * |
|
252 | + * @param mixed $key Primary key to use for the query |
|
253 | + * |
|
254 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
255 | + */ |
|
256 | + public function filterByPrimaryKey($key) |
|
257 | + { |
|
258 | + |
|
259 | + return $this->addUsingAlias(ConnectionTableMap::COL_ID, $key, Criteria::EQUAL); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Filter the query by a list of primary keys |
|
264 | + * |
|
265 | + * @param array $keys The list of primary key to use for the query |
|
266 | + * |
|
267 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
268 | + */ |
|
269 | + public function filterByPrimaryKeys($keys) |
|
270 | + { |
|
271 | + |
|
272 | + return $this->addUsingAlias(ConnectionTableMap::COL_ID, $keys, Criteria::IN); |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * Filter the query on the id column |
|
277 | + * |
|
278 | + * Example usage: |
|
279 | + * <code> |
|
280 | + * $query->filterById(1234); // WHERE id = 1234 |
|
281 | + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
282 | + * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
283 | + * </code> |
|
284 | + * |
|
285 | + * @param mixed $id The value to use as filter. |
|
286 | + * Use scalar values for equality. |
|
287 | + * Use array values for in_array() equivalent. |
|
288 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
289 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
290 | + * |
|
291 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
292 | + */ |
|
293 | + public function filterById($id = null, $comparison = null) |
|
294 | + { |
|
295 | + if (is_array($id)) { |
|
296 | + $useMinMax = false; |
|
297 | + if (isset($id['min'])) { |
|
298 | + $this->addUsingAlias(ConnectionTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
299 | + $useMinMax = true; |
|
300 | + } |
|
301 | + if (isset($id['max'])) { |
|
302 | + $this->addUsingAlias(ConnectionTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
303 | + $useMinMax = true; |
|
304 | + } |
|
305 | + if ($useMinMax) { |
|
306 | + return $this; |
|
307 | + } |
|
308 | + if (null === $comparison) { |
|
309 | + $comparison = Criteria::IN; |
|
310 | + } |
|
311 | + } |
|
312 | + |
|
313 | + return $this->addUsingAlias(ConnectionTableMap::COL_ID, $id, $comparison); |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Filter the query on the instance_name column |
|
318 | + * |
|
319 | + * Example usage: |
|
320 | + * <code> |
|
321 | + * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
322 | + * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
323 | + * </code> |
|
324 | + * |
|
325 | + * @param string $instanceName The value to use as filter. |
|
326 | + * Accepts wildcards (* and % trigger a LIKE) |
|
327 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
328 | + * |
|
329 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
330 | + */ |
|
331 | + public function filterByInstanceName($instanceName = null, $comparison = null) |
|
332 | + { |
|
333 | + if (null === $comparison) { |
|
334 | + if (is_array($instanceName)) { |
|
335 | + $comparison = Criteria::IN; |
|
336 | + } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
337 | + $instanceName = str_replace('*', '%', $instanceName); |
|
338 | + $comparison = Criteria::LIKE; |
|
339 | + } |
|
340 | + } |
|
341 | + |
|
342 | + return $this->addUsingAlias(ConnectionTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * Filter the query on the user_id column |
|
347 | + * |
|
348 | + * Example usage: |
|
349 | + * <code> |
|
350 | + * $query->filterByUserId(1234); // WHERE user_id = 1234 |
|
351 | + * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34) |
|
352 | + * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12 |
|
353 | + * </code> |
|
354 | + * |
|
355 | + * @see filterByUser() |
|
356 | + * |
|
357 | + * @param mixed $userId The value to use as filter. |
|
358 | + * Use scalar values for equality. |
|
359 | + * Use array values for in_array() equivalent. |
|
360 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
361 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
362 | + * |
|
363 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
364 | + */ |
|
365 | + public function filterByUserId($userId = null, $comparison = null) |
|
366 | + { |
|
367 | + if (is_array($userId)) { |
|
368 | + $useMinMax = false; |
|
369 | + if (isset($userId['min'])) { |
|
370 | + $this->addUsingAlias(ConnectionTableMap::COL_USER_ID, $userId['min'], Criteria::GREATER_EQUAL); |
|
371 | + $useMinMax = true; |
|
372 | + } |
|
373 | + if (isset($userId['max'])) { |
|
374 | + $this->addUsingAlias(ConnectionTableMap::COL_USER_ID, $userId['max'], Criteria::LESS_EQUAL); |
|
375 | + $useMinMax = true; |
|
376 | + } |
|
377 | + if ($useMinMax) { |
|
378 | + return $this; |
|
379 | + } |
|
380 | + if (null === $comparison) { |
|
381 | + $comparison = Criteria::IN; |
|
382 | + } |
|
383 | + } |
|
384 | + |
|
385 | + return $this->addUsingAlias(ConnectionTableMap::COL_USER_ID, $userId, $comparison); |
|
386 | + } |
|
387 | + |
|
388 | + /** |
|
389 | + * Filter the query on the peer column |
|
390 | + * |
|
391 | + * Example usage: |
|
392 | + * <code> |
|
393 | + * $query->filterByPeer('fooValue'); // WHERE peer = 'fooValue' |
|
394 | + * $query->filterByPeer('%fooValue%'); // WHERE peer LIKE '%fooValue%' |
|
395 | + * </code> |
|
396 | + * |
|
397 | + * @param string $peer The value to use as filter. |
|
398 | + * Accepts wildcards (* and % trigger a LIKE) |
|
399 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
400 | + * |
|
401 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
402 | + */ |
|
403 | + public function filterByPeer($peer = null, $comparison = null) |
|
404 | + { |
|
405 | + if (null === $comparison) { |
|
406 | + if (is_array($peer)) { |
|
407 | + $comparison = Criteria::IN; |
|
408 | + } elseif (preg_match('/[\%\*]/', $peer)) { |
|
409 | + $peer = str_replace('*', '%', $peer); |
|
410 | + $comparison = Criteria::LIKE; |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + return $this->addUsingAlias(ConnectionTableMap::COL_PEER, $peer, $comparison); |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * Filter the query on the started column |
|
419 | + * |
|
420 | + * Example usage: |
|
421 | + * <code> |
|
422 | + * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
|
423 | + * $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
|
424 | + * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
|
425 | + * </code> |
|
426 | + * |
|
427 | + * @param mixed $started The value to use as filter. |
|
428 | + * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
429 | + * Empty strings are treated as NULL. |
|
430 | + * Use scalar values for equality. |
|
431 | + * Use array values for in_array() equivalent. |
|
432 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
433 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
434 | + * |
|
435 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
436 | + */ |
|
437 | + public function filterByStarted($started = null, $comparison = null) |
|
438 | + { |
|
439 | + if (is_array($started)) { |
|
440 | + $useMinMax = false; |
|
441 | + if (isset($started['min'])) { |
|
442 | + $this->addUsingAlias(ConnectionTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
|
443 | + $useMinMax = true; |
|
444 | + } |
|
445 | + if (isset($started['max'])) { |
|
446 | + $this->addUsingAlias(ConnectionTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
|
447 | + $useMinMax = true; |
|
448 | + } |
|
449 | + if ($useMinMax) { |
|
450 | + return $this; |
|
451 | + } |
|
452 | + if (null === $comparison) { |
|
453 | + $comparison = Criteria::IN; |
|
454 | + } |
|
455 | + } |
|
456 | + |
|
457 | + return $this->addUsingAlias(ConnectionTableMap::COL_STARTED, $started, $comparison); |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * Filter the query on the type column |
|
462 | + * |
|
463 | + * Example usage: |
|
464 | + * <code> |
|
465 | + * $query->filterByType('fooValue'); // WHERE type = 'fooValue' |
|
466 | + * $query->filterByType('%fooValue%'); // WHERE type LIKE '%fooValue%' |
|
467 | + * </code> |
|
468 | + * |
|
469 | + * @param string $type The value to use as filter. |
|
470 | + * Accepts wildcards (* and % trigger a LIKE) |
|
471 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
472 | + * |
|
473 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
474 | + */ |
|
475 | + public function filterByType($type = null, $comparison = null) |
|
476 | + { |
|
477 | + if (null === $comparison) { |
|
478 | + if (is_array($type)) { |
|
479 | + $comparison = Criteria::IN; |
|
480 | + } elseif (preg_match('/[\%\*]/', $type)) { |
|
481 | + $type = str_replace('*', '%', $type); |
|
482 | + $comparison = Criteria::LIKE; |
|
483 | + } |
|
484 | + } |
|
485 | + |
|
486 | + return $this->addUsingAlias(ConnectionTableMap::COL_TYPE, $type, $comparison); |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
491 | + * |
|
492 | + * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
493 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
494 | + * |
|
495 | + * @throws \Propel\Runtime\Exception\PropelException |
|
496 | + * |
|
497 | + * @return ChildConnectionQuery The current query, for fluid interface |
|
498 | + */ |
|
499 | + public function filterByInstance($instance, $comparison = null) |
|
500 | + { |
|
501 | + if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
502 | + return $this |
|
503 | + ->addUsingAlias(ConnectionTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
504 | + } elseif ($instance instanceof ObjectCollection) { |
|
505 | + if (null === $comparison) { |
|
506 | + $comparison = Criteria::IN; |
|
507 | + } |
|
508 | + |
|
509 | + return $this |
|
510 | + ->addUsingAlias(ConnectionTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
511 | + } else { |
|
512 | + throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
513 | + } |
|
514 | + } |
|
515 | + |
|
516 | + /** |
|
517 | + * Adds a JOIN clause to the query using the Instance relation |
|
518 | + * |
|
519 | + * @param string $relationAlias optional alias for the relation |
|
520 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
521 | + * |
|
522 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
523 | + */ |
|
524 | + public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
525 | + { |
|
526 | + $tableMap = $this->getTableMap(); |
|
527 | + $relationMap = $tableMap->getRelation('Instance'); |
|
528 | + |
|
529 | + // create a ModelJoin object for this join |
|
530 | + $join = new ModelJoin(); |
|
531 | + $join->setJoinType($joinType); |
|
532 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
533 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
534 | + $join->setPreviousJoin($previousJoin); |
|
535 | + } |
|
536 | + |
|
537 | + // add the ModelJoin to the current object |
|
538 | + if ($relationAlias) { |
|
539 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
540 | + $this->addJoinObject($join, $relationAlias); |
|
541 | + } else { |
|
542 | + $this->addJoinObject($join, 'Instance'); |
|
543 | + } |
|
544 | + |
|
545 | + return $this; |
|
546 | + } |
|
547 | + |
|
548 | + /** |
|
549 | + * Use the Instance relation Instance object |
|
550 | + * |
|
551 | + * @see useQuery() |
|
552 | + * |
|
553 | + * @param string $relationAlias optional alias for the relation, |
|
554 | + * to be used as main alias in the secondary query |
|
555 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
556 | + * |
|
557 | + * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
558 | + */ |
|
559 | + public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
560 | + { |
|
561 | + return $this |
|
562 | + ->joinInstance($relationAlias, $joinType) |
|
563 | + ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Filter the query by a related \Jalle19\StatusManager\Database\User object |
|
568 | + * |
|
569 | + * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user The related object(s) to use as filter |
|
570 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
571 | + * |
|
572 | + * @throws \Propel\Runtime\Exception\PropelException |
|
573 | + * |
|
574 | + * @return ChildConnectionQuery The current query, for fluid interface |
|
575 | + */ |
|
576 | + public function filterByUser($user, $comparison = null) |
|
577 | + { |
|
578 | + if ($user instanceof \Jalle19\StatusManager\Database\User) { |
|
579 | + return $this |
|
580 | + ->addUsingAlias(ConnectionTableMap::COL_USER_ID, $user->getId(), $comparison); |
|
581 | + } elseif ($user instanceof ObjectCollection) { |
|
582 | + if (null === $comparison) { |
|
583 | + $comparison = Criteria::IN; |
|
584 | + } |
|
585 | + |
|
586 | + return $this |
|
587 | + ->addUsingAlias(ConnectionTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); |
|
588 | + } else { |
|
589 | + throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection'); |
|
590 | + } |
|
591 | + } |
|
592 | + |
|
593 | + /** |
|
594 | + * Adds a JOIN clause to the query using the User relation |
|
595 | + * |
|
596 | + * @param string $relationAlias optional alias for the relation |
|
597 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
598 | + * |
|
599 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
600 | + */ |
|
601 | + public function joinUser($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
602 | + { |
|
603 | + $tableMap = $this->getTableMap(); |
|
604 | + $relationMap = $tableMap->getRelation('User'); |
|
605 | + |
|
606 | + // create a ModelJoin object for this join |
|
607 | + $join = new ModelJoin(); |
|
608 | + $join->setJoinType($joinType); |
|
609 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
610 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
611 | + $join->setPreviousJoin($previousJoin); |
|
612 | + } |
|
613 | + |
|
614 | + // add the ModelJoin to the current object |
|
615 | + if ($relationAlias) { |
|
616 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
617 | + $this->addJoinObject($join, $relationAlias); |
|
618 | + } else { |
|
619 | + $this->addJoinObject($join, 'User'); |
|
620 | + } |
|
621 | + |
|
622 | + return $this; |
|
623 | + } |
|
624 | + |
|
625 | + /** |
|
626 | + * Use the User relation User object |
|
627 | + * |
|
628 | + * @see useQuery() |
|
629 | + * |
|
630 | + * @param string $relationAlias optional alias for the relation, |
|
631 | + * to be used as main alias in the secondary query |
|
632 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
633 | + * |
|
634 | + * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query |
|
635 | + */ |
|
636 | + public function useUserQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
637 | + { |
|
638 | + return $this |
|
639 | + ->joinUser($relationAlias, $joinType) |
|
640 | + ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery'); |
|
641 | + } |
|
642 | + |
|
643 | + /** |
|
644 | + * Exclude object from result |
|
645 | + * |
|
646 | + * @param ChildConnection $connection Object to remove from the list of results |
|
647 | + * |
|
648 | + * @return $this|ChildConnectionQuery The current query, for fluid interface |
|
649 | + */ |
|
650 | + public function prune($connection = null) |
|
651 | + { |
|
652 | + if ($connection) { |
|
653 | + $this->addUsingAlias(ConnectionTableMap::COL_ID, $connection->getId(), Criteria::NOT_EQUAL); |
|
654 | + } |
|
655 | + |
|
656 | + return $this; |
|
657 | + } |
|
658 | + |
|
659 | + /** |
|
660 | + * Deletes all rows from the connection table. |
|
661 | + * |
|
662 | + * @param ConnectionInterface $con the connection to use |
|
663 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
664 | + */ |
|
665 | + public function doDeleteAll(ConnectionInterface $con = null) |
|
666 | + { |
|
667 | + if (null === $con) { |
|
668 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
669 | + } |
|
670 | + |
|
671 | + // use transaction because $criteria could contain info |
|
672 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
673 | + return $con->transaction(function () use ($con) { |
|
674 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
675 | + $affectedRows += parent::doDeleteAll($con); |
|
676 | + // Because this db requires some delete cascade/set null emulation, we have to |
|
677 | + // clear the cached instance *after* the emulation has happened (since |
|
678 | + // instances get re-added by the select statement contained therein). |
|
679 | + ConnectionTableMap::clearInstancePool(); |
|
680 | + ConnectionTableMap::clearRelatedInstancePool(); |
|
681 | + |
|
682 | + return $affectedRows; |
|
683 | + }); |
|
684 | + } |
|
685 | + |
|
686 | + /** |
|
687 | + * Performs a DELETE on the database based on the current ModelCriteria |
|
688 | + * |
|
689 | + * @param ConnectionInterface $con the connection to use |
|
690 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
691 | + * if supported by native driver or if emulated using Propel. |
|
692 | + * @throws PropelException Any exceptions caught during processing will be |
|
693 | + * rethrown wrapped into a PropelException. |
|
694 | + */ |
|
695 | + public function delete(ConnectionInterface $con = null) |
|
696 | + { |
|
697 | + if (null === $con) { |
|
698 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
699 | + } |
|
700 | + |
|
701 | + $criteria = $this; |
|
702 | + |
|
703 | + // Set the correct dbName |
|
704 | + $criteria->setDbName(ConnectionTableMap::DATABASE_NAME); |
|
705 | + |
|
706 | + // use transaction because $criteria could contain info |
|
707 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
708 | + return $con->transaction(function () use ($con, $criteria) { |
|
709 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
710 | + |
|
711 | + ConnectionTableMap::removeInstanceFromPool($criteria); |
|
712 | + |
|
713 | + $affectedRows += ModelCriteria::delete($con); |
|
714 | + ConnectionTableMap::clearRelatedInstancePool(); |
|
715 | + |
|
716 | + return $affectedRows; |
|
717 | + }); |
|
718 | + } |
|
720 | 719 | |
721 | 720 | } // ConnectionQuery |
@@ -74,7 +74,6 @@ discard block |
||
74 | 74 | * @method ChildUser findOneById(int $id) Return the first ChildUser filtered by the id column |
75 | 75 | * @method ChildUser findOneByInstanceName(string $instance_name) Return the first ChildUser filtered by the instance_name column |
76 | 76 | * @method ChildUser findOneByName(string $name) Return the first ChildUser filtered by the name column * |
77 | - |
|
78 | 77 | * @method ChildUser requirePk($key, ConnectionInterface $con = null) Return the ChildUser by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
79 | 78 | * @method ChildUser requireOne(ConnectionInterface $con = null) Return the first ChildUser matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
80 | 79 | * |
@@ -91,580 +90,580 @@ discard block |
||
91 | 90 | */ |
92 | 91 | abstract class UserQuery extends ModelCriteria |
93 | 92 | { |
94 | - protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
95 | - |
|
96 | - /** |
|
97 | - * Initializes internal state of \Jalle19\StatusManager\Database\Base\UserQuery object. |
|
98 | - * |
|
99 | - * @param string $dbName The database name |
|
100 | - * @param string $modelName The phpName of a model, e.g. 'Book' |
|
101 | - * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
102 | - */ |
|
103 | - public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\User', $modelAlias = null) |
|
104 | - { |
|
105 | - parent::__construct($dbName, $modelName, $modelAlias); |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Returns a new ChildUserQuery object. |
|
110 | - * |
|
111 | - * @param string $modelAlias The alias of a model in the query |
|
112 | - * @param Criteria $criteria Optional Criteria to build the query from |
|
113 | - * |
|
114 | - * @return ChildUserQuery |
|
115 | - */ |
|
116 | - public static function create($modelAlias = null, Criteria $criteria = null) |
|
117 | - { |
|
118 | - if ($criteria instanceof ChildUserQuery) { |
|
119 | - return $criteria; |
|
120 | - } |
|
121 | - $query = new ChildUserQuery(); |
|
122 | - if (null !== $modelAlias) { |
|
123 | - $query->setModelAlias($modelAlias); |
|
124 | - } |
|
125 | - if ($criteria instanceof Criteria) { |
|
126 | - $query->mergeWith($criteria); |
|
127 | - } |
|
128 | - |
|
129 | - return $query; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Find object by primary key. |
|
134 | - * Propel uses the instance pool to skip the database if the object exists. |
|
135 | - * Go fast if the query is untouched. |
|
136 | - * |
|
137 | - * <code> |
|
138 | - * $obj = $c->findPk(12, $con); |
|
139 | - * </code> |
|
140 | - * |
|
141 | - * @param mixed $key Primary key to use for the query |
|
142 | - * @param ConnectionInterface $con an optional connection object |
|
143 | - * |
|
144 | - * @return ChildUser|array|mixed the result, formatted by the current formatter |
|
145 | - */ |
|
146 | - public function findPk($key, ConnectionInterface $con = null) |
|
147 | - { |
|
148 | - if ($key === null) { |
|
149 | - return null; |
|
150 | - } |
|
151 | - if ((null !== ($obj = UserTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
152 | - // the object is already in the instance pool |
|
153 | - return $obj; |
|
154 | - } |
|
155 | - if ($con === null) { |
|
156 | - $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME); |
|
157 | - } |
|
158 | - $this->basePreSelect($con); |
|
159 | - if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
160 | - || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
161 | - || $this->map || $this->having || $this->joins) { |
|
162 | - return $this->findPkComplex($key, $con); |
|
163 | - } else { |
|
164 | - return $this->findPkSimple($key, $con); |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Find object by primary key using raw SQL to go fast. |
|
170 | - * Bypass doSelect() and the object formatter by using generated code. |
|
171 | - * |
|
172 | - * @param mixed $key Primary key to use for the query |
|
173 | - * @param ConnectionInterface $con A connection object |
|
174 | - * |
|
175 | - * @throws \Propel\Runtime\Exception\PropelException |
|
176 | - * |
|
177 | - * @return ChildUser A model object, or null if the key is not found |
|
178 | - */ |
|
179 | - protected function findPkSimple($key, ConnectionInterface $con) |
|
180 | - { |
|
181 | - $sql = 'SELECT id, instance_name, name FROM user WHERE id = :p0'; |
|
182 | - try { |
|
183 | - $stmt = $con->prepare($sql); |
|
184 | - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
185 | - $stmt->execute(); |
|
186 | - } catch (Exception $e) { |
|
187 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
188 | - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
189 | - } |
|
190 | - $obj = null; |
|
191 | - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
192 | - /** @var ChildUser $obj */ |
|
193 | - $obj = new ChildUser(); |
|
194 | - $obj->hydrate($row); |
|
195 | - UserTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
196 | - } |
|
197 | - $stmt->closeCursor(); |
|
198 | - |
|
199 | - return $obj; |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * Find object by primary key. |
|
204 | - * |
|
205 | - * @param mixed $key Primary key to use for the query |
|
206 | - * @param ConnectionInterface $con A connection object |
|
207 | - * |
|
208 | - * @return ChildUser|array|mixed the result, formatted by the current formatter |
|
209 | - */ |
|
210 | - protected function findPkComplex($key, ConnectionInterface $con) |
|
211 | - { |
|
212 | - // As the query uses a PK condition, no limit(1) is necessary. |
|
213 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
214 | - $dataFetcher = $criteria |
|
215 | - ->filterByPrimaryKey($key) |
|
216 | - ->doSelect($con); |
|
217 | - |
|
218 | - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Find objects by primary key |
|
223 | - * <code> |
|
224 | - * $objs = $c->findPks(array(12, 56, 832), $con); |
|
225 | - * </code> |
|
226 | - * @param array $keys Primary keys to use for the query |
|
227 | - * @param ConnectionInterface $con an optional connection object |
|
228 | - * |
|
229 | - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
230 | - */ |
|
231 | - public function findPks($keys, ConnectionInterface $con = null) |
|
232 | - { |
|
233 | - if (null === $con) { |
|
234 | - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
235 | - } |
|
236 | - $this->basePreSelect($con); |
|
237 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
238 | - $dataFetcher = $criteria |
|
239 | - ->filterByPrimaryKeys($keys) |
|
240 | - ->doSelect($con); |
|
241 | - |
|
242 | - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Filter the query by primary key |
|
247 | - * |
|
248 | - * @param mixed $key Primary key to use for the query |
|
249 | - * |
|
250 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
251 | - */ |
|
252 | - public function filterByPrimaryKey($key) |
|
253 | - { |
|
254 | - |
|
255 | - return $this->addUsingAlias(UserTableMap::COL_ID, $key, Criteria::EQUAL); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Filter the query by a list of primary keys |
|
260 | - * |
|
261 | - * @param array $keys The list of primary key to use for the query |
|
262 | - * |
|
263 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
264 | - */ |
|
265 | - public function filterByPrimaryKeys($keys) |
|
266 | - { |
|
267 | - |
|
268 | - return $this->addUsingAlias(UserTableMap::COL_ID, $keys, Criteria::IN); |
|
269 | - } |
|
270 | - |
|
271 | - /** |
|
272 | - * Filter the query on the id column |
|
273 | - * |
|
274 | - * Example usage: |
|
275 | - * <code> |
|
276 | - * $query->filterById(1234); // WHERE id = 1234 |
|
277 | - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
278 | - * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
279 | - * </code> |
|
280 | - * |
|
281 | - * @param mixed $id The value to use as filter. |
|
282 | - * Use scalar values for equality. |
|
283 | - * Use array values for in_array() equivalent. |
|
284 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
285 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
286 | - * |
|
287 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
288 | - */ |
|
289 | - public function filterById($id = null, $comparison = null) |
|
290 | - { |
|
291 | - if (is_array($id)) { |
|
292 | - $useMinMax = false; |
|
293 | - if (isset($id['min'])) { |
|
294 | - $this->addUsingAlias(UserTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
295 | - $useMinMax = true; |
|
296 | - } |
|
297 | - if (isset($id['max'])) { |
|
298 | - $this->addUsingAlias(UserTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
299 | - $useMinMax = true; |
|
300 | - } |
|
301 | - if ($useMinMax) { |
|
302 | - return $this; |
|
303 | - } |
|
304 | - if (null === $comparison) { |
|
305 | - $comparison = Criteria::IN; |
|
306 | - } |
|
307 | - } |
|
308 | - |
|
309 | - return $this->addUsingAlias(UserTableMap::COL_ID, $id, $comparison); |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Filter the query on the instance_name column |
|
314 | - * |
|
315 | - * Example usage: |
|
316 | - * <code> |
|
317 | - * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
318 | - * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
319 | - * </code> |
|
320 | - * |
|
321 | - * @param string $instanceName The value to use as filter. |
|
322 | - * Accepts wildcards (* and % trigger a LIKE) |
|
323 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
324 | - * |
|
325 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
326 | - */ |
|
327 | - public function filterByInstanceName($instanceName = null, $comparison = null) |
|
328 | - { |
|
329 | - if (null === $comparison) { |
|
330 | - if (is_array($instanceName)) { |
|
331 | - $comparison = Criteria::IN; |
|
332 | - } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
333 | - $instanceName = str_replace('*', '%', $instanceName); |
|
334 | - $comparison = Criteria::LIKE; |
|
335 | - } |
|
336 | - } |
|
337 | - |
|
338 | - return $this->addUsingAlias(UserTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Filter the query on the name column |
|
343 | - * |
|
344 | - * Example usage: |
|
345 | - * <code> |
|
346 | - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
|
347 | - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
|
348 | - * </code> |
|
349 | - * |
|
350 | - * @param string $name The value to use as filter. |
|
351 | - * Accepts wildcards (* and % trigger a LIKE) |
|
352 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
353 | - * |
|
354 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
355 | - */ |
|
356 | - public function filterByName($name = null, $comparison = null) |
|
357 | - { |
|
358 | - if (null === $comparison) { |
|
359 | - if (is_array($name)) { |
|
360 | - $comparison = Criteria::IN; |
|
361 | - } elseif (preg_match('/[\%\*]/', $name)) { |
|
362 | - $name = str_replace('*', '%', $name); |
|
363 | - $comparison = Criteria::LIKE; |
|
364 | - } |
|
365 | - } |
|
366 | - |
|
367 | - return $this->addUsingAlias(UserTableMap::COL_NAME, $name, $comparison); |
|
368 | - } |
|
369 | - |
|
370 | - /** |
|
371 | - * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
372 | - * |
|
373 | - * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
374 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
375 | - * |
|
376 | - * @throws \Propel\Runtime\Exception\PropelException |
|
377 | - * |
|
378 | - * @return ChildUserQuery The current query, for fluid interface |
|
379 | - */ |
|
380 | - public function filterByInstance($instance, $comparison = null) |
|
381 | - { |
|
382 | - if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
383 | - return $this |
|
384 | - ->addUsingAlias(UserTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
385 | - } elseif ($instance instanceof ObjectCollection) { |
|
386 | - if (null === $comparison) { |
|
387 | - $comparison = Criteria::IN; |
|
388 | - } |
|
389 | - |
|
390 | - return $this |
|
391 | - ->addUsingAlias(UserTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
392 | - } else { |
|
393 | - throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
394 | - } |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Adds a JOIN clause to the query using the Instance relation |
|
399 | - * |
|
400 | - * @param string $relationAlias optional alias for the relation |
|
401 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
402 | - * |
|
403 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
404 | - */ |
|
405 | - public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
406 | - { |
|
407 | - $tableMap = $this->getTableMap(); |
|
408 | - $relationMap = $tableMap->getRelation('Instance'); |
|
409 | - |
|
410 | - // create a ModelJoin object for this join |
|
411 | - $join = new ModelJoin(); |
|
412 | - $join->setJoinType($joinType); |
|
413 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
414 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
415 | - $join->setPreviousJoin($previousJoin); |
|
416 | - } |
|
417 | - |
|
418 | - // add the ModelJoin to the current object |
|
419 | - if ($relationAlias) { |
|
420 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
421 | - $this->addJoinObject($join, $relationAlias); |
|
422 | - } else { |
|
423 | - $this->addJoinObject($join, 'Instance'); |
|
424 | - } |
|
425 | - |
|
426 | - return $this; |
|
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Use the Instance relation Instance object |
|
431 | - * |
|
432 | - * @see useQuery() |
|
433 | - * |
|
434 | - * @param string $relationAlias optional alias for the relation, |
|
435 | - * to be used as main alias in the secondary query |
|
436 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
437 | - * |
|
438 | - * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
439 | - */ |
|
440 | - public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
441 | - { |
|
442 | - return $this |
|
443 | - ->joinInstance($relationAlias, $joinType) |
|
444 | - ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
445 | - } |
|
446 | - |
|
447 | - /** |
|
448 | - * Filter the query by a related \Jalle19\StatusManager\Database\Connection object |
|
449 | - * |
|
450 | - * @param \Jalle19\StatusManager\Database\Connection|ObjectCollection $connection the related object to use as filter |
|
451 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
452 | - * |
|
453 | - * @return ChildUserQuery The current query, for fluid interface |
|
454 | - */ |
|
455 | - public function filterByConnection($connection, $comparison = null) |
|
456 | - { |
|
457 | - if ($connection instanceof \Jalle19\StatusManager\Database\Connection) { |
|
458 | - return $this |
|
459 | - ->addUsingAlias(UserTableMap::COL_ID, $connection->getUserId(), $comparison); |
|
460 | - } elseif ($connection instanceof ObjectCollection) { |
|
461 | - return $this |
|
462 | - ->useConnectionQuery() |
|
463 | - ->filterByPrimaryKeys($connection->getPrimaryKeys()) |
|
464 | - ->endUse(); |
|
465 | - } else { |
|
466 | - throw new PropelException('filterByConnection() only accepts arguments of type \Jalle19\StatusManager\Database\Connection or Collection'); |
|
467 | - } |
|
468 | - } |
|
469 | - |
|
470 | - /** |
|
471 | - * Adds a JOIN clause to the query using the Connection relation |
|
472 | - * |
|
473 | - * @param string $relationAlias optional alias for the relation |
|
474 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
475 | - * |
|
476 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
477 | - */ |
|
478 | - public function joinConnection($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
479 | - { |
|
480 | - $tableMap = $this->getTableMap(); |
|
481 | - $relationMap = $tableMap->getRelation('Connection'); |
|
482 | - |
|
483 | - // create a ModelJoin object for this join |
|
484 | - $join = new ModelJoin(); |
|
485 | - $join->setJoinType($joinType); |
|
486 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
487 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
488 | - $join->setPreviousJoin($previousJoin); |
|
489 | - } |
|
490 | - |
|
491 | - // add the ModelJoin to the current object |
|
492 | - if ($relationAlias) { |
|
493 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
494 | - $this->addJoinObject($join, $relationAlias); |
|
495 | - } else { |
|
496 | - $this->addJoinObject($join, 'Connection'); |
|
497 | - } |
|
498 | - |
|
499 | - return $this; |
|
500 | - } |
|
501 | - |
|
502 | - /** |
|
503 | - * Use the Connection relation Connection object |
|
504 | - * |
|
505 | - * @see useQuery() |
|
506 | - * |
|
507 | - * @param string $relationAlias optional alias for the relation, |
|
508 | - * to be used as main alias in the secondary query |
|
509 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
510 | - * |
|
511 | - * @return \Jalle19\StatusManager\Database\ConnectionQuery A secondary query class using the current class as primary query |
|
512 | - */ |
|
513 | - public function useConnectionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
514 | - { |
|
515 | - return $this |
|
516 | - ->joinConnection($relationAlias, $joinType) |
|
517 | - ->useQuery($relationAlias ? $relationAlias : 'Connection', '\Jalle19\StatusManager\Database\ConnectionQuery'); |
|
518 | - } |
|
519 | - |
|
520 | - /** |
|
521 | - * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
522 | - * |
|
523 | - * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
524 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
525 | - * |
|
526 | - * @return ChildUserQuery The current query, for fluid interface |
|
527 | - */ |
|
528 | - public function filterBySubscription($subscription, $comparison = null) |
|
529 | - { |
|
530 | - if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
531 | - return $this |
|
532 | - ->addUsingAlias(UserTableMap::COL_ID, $subscription->getUserId(), $comparison); |
|
533 | - } elseif ($subscription instanceof ObjectCollection) { |
|
534 | - return $this |
|
535 | - ->useSubscriptionQuery() |
|
536 | - ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
537 | - ->endUse(); |
|
538 | - } else { |
|
539 | - throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
540 | - } |
|
541 | - } |
|
542 | - |
|
543 | - /** |
|
544 | - * Adds a JOIN clause to the query using the Subscription relation |
|
545 | - * |
|
546 | - * @param string $relationAlias optional alias for the relation |
|
547 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
548 | - * |
|
549 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
550 | - */ |
|
551 | - public function joinSubscription($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
552 | - { |
|
553 | - $tableMap = $this->getTableMap(); |
|
554 | - $relationMap = $tableMap->getRelation('Subscription'); |
|
555 | - |
|
556 | - // create a ModelJoin object for this join |
|
557 | - $join = new ModelJoin(); |
|
558 | - $join->setJoinType($joinType); |
|
559 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
560 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
561 | - $join->setPreviousJoin($previousJoin); |
|
562 | - } |
|
563 | - |
|
564 | - // add the ModelJoin to the current object |
|
565 | - if ($relationAlias) { |
|
566 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
567 | - $this->addJoinObject($join, $relationAlias); |
|
568 | - } else { |
|
569 | - $this->addJoinObject($join, 'Subscription'); |
|
570 | - } |
|
571 | - |
|
572 | - return $this; |
|
573 | - } |
|
574 | - |
|
575 | - /** |
|
576 | - * Use the Subscription relation Subscription object |
|
577 | - * |
|
578 | - * @see useQuery() |
|
579 | - * |
|
580 | - * @param string $relationAlias optional alias for the relation, |
|
581 | - * to be used as main alias in the secondary query |
|
582 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
583 | - * |
|
584 | - * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
585 | - */ |
|
586 | - public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
587 | - { |
|
588 | - return $this |
|
589 | - ->joinSubscription($relationAlias, $joinType) |
|
590 | - ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
591 | - } |
|
592 | - |
|
593 | - /** |
|
594 | - * Exclude object from result |
|
595 | - * |
|
596 | - * @param ChildUser $user Object to remove from the list of results |
|
597 | - * |
|
598 | - * @return $this|ChildUserQuery The current query, for fluid interface |
|
599 | - */ |
|
600 | - public function prune($user = null) |
|
601 | - { |
|
602 | - if ($user) { |
|
603 | - $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL); |
|
604 | - } |
|
605 | - |
|
606 | - return $this; |
|
607 | - } |
|
608 | - |
|
609 | - /** |
|
610 | - * Deletes all rows from the user table. |
|
611 | - * |
|
612 | - * @param ConnectionInterface $con the connection to use |
|
613 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
614 | - */ |
|
615 | - public function doDeleteAll(ConnectionInterface $con = null) |
|
616 | - { |
|
617 | - if (null === $con) { |
|
618 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
619 | - } |
|
620 | - |
|
621 | - // use transaction because $criteria could contain info |
|
622 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
623 | - return $con->transaction(function () use ($con) { |
|
624 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
625 | - $affectedRows += parent::doDeleteAll($con); |
|
626 | - // Because this db requires some delete cascade/set null emulation, we have to |
|
627 | - // clear the cached instance *after* the emulation has happened (since |
|
628 | - // instances get re-added by the select statement contained therein). |
|
629 | - UserTableMap::clearInstancePool(); |
|
630 | - UserTableMap::clearRelatedInstancePool(); |
|
631 | - |
|
632 | - return $affectedRows; |
|
633 | - }); |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * Performs a DELETE on the database based on the current ModelCriteria |
|
638 | - * |
|
639 | - * @param ConnectionInterface $con the connection to use |
|
640 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
641 | - * if supported by native driver or if emulated using Propel. |
|
642 | - * @throws PropelException Any exceptions caught during processing will be |
|
643 | - * rethrown wrapped into a PropelException. |
|
644 | - */ |
|
645 | - public function delete(ConnectionInterface $con = null) |
|
646 | - { |
|
647 | - if (null === $con) { |
|
648 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
649 | - } |
|
650 | - |
|
651 | - $criteria = $this; |
|
652 | - |
|
653 | - // Set the correct dbName |
|
654 | - $criteria->setDbName(UserTableMap::DATABASE_NAME); |
|
655 | - |
|
656 | - // use transaction because $criteria could contain info |
|
657 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
658 | - return $con->transaction(function () use ($con, $criteria) { |
|
659 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
660 | - |
|
661 | - UserTableMap::removeInstanceFromPool($criteria); |
|
662 | - |
|
663 | - $affectedRows += ModelCriteria::delete($con); |
|
664 | - UserTableMap::clearRelatedInstancePool(); |
|
665 | - |
|
666 | - return $affectedRows; |
|
667 | - }); |
|
668 | - } |
|
93 | + protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
94 | + |
|
95 | + /** |
|
96 | + * Initializes internal state of \Jalle19\StatusManager\Database\Base\UserQuery object. |
|
97 | + * |
|
98 | + * @param string $dbName The database name |
|
99 | + * @param string $modelName The phpName of a model, e.g. 'Book' |
|
100 | + * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
101 | + */ |
|
102 | + public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\User', $modelAlias = null) |
|
103 | + { |
|
104 | + parent::__construct($dbName, $modelName, $modelAlias); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Returns a new ChildUserQuery object. |
|
109 | + * |
|
110 | + * @param string $modelAlias The alias of a model in the query |
|
111 | + * @param Criteria $criteria Optional Criteria to build the query from |
|
112 | + * |
|
113 | + * @return ChildUserQuery |
|
114 | + */ |
|
115 | + public static function create($modelAlias = null, Criteria $criteria = null) |
|
116 | + { |
|
117 | + if ($criteria instanceof ChildUserQuery) { |
|
118 | + return $criteria; |
|
119 | + } |
|
120 | + $query = new ChildUserQuery(); |
|
121 | + if (null !== $modelAlias) { |
|
122 | + $query->setModelAlias($modelAlias); |
|
123 | + } |
|
124 | + if ($criteria instanceof Criteria) { |
|
125 | + $query->mergeWith($criteria); |
|
126 | + } |
|
127 | + |
|
128 | + return $query; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Find object by primary key. |
|
133 | + * Propel uses the instance pool to skip the database if the object exists. |
|
134 | + * Go fast if the query is untouched. |
|
135 | + * |
|
136 | + * <code> |
|
137 | + * $obj = $c->findPk(12, $con); |
|
138 | + * </code> |
|
139 | + * |
|
140 | + * @param mixed $key Primary key to use for the query |
|
141 | + * @param ConnectionInterface $con an optional connection object |
|
142 | + * |
|
143 | + * @return ChildUser|array|mixed the result, formatted by the current formatter |
|
144 | + */ |
|
145 | + public function findPk($key, ConnectionInterface $con = null) |
|
146 | + { |
|
147 | + if ($key === null) { |
|
148 | + return null; |
|
149 | + } |
|
150 | + if ((null !== ($obj = UserTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
151 | + // the object is already in the instance pool |
|
152 | + return $obj; |
|
153 | + } |
|
154 | + if ($con === null) { |
|
155 | + $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME); |
|
156 | + } |
|
157 | + $this->basePreSelect($con); |
|
158 | + if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
159 | + || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
160 | + || $this->map || $this->having || $this->joins) { |
|
161 | + return $this->findPkComplex($key, $con); |
|
162 | + } else { |
|
163 | + return $this->findPkSimple($key, $con); |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * Find object by primary key using raw SQL to go fast. |
|
169 | + * Bypass doSelect() and the object formatter by using generated code. |
|
170 | + * |
|
171 | + * @param mixed $key Primary key to use for the query |
|
172 | + * @param ConnectionInterface $con A connection object |
|
173 | + * |
|
174 | + * @throws \Propel\Runtime\Exception\PropelException |
|
175 | + * |
|
176 | + * @return ChildUser A model object, or null if the key is not found |
|
177 | + */ |
|
178 | + protected function findPkSimple($key, ConnectionInterface $con) |
|
179 | + { |
|
180 | + $sql = 'SELECT id, instance_name, name FROM user WHERE id = :p0'; |
|
181 | + try { |
|
182 | + $stmt = $con->prepare($sql); |
|
183 | + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
184 | + $stmt->execute(); |
|
185 | + } catch (Exception $e) { |
|
186 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
187 | + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
188 | + } |
|
189 | + $obj = null; |
|
190 | + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
191 | + /** @var ChildUser $obj */ |
|
192 | + $obj = new ChildUser(); |
|
193 | + $obj->hydrate($row); |
|
194 | + UserTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
195 | + } |
|
196 | + $stmt->closeCursor(); |
|
197 | + |
|
198 | + return $obj; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Find object by primary key. |
|
203 | + * |
|
204 | + * @param mixed $key Primary key to use for the query |
|
205 | + * @param ConnectionInterface $con A connection object |
|
206 | + * |
|
207 | + * @return ChildUser|array|mixed the result, formatted by the current formatter |
|
208 | + */ |
|
209 | + protected function findPkComplex($key, ConnectionInterface $con) |
|
210 | + { |
|
211 | + // As the query uses a PK condition, no limit(1) is necessary. |
|
212 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
213 | + $dataFetcher = $criteria |
|
214 | + ->filterByPrimaryKey($key) |
|
215 | + ->doSelect($con); |
|
216 | + |
|
217 | + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
218 | + } |
|
219 | + |
|
220 | + /** |
|
221 | + * Find objects by primary key |
|
222 | + * <code> |
|
223 | + * $objs = $c->findPks(array(12, 56, 832), $con); |
|
224 | + * </code> |
|
225 | + * @param array $keys Primary keys to use for the query |
|
226 | + * @param ConnectionInterface $con an optional connection object |
|
227 | + * |
|
228 | + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
229 | + */ |
|
230 | + public function findPks($keys, ConnectionInterface $con = null) |
|
231 | + { |
|
232 | + if (null === $con) { |
|
233 | + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
234 | + } |
|
235 | + $this->basePreSelect($con); |
|
236 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
237 | + $dataFetcher = $criteria |
|
238 | + ->filterByPrimaryKeys($keys) |
|
239 | + ->doSelect($con); |
|
240 | + |
|
241 | + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * Filter the query by primary key |
|
246 | + * |
|
247 | + * @param mixed $key Primary key to use for the query |
|
248 | + * |
|
249 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
250 | + */ |
|
251 | + public function filterByPrimaryKey($key) |
|
252 | + { |
|
253 | + |
|
254 | + return $this->addUsingAlias(UserTableMap::COL_ID, $key, Criteria::EQUAL); |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Filter the query by a list of primary keys |
|
259 | + * |
|
260 | + * @param array $keys The list of primary key to use for the query |
|
261 | + * |
|
262 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
263 | + */ |
|
264 | + public function filterByPrimaryKeys($keys) |
|
265 | + { |
|
266 | + |
|
267 | + return $this->addUsingAlias(UserTableMap::COL_ID, $keys, Criteria::IN); |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Filter the query on the id column |
|
272 | + * |
|
273 | + * Example usage: |
|
274 | + * <code> |
|
275 | + * $query->filterById(1234); // WHERE id = 1234 |
|
276 | + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
277 | + * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
278 | + * </code> |
|
279 | + * |
|
280 | + * @param mixed $id The value to use as filter. |
|
281 | + * Use scalar values for equality. |
|
282 | + * Use array values for in_array() equivalent. |
|
283 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
284 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
285 | + * |
|
286 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
287 | + */ |
|
288 | + public function filterById($id = null, $comparison = null) |
|
289 | + { |
|
290 | + if (is_array($id)) { |
|
291 | + $useMinMax = false; |
|
292 | + if (isset($id['min'])) { |
|
293 | + $this->addUsingAlias(UserTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
294 | + $useMinMax = true; |
|
295 | + } |
|
296 | + if (isset($id['max'])) { |
|
297 | + $this->addUsingAlias(UserTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
298 | + $useMinMax = true; |
|
299 | + } |
|
300 | + if ($useMinMax) { |
|
301 | + return $this; |
|
302 | + } |
|
303 | + if (null === $comparison) { |
|
304 | + $comparison = Criteria::IN; |
|
305 | + } |
|
306 | + } |
|
307 | + |
|
308 | + return $this->addUsingAlias(UserTableMap::COL_ID, $id, $comparison); |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * Filter the query on the instance_name column |
|
313 | + * |
|
314 | + * Example usage: |
|
315 | + * <code> |
|
316 | + * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
317 | + * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
318 | + * </code> |
|
319 | + * |
|
320 | + * @param string $instanceName The value to use as filter. |
|
321 | + * Accepts wildcards (* and % trigger a LIKE) |
|
322 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
323 | + * |
|
324 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
325 | + */ |
|
326 | + public function filterByInstanceName($instanceName = null, $comparison = null) |
|
327 | + { |
|
328 | + if (null === $comparison) { |
|
329 | + if (is_array($instanceName)) { |
|
330 | + $comparison = Criteria::IN; |
|
331 | + } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
332 | + $instanceName = str_replace('*', '%', $instanceName); |
|
333 | + $comparison = Criteria::LIKE; |
|
334 | + } |
|
335 | + } |
|
336 | + |
|
337 | + return $this->addUsingAlias(UserTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Filter the query on the name column |
|
342 | + * |
|
343 | + * Example usage: |
|
344 | + * <code> |
|
345 | + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
|
346 | + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
|
347 | + * </code> |
|
348 | + * |
|
349 | + * @param string $name The value to use as filter. |
|
350 | + * Accepts wildcards (* and % trigger a LIKE) |
|
351 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
352 | + * |
|
353 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
354 | + */ |
|
355 | + public function filterByName($name = null, $comparison = null) |
|
356 | + { |
|
357 | + if (null === $comparison) { |
|
358 | + if (is_array($name)) { |
|
359 | + $comparison = Criteria::IN; |
|
360 | + } elseif (preg_match('/[\%\*]/', $name)) { |
|
361 | + $name = str_replace('*', '%', $name); |
|
362 | + $comparison = Criteria::LIKE; |
|
363 | + } |
|
364 | + } |
|
365 | + |
|
366 | + return $this->addUsingAlias(UserTableMap::COL_NAME, $name, $comparison); |
|
367 | + } |
|
368 | + |
|
369 | + /** |
|
370 | + * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
371 | + * |
|
372 | + * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
373 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
374 | + * |
|
375 | + * @throws \Propel\Runtime\Exception\PropelException |
|
376 | + * |
|
377 | + * @return ChildUserQuery The current query, for fluid interface |
|
378 | + */ |
|
379 | + public function filterByInstance($instance, $comparison = null) |
|
380 | + { |
|
381 | + if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
382 | + return $this |
|
383 | + ->addUsingAlias(UserTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
384 | + } elseif ($instance instanceof ObjectCollection) { |
|
385 | + if (null === $comparison) { |
|
386 | + $comparison = Criteria::IN; |
|
387 | + } |
|
388 | + |
|
389 | + return $this |
|
390 | + ->addUsingAlias(UserTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
391 | + } else { |
|
392 | + throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
393 | + } |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Adds a JOIN clause to the query using the Instance relation |
|
398 | + * |
|
399 | + * @param string $relationAlias optional alias for the relation |
|
400 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
401 | + * |
|
402 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
403 | + */ |
|
404 | + public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
405 | + { |
|
406 | + $tableMap = $this->getTableMap(); |
|
407 | + $relationMap = $tableMap->getRelation('Instance'); |
|
408 | + |
|
409 | + // create a ModelJoin object for this join |
|
410 | + $join = new ModelJoin(); |
|
411 | + $join->setJoinType($joinType); |
|
412 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
413 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
414 | + $join->setPreviousJoin($previousJoin); |
|
415 | + } |
|
416 | + |
|
417 | + // add the ModelJoin to the current object |
|
418 | + if ($relationAlias) { |
|
419 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
420 | + $this->addJoinObject($join, $relationAlias); |
|
421 | + } else { |
|
422 | + $this->addJoinObject($join, 'Instance'); |
|
423 | + } |
|
424 | + |
|
425 | + return $this; |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * Use the Instance relation Instance object |
|
430 | + * |
|
431 | + * @see useQuery() |
|
432 | + * |
|
433 | + * @param string $relationAlias optional alias for the relation, |
|
434 | + * to be used as main alias in the secondary query |
|
435 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
436 | + * |
|
437 | + * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
438 | + */ |
|
439 | + public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
440 | + { |
|
441 | + return $this |
|
442 | + ->joinInstance($relationAlias, $joinType) |
|
443 | + ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
444 | + } |
|
445 | + |
|
446 | + /** |
|
447 | + * Filter the query by a related \Jalle19\StatusManager\Database\Connection object |
|
448 | + * |
|
449 | + * @param \Jalle19\StatusManager\Database\Connection|ObjectCollection $connection the related object to use as filter |
|
450 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
451 | + * |
|
452 | + * @return ChildUserQuery The current query, for fluid interface |
|
453 | + */ |
|
454 | + public function filterByConnection($connection, $comparison = null) |
|
455 | + { |
|
456 | + if ($connection instanceof \Jalle19\StatusManager\Database\Connection) { |
|
457 | + return $this |
|
458 | + ->addUsingAlias(UserTableMap::COL_ID, $connection->getUserId(), $comparison); |
|
459 | + } elseif ($connection instanceof ObjectCollection) { |
|
460 | + return $this |
|
461 | + ->useConnectionQuery() |
|
462 | + ->filterByPrimaryKeys($connection->getPrimaryKeys()) |
|
463 | + ->endUse(); |
|
464 | + } else { |
|
465 | + throw new PropelException('filterByConnection() only accepts arguments of type \Jalle19\StatusManager\Database\Connection or Collection'); |
|
466 | + } |
|
467 | + } |
|
468 | + |
|
469 | + /** |
|
470 | + * Adds a JOIN clause to the query using the Connection relation |
|
471 | + * |
|
472 | + * @param string $relationAlias optional alias for the relation |
|
473 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
474 | + * |
|
475 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
476 | + */ |
|
477 | + public function joinConnection($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
478 | + { |
|
479 | + $tableMap = $this->getTableMap(); |
|
480 | + $relationMap = $tableMap->getRelation('Connection'); |
|
481 | + |
|
482 | + // create a ModelJoin object for this join |
|
483 | + $join = new ModelJoin(); |
|
484 | + $join->setJoinType($joinType); |
|
485 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
486 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
487 | + $join->setPreviousJoin($previousJoin); |
|
488 | + } |
|
489 | + |
|
490 | + // add the ModelJoin to the current object |
|
491 | + if ($relationAlias) { |
|
492 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
493 | + $this->addJoinObject($join, $relationAlias); |
|
494 | + } else { |
|
495 | + $this->addJoinObject($join, 'Connection'); |
|
496 | + } |
|
497 | + |
|
498 | + return $this; |
|
499 | + } |
|
500 | + |
|
501 | + /** |
|
502 | + * Use the Connection relation Connection object |
|
503 | + * |
|
504 | + * @see useQuery() |
|
505 | + * |
|
506 | + * @param string $relationAlias optional alias for the relation, |
|
507 | + * to be used as main alias in the secondary query |
|
508 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
509 | + * |
|
510 | + * @return \Jalle19\StatusManager\Database\ConnectionQuery A secondary query class using the current class as primary query |
|
511 | + */ |
|
512 | + public function useConnectionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
513 | + { |
|
514 | + return $this |
|
515 | + ->joinConnection($relationAlias, $joinType) |
|
516 | + ->useQuery($relationAlias ? $relationAlias : 'Connection', '\Jalle19\StatusManager\Database\ConnectionQuery'); |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
521 | + * |
|
522 | + * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
523 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
524 | + * |
|
525 | + * @return ChildUserQuery The current query, for fluid interface |
|
526 | + */ |
|
527 | + public function filterBySubscription($subscription, $comparison = null) |
|
528 | + { |
|
529 | + if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
530 | + return $this |
|
531 | + ->addUsingAlias(UserTableMap::COL_ID, $subscription->getUserId(), $comparison); |
|
532 | + } elseif ($subscription instanceof ObjectCollection) { |
|
533 | + return $this |
|
534 | + ->useSubscriptionQuery() |
|
535 | + ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
536 | + ->endUse(); |
|
537 | + } else { |
|
538 | + throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
539 | + } |
|
540 | + } |
|
541 | + |
|
542 | + /** |
|
543 | + * Adds a JOIN clause to the query using the Subscription relation |
|
544 | + * |
|
545 | + * @param string $relationAlias optional alias for the relation |
|
546 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
547 | + * |
|
548 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
549 | + */ |
|
550 | + public function joinSubscription($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
551 | + { |
|
552 | + $tableMap = $this->getTableMap(); |
|
553 | + $relationMap = $tableMap->getRelation('Subscription'); |
|
554 | + |
|
555 | + // create a ModelJoin object for this join |
|
556 | + $join = new ModelJoin(); |
|
557 | + $join->setJoinType($joinType); |
|
558 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
559 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
560 | + $join->setPreviousJoin($previousJoin); |
|
561 | + } |
|
562 | + |
|
563 | + // add the ModelJoin to the current object |
|
564 | + if ($relationAlias) { |
|
565 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
566 | + $this->addJoinObject($join, $relationAlias); |
|
567 | + } else { |
|
568 | + $this->addJoinObject($join, 'Subscription'); |
|
569 | + } |
|
570 | + |
|
571 | + return $this; |
|
572 | + } |
|
573 | + |
|
574 | + /** |
|
575 | + * Use the Subscription relation Subscription object |
|
576 | + * |
|
577 | + * @see useQuery() |
|
578 | + * |
|
579 | + * @param string $relationAlias optional alias for the relation, |
|
580 | + * to be used as main alias in the secondary query |
|
581 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
582 | + * |
|
583 | + * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
584 | + */ |
|
585 | + public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
586 | + { |
|
587 | + return $this |
|
588 | + ->joinSubscription($relationAlias, $joinType) |
|
589 | + ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
590 | + } |
|
591 | + |
|
592 | + /** |
|
593 | + * Exclude object from result |
|
594 | + * |
|
595 | + * @param ChildUser $user Object to remove from the list of results |
|
596 | + * |
|
597 | + * @return $this|ChildUserQuery The current query, for fluid interface |
|
598 | + */ |
|
599 | + public function prune($user = null) |
|
600 | + { |
|
601 | + if ($user) { |
|
602 | + $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL); |
|
603 | + } |
|
604 | + |
|
605 | + return $this; |
|
606 | + } |
|
607 | + |
|
608 | + /** |
|
609 | + * Deletes all rows from the user table. |
|
610 | + * |
|
611 | + * @param ConnectionInterface $con the connection to use |
|
612 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
613 | + */ |
|
614 | + public function doDeleteAll(ConnectionInterface $con = null) |
|
615 | + { |
|
616 | + if (null === $con) { |
|
617 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
618 | + } |
|
619 | + |
|
620 | + // use transaction because $criteria could contain info |
|
621 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
622 | + return $con->transaction(function () use ($con) { |
|
623 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
624 | + $affectedRows += parent::doDeleteAll($con); |
|
625 | + // Because this db requires some delete cascade/set null emulation, we have to |
|
626 | + // clear the cached instance *after* the emulation has happened (since |
|
627 | + // instances get re-added by the select statement contained therein). |
|
628 | + UserTableMap::clearInstancePool(); |
|
629 | + UserTableMap::clearRelatedInstancePool(); |
|
630 | + |
|
631 | + return $affectedRows; |
|
632 | + }); |
|
633 | + } |
|
634 | + |
|
635 | + /** |
|
636 | + * Performs a DELETE on the database based on the current ModelCriteria |
|
637 | + * |
|
638 | + * @param ConnectionInterface $con the connection to use |
|
639 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
640 | + * if supported by native driver or if emulated using Propel. |
|
641 | + * @throws PropelException Any exceptions caught during processing will be |
|
642 | + * rethrown wrapped into a PropelException. |
|
643 | + */ |
|
644 | + public function delete(ConnectionInterface $con = null) |
|
645 | + { |
|
646 | + if (null === $con) { |
|
647 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
648 | + } |
|
649 | + |
|
650 | + $criteria = $this; |
|
651 | + |
|
652 | + // Set the correct dbName |
|
653 | + $criteria->setDbName(UserTableMap::DATABASE_NAME); |
|
654 | + |
|
655 | + // use transaction because $criteria could contain info |
|
656 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
657 | + return $con->transaction(function () use ($con, $criteria) { |
|
658 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
659 | + |
|
660 | + UserTableMap::removeInstanceFromPool($criteria); |
|
661 | + |
|
662 | + $affectedRows += ModelCriteria::delete($con); |
|
663 | + UserTableMap::clearRelatedInstancePool(); |
|
664 | + |
|
665 | + return $affectedRows; |
|
666 | + }); |
|
667 | + } |
|
669 | 668 | |
670 | 669 | } // UserQuery |
@@ -28,401 +28,401 @@ |
||
28 | 28 | */ |
29 | 29 | class ChannelTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ChannelTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'channel'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Channel'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Channel'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 3; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 3; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'channel.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'channel.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the name field |
|
86 | - */ |
|
87 | - const COL_NAME = 'channel.name'; |
|
88 | - |
|
89 | - /** |
|
90 | - * The default string format for model objects of the related table |
|
91 | - */ |
|
92 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | - |
|
94 | - /** |
|
95 | - * holds an array of fieldnames |
|
96 | - * |
|
97 | - * first dimension keys are the type constants |
|
98 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | - */ |
|
100 | - protected static $fieldNames = array ( |
|
101 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | - self::TYPE_COLNAME => array(ChannelTableMap::COL_ID, ChannelTableMap::COL_INSTANCE_NAME, ChannelTableMap::COL_NAME, ), |
|
104 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | - ); |
|
107 | - |
|
108 | - /** |
|
109 | - * holds an array of keys for quick access to the fieldnames array |
|
110 | - * |
|
111 | - * first dimension keys are the type constants |
|
112 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | - */ |
|
114 | - protected static $fieldKeys = array ( |
|
115 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | - self::TYPE_COLNAME => array(ChannelTableMap::COL_ID => 0, ChannelTableMap::COL_INSTANCE_NAME => 1, ChannelTableMap::COL_NAME => 2, ), |
|
118 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | - ); |
|
121 | - |
|
122 | - /** |
|
123 | - * Initialize the table attributes and columns |
|
124 | - * Relations are not initialized by this method since they are lazy loaded |
|
125 | - * |
|
126 | - * @return void |
|
127 | - * @throws PropelException |
|
128 | - */ |
|
129 | - public function initialize() |
|
130 | - { |
|
131 | - // attributes |
|
132 | - $this->setName('channel'); |
|
133 | - $this->setPhpName('Channel'); |
|
134 | - $this->setIdentifierQuoting(false); |
|
135 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\Channel'); |
|
136 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | - $this->setUseIdGenerator(true); |
|
138 | - // columns |
|
139 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | - $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | - } // initialize() |
|
143 | - |
|
144 | - /** |
|
145 | - * Build the RelationMap objects for this table relationships |
|
146 | - */ |
|
147 | - public function buildRelations() |
|
148 | - { |
|
149 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ChannelTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'channel'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Channel'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Channel'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 3; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 3; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'channel.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'channel.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the name field |
|
86 | + */ |
|
87 | + const COL_NAME = 'channel.name'; |
|
88 | + |
|
89 | + /** |
|
90 | + * The default string format for model objects of the related table |
|
91 | + */ |
|
92 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | + |
|
94 | + /** |
|
95 | + * holds an array of fieldnames |
|
96 | + * |
|
97 | + * first dimension keys are the type constants |
|
98 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | + */ |
|
100 | + protected static $fieldNames = array ( |
|
101 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | + self::TYPE_COLNAME => array(ChannelTableMap::COL_ID, ChannelTableMap::COL_INSTANCE_NAME, ChannelTableMap::COL_NAME, ), |
|
104 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | + ); |
|
107 | + |
|
108 | + /** |
|
109 | + * holds an array of keys for quick access to the fieldnames array |
|
110 | + * |
|
111 | + * first dimension keys are the type constants |
|
112 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | + */ |
|
114 | + protected static $fieldKeys = array ( |
|
115 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | + self::TYPE_COLNAME => array(ChannelTableMap::COL_ID => 0, ChannelTableMap::COL_INSTANCE_NAME => 1, ChannelTableMap::COL_NAME => 2, ), |
|
118 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | + ); |
|
121 | + |
|
122 | + /** |
|
123 | + * Initialize the table attributes and columns |
|
124 | + * Relations are not initialized by this method since they are lazy loaded |
|
125 | + * |
|
126 | + * @return void |
|
127 | + * @throws PropelException |
|
128 | + */ |
|
129 | + public function initialize() |
|
130 | + { |
|
131 | + // attributes |
|
132 | + $this->setName('channel'); |
|
133 | + $this->setPhpName('Channel'); |
|
134 | + $this->setIdentifierQuoting(false); |
|
135 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\Channel'); |
|
136 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | + $this->setUseIdGenerator(true); |
|
138 | + // columns |
|
139 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | + $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | + } // initialize() |
|
143 | + |
|
144 | + /** |
|
145 | + * Build the RelationMap objects for this table relationships |
|
146 | + */ |
|
147 | + public function buildRelations() |
|
148 | + { |
|
149 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
150 | 150 | 0 => |
151 | 151 | array ( |
152 | - 0 => ':instance_name', |
|
153 | - 1 => ':name', |
|
152 | + 0 => ':instance_name', |
|
153 | + 1 => ':name', |
|
154 | 154 | ), |
155 | 155 | ), null, null, null, false); |
156 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
156 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
157 | 157 | 0 => |
158 | 158 | array ( |
159 | - 0 => ':channel_id', |
|
160 | - 1 => ':id', |
|
159 | + 0 => ':channel_id', |
|
160 | + 1 => ':id', |
|
161 | 161 | ), |
162 | 162 | ), null, null, 'Subscriptions', false); |
163 | - } // buildRelations() |
|
164 | - |
|
165 | - /** |
|
166 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
167 | - * |
|
168 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
169 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
170 | - * |
|
171 | - * @param array $row resultset row. |
|
172 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
173 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
174 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
175 | - * |
|
176 | - * @return string The primary key hash of the row |
|
177 | - */ |
|
178 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
179 | - { |
|
180 | - // If the PK cannot be derived from the row, return NULL. |
|
181 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
182 | - return null; |
|
183 | - } |
|
184 | - |
|
185 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Retrieves the primary key from the DB resultset row |
|
190 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
191 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
192 | - * |
|
193 | - * @param array $row resultset row. |
|
194 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
195 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
196 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
197 | - * |
|
198 | - * @return mixed The primary key of the row |
|
199 | - */ |
|
200 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
201 | - { |
|
202 | - return (int) $row[ |
|
203 | - $indexType == TableMap::TYPE_NUM |
|
204 | - ? 0 + $offset |
|
205 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
206 | - ]; |
|
207 | - } |
|
208 | - |
|
209 | - /** |
|
210 | - * The class that the tableMap will make instances of. |
|
211 | - * |
|
212 | - * If $withPrefix is true, the returned path |
|
213 | - * uses a dot-path notation which is translated into a path |
|
214 | - * relative to a location on the PHP include_path. |
|
215 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
216 | - * |
|
217 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
218 | - * @return string path.to.ClassName |
|
219 | - */ |
|
220 | - public static function getOMClass($withPrefix = true) |
|
221 | - { |
|
222 | - return $withPrefix ? ChannelTableMap::CLASS_DEFAULT : ChannelTableMap::OM_CLASS; |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Populates an object of the default type or an object that inherit from the default. |
|
227 | - * |
|
228 | - * @param array $row row returned by DataFetcher->fetch(). |
|
229 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
230 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
163 | + } // buildRelations() |
|
164 | + |
|
165 | + /** |
|
166 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
167 | + * |
|
168 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
169 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
170 | + * |
|
171 | + * @param array $row resultset row. |
|
172 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
173 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
174 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
175 | + * |
|
176 | + * @return string The primary key hash of the row |
|
177 | + */ |
|
178 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
179 | + { |
|
180 | + // If the PK cannot be derived from the row, return NULL. |
|
181 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
182 | + return null; |
|
183 | + } |
|
184 | + |
|
185 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Retrieves the primary key from the DB resultset row |
|
190 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
191 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
192 | + * |
|
193 | + * @param array $row resultset row. |
|
194 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
195 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
196 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
197 | + * |
|
198 | + * @return mixed The primary key of the row |
|
199 | + */ |
|
200 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
201 | + { |
|
202 | + return (int) $row[ |
|
203 | + $indexType == TableMap::TYPE_NUM |
|
204 | + ? 0 + $offset |
|
205 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
206 | + ]; |
|
207 | + } |
|
208 | + |
|
209 | + /** |
|
210 | + * The class that the tableMap will make instances of. |
|
211 | + * |
|
212 | + * If $withPrefix is true, the returned path |
|
213 | + * uses a dot-path notation which is translated into a path |
|
214 | + * relative to a location on the PHP include_path. |
|
215 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
216 | + * |
|
217 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
218 | + * @return string path.to.ClassName |
|
219 | + */ |
|
220 | + public static function getOMClass($withPrefix = true) |
|
221 | + { |
|
222 | + return $withPrefix ? ChannelTableMap::CLASS_DEFAULT : ChannelTableMap::OM_CLASS; |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Populates an object of the default type or an object that inherit from the default. |
|
227 | + * |
|
228 | + * @param array $row row returned by DataFetcher->fetch(). |
|
229 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
230 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
231 | 231 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
232 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
233 | - * |
|
234 | - * @throws PropelException Any exceptions caught during processing will be |
|
235 | - * rethrown wrapped into a PropelException. |
|
236 | - * @return array (Channel object, last column rank) |
|
237 | - */ |
|
238 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
239 | - { |
|
240 | - $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
241 | - if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
242 | - // We no longer rehydrate the object, since this can cause data loss. |
|
243 | - // See http://www.propelorm.org/ticket/509 |
|
244 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
245 | - $col = $offset + ChannelTableMap::NUM_HYDRATE_COLUMNS; |
|
246 | - } else { |
|
247 | - $cls = ChannelTableMap::OM_CLASS; |
|
248 | - /** @var Channel $obj */ |
|
249 | - $obj = new $cls(); |
|
250 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
251 | - ChannelTableMap::addInstanceToPool($obj, $key); |
|
252 | - } |
|
253 | - |
|
254 | - return array($obj, $col); |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * The returned array will contain objects of the default type or |
|
259 | - * objects that inherit from the default. |
|
260 | - * |
|
261 | - * @param DataFetcherInterface $dataFetcher |
|
262 | - * @return array |
|
263 | - * @throws PropelException Any exceptions caught during processing will be |
|
264 | - * rethrown wrapped into a PropelException. |
|
265 | - */ |
|
266 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
267 | - { |
|
268 | - $results = array(); |
|
269 | - |
|
270 | - // set the class once to avoid overhead in the loop |
|
271 | - $cls = static::getOMClass(false); |
|
272 | - // populate the object(s) |
|
273 | - while ($row = $dataFetcher->fetch()) { |
|
274 | - $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
275 | - if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
276 | - // We no longer rehydrate the object, since this can cause data loss. |
|
277 | - // See http://www.propelorm.org/ticket/509 |
|
278 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
279 | - $results[] = $obj; |
|
280 | - } else { |
|
281 | - /** @var Channel $obj */ |
|
282 | - $obj = new $cls(); |
|
283 | - $obj->hydrate($row); |
|
284 | - $results[] = $obj; |
|
285 | - ChannelTableMap::addInstanceToPool($obj, $key); |
|
286 | - } // if key exists |
|
287 | - } |
|
288 | - |
|
289 | - return $results; |
|
290 | - } |
|
291 | - /** |
|
292 | - * Add all the columns needed to create a new object. |
|
293 | - * |
|
294 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
295 | - * XML schema will not be added to the select list and only loaded |
|
296 | - * on demand. |
|
297 | - * |
|
298 | - * @param Criteria $criteria object containing the columns to add. |
|
299 | - * @param string $alias optional table alias |
|
300 | - * @throws PropelException Any exceptions caught during processing will be |
|
301 | - * rethrown wrapped into a PropelException. |
|
302 | - */ |
|
303 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
304 | - { |
|
305 | - if (null === $alias) { |
|
306 | - $criteria->addSelectColumn(ChannelTableMap::COL_ID); |
|
307 | - $criteria->addSelectColumn(ChannelTableMap::COL_INSTANCE_NAME); |
|
308 | - $criteria->addSelectColumn(ChannelTableMap::COL_NAME); |
|
309 | - } else { |
|
310 | - $criteria->addSelectColumn($alias . '.id'); |
|
311 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
312 | - $criteria->addSelectColumn($alias . '.name'); |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * Returns the TableMap related to this object. |
|
318 | - * This method is not needed for general use but a specific application could have a need. |
|
319 | - * @return TableMap |
|
320 | - * @throws PropelException Any exceptions caught during processing will be |
|
321 | - * rethrown wrapped into a PropelException. |
|
322 | - */ |
|
323 | - public static function getTableMap() |
|
324 | - { |
|
325 | - return Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME)->getTable(ChannelTableMap::TABLE_NAME); |
|
326 | - } |
|
327 | - |
|
328 | - /** |
|
329 | - * Add a TableMap instance to the database for this tableMap class. |
|
330 | - */ |
|
331 | - public static function buildTableMap() |
|
332 | - { |
|
333 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME); |
|
334 | - if (!$dbMap->hasTable(ChannelTableMap::TABLE_NAME)) { |
|
335 | - $dbMap->addTableObject(new ChannelTableMap()); |
|
336 | - } |
|
337 | - } |
|
338 | - |
|
339 | - /** |
|
340 | - * Performs a DELETE on the database, given a Channel or Criteria object OR a primary key value. |
|
341 | - * |
|
342 | - * @param mixed $values Criteria or Channel object or primary key or array of primary keys |
|
343 | - * which is used to create the DELETE statement |
|
344 | - * @param ConnectionInterface $con the connection to use |
|
345 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
346 | - * if supported by native driver or if emulated using Propel. |
|
347 | - * @throws PropelException Any exceptions caught during processing will be |
|
348 | - * rethrown wrapped into a PropelException. |
|
349 | - */ |
|
350 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
351 | - { |
|
352 | - if (null === $con) { |
|
353 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
354 | - } |
|
355 | - |
|
356 | - if ($values instanceof Criteria) { |
|
357 | - // rename for clarity |
|
358 | - $criteria = $values; |
|
359 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\Channel) { // it's a model object |
|
360 | - // create criteria based on pk values |
|
361 | - $criteria = $values->buildPkeyCriteria(); |
|
362 | - } else { // it's a primary key, or an array of pks |
|
363 | - $criteria = new Criteria(ChannelTableMap::DATABASE_NAME); |
|
364 | - $criteria->add(ChannelTableMap::COL_ID, (array) $values, Criteria::IN); |
|
365 | - } |
|
366 | - |
|
367 | - $query = ChannelQuery::create()->mergeWith($criteria); |
|
368 | - |
|
369 | - if ($values instanceof Criteria) { |
|
370 | - ChannelTableMap::clearInstancePool(); |
|
371 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
372 | - foreach ((array) $values as $singleval) { |
|
373 | - ChannelTableMap::removeInstanceFromPool($singleval); |
|
374 | - } |
|
375 | - } |
|
376 | - |
|
377 | - return $query->delete($con); |
|
378 | - } |
|
379 | - |
|
380 | - /** |
|
381 | - * Deletes all rows from the channel table. |
|
382 | - * |
|
383 | - * @param ConnectionInterface $con the connection to use |
|
384 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
385 | - */ |
|
386 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
387 | - { |
|
388 | - return ChannelQuery::create()->doDeleteAll($con); |
|
389 | - } |
|
390 | - |
|
391 | - /** |
|
392 | - * Performs an INSERT on the database, given a Channel or Criteria object. |
|
393 | - * |
|
394 | - * @param mixed $criteria Criteria or Channel object containing data that is used to create the INSERT statement. |
|
395 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
396 | - * @return mixed The new primary key. |
|
397 | - * @throws PropelException Any exceptions caught during processing will be |
|
398 | - * rethrown wrapped into a PropelException. |
|
399 | - */ |
|
400 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
401 | - { |
|
402 | - if (null === $con) { |
|
403 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
404 | - } |
|
405 | - |
|
406 | - if ($criteria instanceof Criteria) { |
|
407 | - $criteria = clone $criteria; // rename for clarity |
|
408 | - } else { |
|
409 | - $criteria = $criteria->buildCriteria(); // build Criteria from Channel object |
|
410 | - } |
|
411 | - |
|
412 | - if ($criteria->containsKey(ChannelTableMap::COL_ID) && $criteria->keyContainsValue(ChannelTableMap::COL_ID) ) { |
|
413 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ChannelTableMap::COL_ID.')'); |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - // Set the correct dbName |
|
418 | - $query = ChannelQuery::create()->mergeWith($criteria); |
|
419 | - |
|
420 | - // use transaction because $criteria could contain info |
|
421 | - // for more than one table (I guess, conceivably) |
|
422 | - return $con->transaction(function () use ($con, $query) { |
|
423 | - return $query->doInsert($con); |
|
424 | - }); |
|
425 | - } |
|
232 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
233 | + * |
|
234 | + * @throws PropelException Any exceptions caught during processing will be |
|
235 | + * rethrown wrapped into a PropelException. |
|
236 | + * @return array (Channel object, last column rank) |
|
237 | + */ |
|
238 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
239 | + { |
|
240 | + $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
241 | + if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
242 | + // We no longer rehydrate the object, since this can cause data loss. |
|
243 | + // See http://www.propelorm.org/ticket/509 |
|
244 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
245 | + $col = $offset + ChannelTableMap::NUM_HYDRATE_COLUMNS; |
|
246 | + } else { |
|
247 | + $cls = ChannelTableMap::OM_CLASS; |
|
248 | + /** @var Channel $obj */ |
|
249 | + $obj = new $cls(); |
|
250 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
251 | + ChannelTableMap::addInstanceToPool($obj, $key); |
|
252 | + } |
|
253 | + |
|
254 | + return array($obj, $col); |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * The returned array will contain objects of the default type or |
|
259 | + * objects that inherit from the default. |
|
260 | + * |
|
261 | + * @param DataFetcherInterface $dataFetcher |
|
262 | + * @return array |
|
263 | + * @throws PropelException Any exceptions caught during processing will be |
|
264 | + * rethrown wrapped into a PropelException. |
|
265 | + */ |
|
266 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
267 | + { |
|
268 | + $results = array(); |
|
269 | + |
|
270 | + // set the class once to avoid overhead in the loop |
|
271 | + $cls = static::getOMClass(false); |
|
272 | + // populate the object(s) |
|
273 | + while ($row = $dataFetcher->fetch()) { |
|
274 | + $key = ChannelTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
275 | + if (null !== ($obj = ChannelTableMap::getInstanceFromPool($key))) { |
|
276 | + // We no longer rehydrate the object, since this can cause data loss. |
|
277 | + // See http://www.propelorm.org/ticket/509 |
|
278 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
279 | + $results[] = $obj; |
|
280 | + } else { |
|
281 | + /** @var Channel $obj */ |
|
282 | + $obj = new $cls(); |
|
283 | + $obj->hydrate($row); |
|
284 | + $results[] = $obj; |
|
285 | + ChannelTableMap::addInstanceToPool($obj, $key); |
|
286 | + } // if key exists |
|
287 | + } |
|
288 | + |
|
289 | + return $results; |
|
290 | + } |
|
291 | + /** |
|
292 | + * Add all the columns needed to create a new object. |
|
293 | + * |
|
294 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
295 | + * XML schema will not be added to the select list and only loaded |
|
296 | + * on demand. |
|
297 | + * |
|
298 | + * @param Criteria $criteria object containing the columns to add. |
|
299 | + * @param string $alias optional table alias |
|
300 | + * @throws PropelException Any exceptions caught during processing will be |
|
301 | + * rethrown wrapped into a PropelException. |
|
302 | + */ |
|
303 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
304 | + { |
|
305 | + if (null === $alias) { |
|
306 | + $criteria->addSelectColumn(ChannelTableMap::COL_ID); |
|
307 | + $criteria->addSelectColumn(ChannelTableMap::COL_INSTANCE_NAME); |
|
308 | + $criteria->addSelectColumn(ChannelTableMap::COL_NAME); |
|
309 | + } else { |
|
310 | + $criteria->addSelectColumn($alias . '.id'); |
|
311 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
312 | + $criteria->addSelectColumn($alias . '.name'); |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * Returns the TableMap related to this object. |
|
318 | + * This method is not needed for general use but a specific application could have a need. |
|
319 | + * @return TableMap |
|
320 | + * @throws PropelException Any exceptions caught during processing will be |
|
321 | + * rethrown wrapped into a PropelException. |
|
322 | + */ |
|
323 | + public static function getTableMap() |
|
324 | + { |
|
325 | + return Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME)->getTable(ChannelTableMap::TABLE_NAME); |
|
326 | + } |
|
327 | + |
|
328 | + /** |
|
329 | + * Add a TableMap instance to the database for this tableMap class. |
|
330 | + */ |
|
331 | + public static function buildTableMap() |
|
332 | + { |
|
333 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ChannelTableMap::DATABASE_NAME); |
|
334 | + if (!$dbMap->hasTable(ChannelTableMap::TABLE_NAME)) { |
|
335 | + $dbMap->addTableObject(new ChannelTableMap()); |
|
336 | + } |
|
337 | + } |
|
338 | + |
|
339 | + /** |
|
340 | + * Performs a DELETE on the database, given a Channel or Criteria object OR a primary key value. |
|
341 | + * |
|
342 | + * @param mixed $values Criteria or Channel object or primary key or array of primary keys |
|
343 | + * which is used to create the DELETE statement |
|
344 | + * @param ConnectionInterface $con the connection to use |
|
345 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
346 | + * if supported by native driver or if emulated using Propel. |
|
347 | + * @throws PropelException Any exceptions caught during processing will be |
|
348 | + * rethrown wrapped into a PropelException. |
|
349 | + */ |
|
350 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
351 | + { |
|
352 | + if (null === $con) { |
|
353 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
354 | + } |
|
355 | + |
|
356 | + if ($values instanceof Criteria) { |
|
357 | + // rename for clarity |
|
358 | + $criteria = $values; |
|
359 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\Channel) { // it's a model object |
|
360 | + // create criteria based on pk values |
|
361 | + $criteria = $values->buildPkeyCriteria(); |
|
362 | + } else { // it's a primary key, or an array of pks |
|
363 | + $criteria = new Criteria(ChannelTableMap::DATABASE_NAME); |
|
364 | + $criteria->add(ChannelTableMap::COL_ID, (array) $values, Criteria::IN); |
|
365 | + } |
|
366 | + |
|
367 | + $query = ChannelQuery::create()->mergeWith($criteria); |
|
368 | + |
|
369 | + if ($values instanceof Criteria) { |
|
370 | + ChannelTableMap::clearInstancePool(); |
|
371 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
372 | + foreach ((array) $values as $singleval) { |
|
373 | + ChannelTableMap::removeInstanceFromPool($singleval); |
|
374 | + } |
|
375 | + } |
|
376 | + |
|
377 | + return $query->delete($con); |
|
378 | + } |
|
379 | + |
|
380 | + /** |
|
381 | + * Deletes all rows from the channel table. |
|
382 | + * |
|
383 | + * @param ConnectionInterface $con the connection to use |
|
384 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
385 | + */ |
|
386 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
387 | + { |
|
388 | + return ChannelQuery::create()->doDeleteAll($con); |
|
389 | + } |
|
390 | + |
|
391 | + /** |
|
392 | + * Performs an INSERT on the database, given a Channel or Criteria object. |
|
393 | + * |
|
394 | + * @param mixed $criteria Criteria or Channel object containing data that is used to create the INSERT statement. |
|
395 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
396 | + * @return mixed The new primary key. |
|
397 | + * @throws PropelException Any exceptions caught during processing will be |
|
398 | + * rethrown wrapped into a PropelException. |
|
399 | + */ |
|
400 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
401 | + { |
|
402 | + if (null === $con) { |
|
403 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
404 | + } |
|
405 | + |
|
406 | + if ($criteria instanceof Criteria) { |
|
407 | + $criteria = clone $criteria; // rename for clarity |
|
408 | + } else { |
|
409 | + $criteria = $criteria->buildCriteria(); // build Criteria from Channel object |
|
410 | + } |
|
411 | + |
|
412 | + if ($criteria->containsKey(ChannelTableMap::COL_ID) && $criteria->keyContainsValue(ChannelTableMap::COL_ID) ) { |
|
413 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ChannelTableMap::COL_ID.')'); |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + // Set the correct dbName |
|
418 | + $query = ChannelQuery::create()->mergeWith($criteria); |
|
419 | + |
|
420 | + // use transaction because $criteria could contain info |
|
421 | + // for more than one table (I guess, conceivably) |
|
422 | + return $con->transaction(function () use ($con, $query) { |
|
423 | + return $query->doInsert($con); |
|
424 | + }); |
|
425 | + } |
|
426 | 426 | |
427 | 427 | } // ChannelTableMap |
428 | 428 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -28,425 +28,425 @@ |
||
28 | 28 | */ |
29 | 29 | class ConnectionTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ConnectionTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'connection'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Connection'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Connection'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 6; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 6; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'connection.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'connection.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the user_id field |
|
86 | - */ |
|
87 | - const COL_USER_ID = 'connection.user_id'; |
|
88 | - |
|
89 | - /** |
|
90 | - * the column name for the peer field |
|
91 | - */ |
|
92 | - const COL_PEER = 'connection.peer'; |
|
93 | - |
|
94 | - /** |
|
95 | - * the column name for the started field |
|
96 | - */ |
|
97 | - const COL_STARTED = 'connection.started'; |
|
98 | - |
|
99 | - /** |
|
100 | - * the column name for the type field |
|
101 | - */ |
|
102 | - const COL_TYPE = 'connection.type'; |
|
103 | - |
|
104 | - /** |
|
105 | - * The default string format for model objects of the related table |
|
106 | - */ |
|
107 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
108 | - |
|
109 | - /** |
|
110 | - * holds an array of fieldnames |
|
111 | - * |
|
112 | - * first dimension keys are the type constants |
|
113 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
114 | - */ |
|
115 | - protected static $fieldNames = array ( |
|
116 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'Peer', 'Started', 'Type', ), |
|
117 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'peer', 'started', 'type', ), |
|
118 | - self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID, ConnectionTableMap::COL_INSTANCE_NAME, ConnectionTableMap::COL_USER_ID, ConnectionTableMap::COL_PEER, ConnectionTableMap::COL_STARTED, ConnectionTableMap::COL_TYPE, ), |
|
119 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'peer', 'started', 'type', ), |
|
120 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
121 | - ); |
|
122 | - |
|
123 | - /** |
|
124 | - * holds an array of keys for quick access to the fieldnames array |
|
125 | - * |
|
126 | - * first dimension keys are the type constants |
|
127 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
128 | - */ |
|
129 | - protected static $fieldKeys = array ( |
|
130 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'Peer' => 3, 'Started' => 4, 'Type' => 5, ), |
|
131 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
132 | - self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID => 0, ConnectionTableMap::COL_INSTANCE_NAME => 1, ConnectionTableMap::COL_USER_ID => 2, ConnectionTableMap::COL_PEER => 3, ConnectionTableMap::COL_STARTED => 4, ConnectionTableMap::COL_TYPE => 5, ), |
|
133 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
134 | - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
135 | - ); |
|
136 | - |
|
137 | - /** |
|
138 | - * Initialize the table attributes and columns |
|
139 | - * Relations are not initialized by this method since they are lazy loaded |
|
140 | - * |
|
141 | - * @return void |
|
142 | - * @throws PropelException |
|
143 | - */ |
|
144 | - public function initialize() |
|
145 | - { |
|
146 | - // attributes |
|
147 | - $this->setName('connection'); |
|
148 | - $this->setPhpName('Connection'); |
|
149 | - $this->setIdentifierQuoting(false); |
|
150 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\Connection'); |
|
151 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
152 | - $this->setUseIdGenerator(true); |
|
153 | - // columns |
|
154 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
155 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
156 | - $this->addForeignKey('user_id', 'UserId', 'INTEGER', 'user', 'id', false, null, null); |
|
157 | - $this->addColumn('peer', 'Peer', 'VARCHAR', true, 255, null); |
|
158 | - $this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
|
159 | - $this->addColumn('type', 'Type', 'VARCHAR', true, 255, null); |
|
160 | - } // initialize() |
|
161 | - |
|
162 | - /** |
|
163 | - * Build the RelationMap objects for this table relationships |
|
164 | - */ |
|
165 | - public function buildRelations() |
|
166 | - { |
|
167 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.ConnectionTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'connection'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Connection'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Connection'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 6; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 6; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'connection.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'connection.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the user_id field |
|
86 | + */ |
|
87 | + const COL_USER_ID = 'connection.user_id'; |
|
88 | + |
|
89 | + /** |
|
90 | + * the column name for the peer field |
|
91 | + */ |
|
92 | + const COL_PEER = 'connection.peer'; |
|
93 | + |
|
94 | + /** |
|
95 | + * the column name for the started field |
|
96 | + */ |
|
97 | + const COL_STARTED = 'connection.started'; |
|
98 | + |
|
99 | + /** |
|
100 | + * the column name for the type field |
|
101 | + */ |
|
102 | + const COL_TYPE = 'connection.type'; |
|
103 | + |
|
104 | + /** |
|
105 | + * The default string format for model objects of the related table |
|
106 | + */ |
|
107 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
108 | + |
|
109 | + /** |
|
110 | + * holds an array of fieldnames |
|
111 | + * |
|
112 | + * first dimension keys are the type constants |
|
113 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
114 | + */ |
|
115 | + protected static $fieldNames = array ( |
|
116 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'UserId', 'Peer', 'Started', 'Type', ), |
|
117 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'userId', 'peer', 'started', 'type', ), |
|
118 | + self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID, ConnectionTableMap::COL_INSTANCE_NAME, ConnectionTableMap::COL_USER_ID, ConnectionTableMap::COL_PEER, ConnectionTableMap::COL_STARTED, ConnectionTableMap::COL_TYPE, ), |
|
119 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'user_id', 'peer', 'started', 'type', ), |
|
120 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
121 | + ); |
|
122 | + |
|
123 | + /** |
|
124 | + * holds an array of keys for quick access to the fieldnames array |
|
125 | + * |
|
126 | + * first dimension keys are the type constants |
|
127 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
128 | + */ |
|
129 | + protected static $fieldKeys = array ( |
|
130 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'UserId' => 2, 'Peer' => 3, 'Started' => 4, 'Type' => 5, ), |
|
131 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'userId' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
132 | + self::TYPE_COLNAME => array(ConnectionTableMap::COL_ID => 0, ConnectionTableMap::COL_INSTANCE_NAME => 1, ConnectionTableMap::COL_USER_ID => 2, ConnectionTableMap::COL_PEER => 3, ConnectionTableMap::COL_STARTED => 4, ConnectionTableMap::COL_TYPE => 5, ), |
|
133 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'user_id' => 2, 'peer' => 3, 'started' => 4, 'type' => 5, ), |
|
134 | + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) |
|
135 | + ); |
|
136 | + |
|
137 | + /** |
|
138 | + * Initialize the table attributes and columns |
|
139 | + * Relations are not initialized by this method since they are lazy loaded |
|
140 | + * |
|
141 | + * @return void |
|
142 | + * @throws PropelException |
|
143 | + */ |
|
144 | + public function initialize() |
|
145 | + { |
|
146 | + // attributes |
|
147 | + $this->setName('connection'); |
|
148 | + $this->setPhpName('Connection'); |
|
149 | + $this->setIdentifierQuoting(false); |
|
150 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\Connection'); |
|
151 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
152 | + $this->setUseIdGenerator(true); |
|
153 | + // columns |
|
154 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
155 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
156 | + $this->addForeignKey('user_id', 'UserId', 'INTEGER', 'user', 'id', false, null, null); |
|
157 | + $this->addColumn('peer', 'Peer', 'VARCHAR', true, 255, null); |
|
158 | + $this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
|
159 | + $this->addColumn('type', 'Type', 'VARCHAR', true, 255, null); |
|
160 | + } // initialize() |
|
161 | + |
|
162 | + /** |
|
163 | + * Build the RelationMap objects for this table relationships |
|
164 | + */ |
|
165 | + public function buildRelations() |
|
166 | + { |
|
167 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
168 | 168 | 0 => |
169 | 169 | array ( |
170 | - 0 => ':instance_name', |
|
171 | - 1 => ':name', |
|
170 | + 0 => ':instance_name', |
|
171 | + 1 => ':name', |
|
172 | 172 | ), |
173 | 173 | ), null, null, null, false); |
174 | - $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
174 | + $this->addRelation('User', '\\Jalle19\\StatusManager\\Database\\User', RelationMap::MANY_TO_ONE, array ( |
|
175 | 175 | 0 => |
176 | 176 | array ( |
177 | - 0 => ':user_id', |
|
178 | - 1 => ':id', |
|
177 | + 0 => ':user_id', |
|
178 | + 1 => ':id', |
|
179 | 179 | ), |
180 | 180 | ), null, null, null, false); |
181 | - } // buildRelations() |
|
182 | - |
|
183 | - /** |
|
184 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
185 | - * |
|
186 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
187 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
188 | - * |
|
189 | - * @param array $row resultset row. |
|
190 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
191 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
192 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
193 | - * |
|
194 | - * @return string The primary key hash of the row |
|
195 | - */ |
|
196 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
197 | - { |
|
198 | - // If the PK cannot be derived from the row, return NULL. |
|
199 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
200 | - return null; |
|
201 | - } |
|
202 | - |
|
203 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Retrieves the primary key from the DB resultset row |
|
208 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
209 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
210 | - * |
|
211 | - * @param array $row resultset row. |
|
212 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
213 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
214 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
215 | - * |
|
216 | - * @return mixed The primary key of the row |
|
217 | - */ |
|
218 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
219 | - { |
|
220 | - return (int) $row[ |
|
221 | - $indexType == TableMap::TYPE_NUM |
|
222 | - ? 0 + $offset |
|
223 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
224 | - ]; |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * The class that the tableMap will make instances of. |
|
229 | - * |
|
230 | - * If $withPrefix is true, the returned path |
|
231 | - * uses a dot-path notation which is translated into a path |
|
232 | - * relative to a location on the PHP include_path. |
|
233 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
234 | - * |
|
235 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
236 | - * @return string path.to.ClassName |
|
237 | - */ |
|
238 | - public static function getOMClass($withPrefix = true) |
|
239 | - { |
|
240 | - return $withPrefix ? ConnectionTableMap::CLASS_DEFAULT : ConnectionTableMap::OM_CLASS; |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Populates an object of the default type or an object that inherit from the default. |
|
245 | - * |
|
246 | - * @param array $row row returned by DataFetcher->fetch(). |
|
247 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
248 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
181 | + } // buildRelations() |
|
182 | + |
|
183 | + /** |
|
184 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
185 | + * |
|
186 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
187 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
188 | + * |
|
189 | + * @param array $row resultset row. |
|
190 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
191 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
192 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
193 | + * |
|
194 | + * @return string The primary key hash of the row |
|
195 | + */ |
|
196 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
197 | + { |
|
198 | + // If the PK cannot be derived from the row, return NULL. |
|
199 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
200 | + return null; |
|
201 | + } |
|
202 | + |
|
203 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Retrieves the primary key from the DB resultset row |
|
208 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
209 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
210 | + * |
|
211 | + * @param array $row resultset row. |
|
212 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
213 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
214 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
215 | + * |
|
216 | + * @return mixed The primary key of the row |
|
217 | + */ |
|
218 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
219 | + { |
|
220 | + return (int) $row[ |
|
221 | + $indexType == TableMap::TYPE_NUM |
|
222 | + ? 0 + $offset |
|
223 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
224 | + ]; |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * The class that the tableMap will make instances of. |
|
229 | + * |
|
230 | + * If $withPrefix is true, the returned path |
|
231 | + * uses a dot-path notation which is translated into a path |
|
232 | + * relative to a location on the PHP include_path. |
|
233 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
234 | + * |
|
235 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
236 | + * @return string path.to.ClassName |
|
237 | + */ |
|
238 | + public static function getOMClass($withPrefix = true) |
|
239 | + { |
|
240 | + return $withPrefix ? ConnectionTableMap::CLASS_DEFAULT : ConnectionTableMap::OM_CLASS; |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Populates an object of the default type or an object that inherit from the default. |
|
245 | + * |
|
246 | + * @param array $row row returned by DataFetcher->fetch(). |
|
247 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
248 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
249 | 249 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
250 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
251 | - * |
|
252 | - * @throws PropelException Any exceptions caught during processing will be |
|
253 | - * rethrown wrapped into a PropelException. |
|
254 | - * @return array (Connection object, last column rank) |
|
255 | - */ |
|
256 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
257 | - { |
|
258 | - $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
259 | - if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
260 | - // We no longer rehydrate the object, since this can cause data loss. |
|
261 | - // See http://www.propelorm.org/ticket/509 |
|
262 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
263 | - $col = $offset + ConnectionTableMap::NUM_HYDRATE_COLUMNS; |
|
264 | - } else { |
|
265 | - $cls = ConnectionTableMap::OM_CLASS; |
|
266 | - /** @var Connection $obj */ |
|
267 | - $obj = new $cls(); |
|
268 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
269 | - ConnectionTableMap::addInstanceToPool($obj, $key); |
|
270 | - } |
|
271 | - |
|
272 | - return array($obj, $col); |
|
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * The returned array will contain objects of the default type or |
|
277 | - * objects that inherit from the default. |
|
278 | - * |
|
279 | - * @param DataFetcherInterface $dataFetcher |
|
280 | - * @return array |
|
281 | - * @throws PropelException Any exceptions caught during processing will be |
|
282 | - * rethrown wrapped into a PropelException. |
|
283 | - */ |
|
284 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
285 | - { |
|
286 | - $results = array(); |
|
287 | - |
|
288 | - // set the class once to avoid overhead in the loop |
|
289 | - $cls = static::getOMClass(false); |
|
290 | - // populate the object(s) |
|
291 | - while ($row = $dataFetcher->fetch()) { |
|
292 | - $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
293 | - if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
294 | - // We no longer rehydrate the object, since this can cause data loss. |
|
295 | - // See http://www.propelorm.org/ticket/509 |
|
296 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
297 | - $results[] = $obj; |
|
298 | - } else { |
|
299 | - /** @var Connection $obj */ |
|
300 | - $obj = new $cls(); |
|
301 | - $obj->hydrate($row); |
|
302 | - $results[] = $obj; |
|
303 | - ConnectionTableMap::addInstanceToPool($obj, $key); |
|
304 | - } // if key exists |
|
305 | - } |
|
306 | - |
|
307 | - return $results; |
|
308 | - } |
|
309 | - /** |
|
310 | - * Add all the columns needed to create a new object. |
|
311 | - * |
|
312 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
313 | - * XML schema will not be added to the select list and only loaded |
|
314 | - * on demand. |
|
315 | - * |
|
316 | - * @param Criteria $criteria object containing the columns to add. |
|
317 | - * @param string $alias optional table alias |
|
318 | - * @throws PropelException Any exceptions caught during processing will be |
|
319 | - * rethrown wrapped into a PropelException. |
|
320 | - */ |
|
321 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
322 | - { |
|
323 | - if (null === $alias) { |
|
324 | - $criteria->addSelectColumn(ConnectionTableMap::COL_ID); |
|
325 | - $criteria->addSelectColumn(ConnectionTableMap::COL_INSTANCE_NAME); |
|
326 | - $criteria->addSelectColumn(ConnectionTableMap::COL_USER_ID); |
|
327 | - $criteria->addSelectColumn(ConnectionTableMap::COL_PEER); |
|
328 | - $criteria->addSelectColumn(ConnectionTableMap::COL_STARTED); |
|
329 | - $criteria->addSelectColumn(ConnectionTableMap::COL_TYPE); |
|
330 | - } else { |
|
331 | - $criteria->addSelectColumn($alias . '.id'); |
|
332 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
333 | - $criteria->addSelectColumn($alias . '.user_id'); |
|
334 | - $criteria->addSelectColumn($alias . '.peer'); |
|
335 | - $criteria->addSelectColumn($alias . '.started'); |
|
336 | - $criteria->addSelectColumn($alias . '.type'); |
|
337 | - } |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Returns the TableMap related to this object. |
|
342 | - * This method is not needed for general use but a specific application could have a need. |
|
343 | - * @return TableMap |
|
344 | - * @throws PropelException Any exceptions caught during processing will be |
|
345 | - * rethrown wrapped into a PropelException. |
|
346 | - */ |
|
347 | - public static function getTableMap() |
|
348 | - { |
|
349 | - return Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME)->getTable(ConnectionTableMap::TABLE_NAME); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Add a TableMap instance to the database for this tableMap class. |
|
354 | - */ |
|
355 | - public static function buildTableMap() |
|
356 | - { |
|
357 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME); |
|
358 | - if (!$dbMap->hasTable(ConnectionTableMap::TABLE_NAME)) { |
|
359 | - $dbMap->addTableObject(new ConnectionTableMap()); |
|
360 | - } |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Performs a DELETE on the database, given a Connection or Criteria object OR a primary key value. |
|
365 | - * |
|
366 | - * @param mixed $values Criteria or Connection object or primary key or array of primary keys |
|
367 | - * which is used to create the DELETE statement |
|
368 | - * @param ConnectionInterface $con the connection to use |
|
369 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
370 | - * if supported by native driver or if emulated using Propel. |
|
371 | - * @throws PropelException Any exceptions caught during processing will be |
|
372 | - * rethrown wrapped into a PropelException. |
|
373 | - */ |
|
374 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
375 | - { |
|
376 | - if (null === $con) { |
|
377 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
378 | - } |
|
379 | - |
|
380 | - if ($values instanceof Criteria) { |
|
381 | - // rename for clarity |
|
382 | - $criteria = $values; |
|
383 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\Connection) { // it's a model object |
|
384 | - // create criteria based on pk values |
|
385 | - $criteria = $values->buildPkeyCriteria(); |
|
386 | - } else { // it's a primary key, or an array of pks |
|
387 | - $criteria = new Criteria(ConnectionTableMap::DATABASE_NAME); |
|
388 | - $criteria->add(ConnectionTableMap::COL_ID, (array) $values, Criteria::IN); |
|
389 | - } |
|
390 | - |
|
391 | - $query = ConnectionQuery::create()->mergeWith($criteria); |
|
392 | - |
|
393 | - if ($values instanceof Criteria) { |
|
394 | - ConnectionTableMap::clearInstancePool(); |
|
395 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
396 | - foreach ((array) $values as $singleval) { |
|
397 | - ConnectionTableMap::removeInstanceFromPool($singleval); |
|
398 | - } |
|
399 | - } |
|
400 | - |
|
401 | - return $query->delete($con); |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * Deletes all rows from the connection table. |
|
406 | - * |
|
407 | - * @param ConnectionInterface $con the connection to use |
|
408 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
409 | - */ |
|
410 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
411 | - { |
|
412 | - return ConnectionQuery::create()->doDeleteAll($con); |
|
413 | - } |
|
414 | - |
|
415 | - /** |
|
416 | - * Performs an INSERT on the database, given a Connection or Criteria object. |
|
417 | - * |
|
418 | - * @param mixed $criteria Criteria or Connection object containing data that is used to create the INSERT statement. |
|
419 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
420 | - * @return mixed The new primary key. |
|
421 | - * @throws PropelException Any exceptions caught during processing will be |
|
422 | - * rethrown wrapped into a PropelException. |
|
423 | - */ |
|
424 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
425 | - { |
|
426 | - if (null === $con) { |
|
427 | - $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
428 | - } |
|
429 | - |
|
430 | - if ($criteria instanceof Criteria) { |
|
431 | - $criteria = clone $criteria; // rename for clarity |
|
432 | - } else { |
|
433 | - $criteria = $criteria->buildCriteria(); // build Criteria from Connection object |
|
434 | - } |
|
435 | - |
|
436 | - if ($criteria->containsKey(ConnectionTableMap::COL_ID) && $criteria->keyContainsValue(ConnectionTableMap::COL_ID) ) { |
|
437 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConnectionTableMap::COL_ID.')'); |
|
438 | - } |
|
439 | - |
|
440 | - |
|
441 | - // Set the correct dbName |
|
442 | - $query = ConnectionQuery::create()->mergeWith($criteria); |
|
443 | - |
|
444 | - // use transaction because $criteria could contain info |
|
445 | - // for more than one table (I guess, conceivably) |
|
446 | - return $con->transaction(function () use ($con, $query) { |
|
447 | - return $query->doInsert($con); |
|
448 | - }); |
|
449 | - } |
|
250 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
251 | + * |
|
252 | + * @throws PropelException Any exceptions caught during processing will be |
|
253 | + * rethrown wrapped into a PropelException. |
|
254 | + * @return array (Connection object, last column rank) |
|
255 | + */ |
|
256 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
257 | + { |
|
258 | + $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
259 | + if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
260 | + // We no longer rehydrate the object, since this can cause data loss. |
|
261 | + // See http://www.propelorm.org/ticket/509 |
|
262 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
263 | + $col = $offset + ConnectionTableMap::NUM_HYDRATE_COLUMNS; |
|
264 | + } else { |
|
265 | + $cls = ConnectionTableMap::OM_CLASS; |
|
266 | + /** @var Connection $obj */ |
|
267 | + $obj = new $cls(); |
|
268 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
269 | + ConnectionTableMap::addInstanceToPool($obj, $key); |
|
270 | + } |
|
271 | + |
|
272 | + return array($obj, $col); |
|
273 | + } |
|
274 | + |
|
275 | + /** |
|
276 | + * The returned array will contain objects of the default type or |
|
277 | + * objects that inherit from the default. |
|
278 | + * |
|
279 | + * @param DataFetcherInterface $dataFetcher |
|
280 | + * @return array |
|
281 | + * @throws PropelException Any exceptions caught during processing will be |
|
282 | + * rethrown wrapped into a PropelException. |
|
283 | + */ |
|
284 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
285 | + { |
|
286 | + $results = array(); |
|
287 | + |
|
288 | + // set the class once to avoid overhead in the loop |
|
289 | + $cls = static::getOMClass(false); |
|
290 | + // populate the object(s) |
|
291 | + while ($row = $dataFetcher->fetch()) { |
|
292 | + $key = ConnectionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
293 | + if (null !== ($obj = ConnectionTableMap::getInstanceFromPool($key))) { |
|
294 | + // We no longer rehydrate the object, since this can cause data loss. |
|
295 | + // See http://www.propelorm.org/ticket/509 |
|
296 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
297 | + $results[] = $obj; |
|
298 | + } else { |
|
299 | + /** @var Connection $obj */ |
|
300 | + $obj = new $cls(); |
|
301 | + $obj->hydrate($row); |
|
302 | + $results[] = $obj; |
|
303 | + ConnectionTableMap::addInstanceToPool($obj, $key); |
|
304 | + } // if key exists |
|
305 | + } |
|
306 | + |
|
307 | + return $results; |
|
308 | + } |
|
309 | + /** |
|
310 | + * Add all the columns needed to create a new object. |
|
311 | + * |
|
312 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
313 | + * XML schema will not be added to the select list and only loaded |
|
314 | + * on demand. |
|
315 | + * |
|
316 | + * @param Criteria $criteria object containing the columns to add. |
|
317 | + * @param string $alias optional table alias |
|
318 | + * @throws PropelException Any exceptions caught during processing will be |
|
319 | + * rethrown wrapped into a PropelException. |
|
320 | + */ |
|
321 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
322 | + { |
|
323 | + if (null === $alias) { |
|
324 | + $criteria->addSelectColumn(ConnectionTableMap::COL_ID); |
|
325 | + $criteria->addSelectColumn(ConnectionTableMap::COL_INSTANCE_NAME); |
|
326 | + $criteria->addSelectColumn(ConnectionTableMap::COL_USER_ID); |
|
327 | + $criteria->addSelectColumn(ConnectionTableMap::COL_PEER); |
|
328 | + $criteria->addSelectColumn(ConnectionTableMap::COL_STARTED); |
|
329 | + $criteria->addSelectColumn(ConnectionTableMap::COL_TYPE); |
|
330 | + } else { |
|
331 | + $criteria->addSelectColumn($alias . '.id'); |
|
332 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
333 | + $criteria->addSelectColumn($alias . '.user_id'); |
|
334 | + $criteria->addSelectColumn($alias . '.peer'); |
|
335 | + $criteria->addSelectColumn($alias . '.started'); |
|
336 | + $criteria->addSelectColumn($alias . '.type'); |
|
337 | + } |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Returns the TableMap related to this object. |
|
342 | + * This method is not needed for general use but a specific application could have a need. |
|
343 | + * @return TableMap |
|
344 | + * @throws PropelException Any exceptions caught during processing will be |
|
345 | + * rethrown wrapped into a PropelException. |
|
346 | + */ |
|
347 | + public static function getTableMap() |
|
348 | + { |
|
349 | + return Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME)->getTable(ConnectionTableMap::TABLE_NAME); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Add a TableMap instance to the database for this tableMap class. |
|
354 | + */ |
|
355 | + public static function buildTableMap() |
|
356 | + { |
|
357 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ConnectionTableMap::DATABASE_NAME); |
|
358 | + if (!$dbMap->hasTable(ConnectionTableMap::TABLE_NAME)) { |
|
359 | + $dbMap->addTableObject(new ConnectionTableMap()); |
|
360 | + } |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Performs a DELETE on the database, given a Connection or Criteria object OR a primary key value. |
|
365 | + * |
|
366 | + * @param mixed $values Criteria or Connection object or primary key or array of primary keys |
|
367 | + * which is used to create the DELETE statement |
|
368 | + * @param ConnectionInterface $con the connection to use |
|
369 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
370 | + * if supported by native driver or if emulated using Propel. |
|
371 | + * @throws PropelException Any exceptions caught during processing will be |
|
372 | + * rethrown wrapped into a PropelException. |
|
373 | + */ |
|
374 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
375 | + { |
|
376 | + if (null === $con) { |
|
377 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
378 | + } |
|
379 | + |
|
380 | + if ($values instanceof Criteria) { |
|
381 | + // rename for clarity |
|
382 | + $criteria = $values; |
|
383 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\Connection) { // it's a model object |
|
384 | + // create criteria based on pk values |
|
385 | + $criteria = $values->buildPkeyCriteria(); |
|
386 | + } else { // it's a primary key, or an array of pks |
|
387 | + $criteria = new Criteria(ConnectionTableMap::DATABASE_NAME); |
|
388 | + $criteria->add(ConnectionTableMap::COL_ID, (array) $values, Criteria::IN); |
|
389 | + } |
|
390 | + |
|
391 | + $query = ConnectionQuery::create()->mergeWith($criteria); |
|
392 | + |
|
393 | + if ($values instanceof Criteria) { |
|
394 | + ConnectionTableMap::clearInstancePool(); |
|
395 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
396 | + foreach ((array) $values as $singleval) { |
|
397 | + ConnectionTableMap::removeInstanceFromPool($singleval); |
|
398 | + } |
|
399 | + } |
|
400 | + |
|
401 | + return $query->delete($con); |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * Deletes all rows from the connection table. |
|
406 | + * |
|
407 | + * @param ConnectionInterface $con the connection to use |
|
408 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
409 | + */ |
|
410 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
411 | + { |
|
412 | + return ConnectionQuery::create()->doDeleteAll($con); |
|
413 | + } |
|
414 | + |
|
415 | + /** |
|
416 | + * Performs an INSERT on the database, given a Connection or Criteria object. |
|
417 | + * |
|
418 | + * @param mixed $criteria Criteria or Connection object containing data that is used to create the INSERT statement. |
|
419 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
420 | + * @return mixed The new primary key. |
|
421 | + * @throws PropelException Any exceptions caught during processing will be |
|
422 | + * rethrown wrapped into a PropelException. |
|
423 | + */ |
|
424 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
425 | + { |
|
426 | + if (null === $con) { |
|
427 | + $con = Propel::getServiceContainer()->getWriteConnection(ConnectionTableMap::DATABASE_NAME); |
|
428 | + } |
|
429 | + |
|
430 | + if ($criteria instanceof Criteria) { |
|
431 | + $criteria = clone $criteria; // rename for clarity |
|
432 | + } else { |
|
433 | + $criteria = $criteria->buildCriteria(); // build Criteria from Connection object |
|
434 | + } |
|
435 | + |
|
436 | + if ($criteria->containsKey(ConnectionTableMap::COL_ID) && $criteria->keyContainsValue(ConnectionTableMap::COL_ID) ) { |
|
437 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ConnectionTableMap::COL_ID.')'); |
|
438 | + } |
|
439 | + |
|
440 | + |
|
441 | + // Set the correct dbName |
|
442 | + $query = ConnectionQuery::create()->mergeWith($criteria); |
|
443 | + |
|
444 | + // use transaction because $criteria could contain info |
|
445 | + // for more than one table (I guess, conceivably) |
|
446 | + return $con->transaction(function () use ($con, $query) { |
|
447 | + return $query->doInsert($con); |
|
448 | + }); |
|
449 | + } |
|
450 | 450 | |
451 | 451 | } // ConnectionTableMap |
452 | 452 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -28,408 +28,408 @@ |
||
28 | 28 | */ |
29 | 29 | class UserTableMap extends TableMap |
30 | 30 | { |
31 | - use InstancePoolTrait; |
|
32 | - use TableMapTrait; |
|
33 | - |
|
34 | - /** |
|
35 | - * The (dot-path) name of this class |
|
36 | - */ |
|
37 | - const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.UserTableMap'; |
|
38 | - |
|
39 | - /** |
|
40 | - * The default database name for this class |
|
41 | - */ |
|
42 | - const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | - |
|
44 | - /** |
|
45 | - * The table name for this class |
|
46 | - */ |
|
47 | - const TABLE_NAME = 'user'; |
|
48 | - |
|
49 | - /** |
|
50 | - * The related Propel class for this table |
|
51 | - */ |
|
52 | - const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\User'; |
|
53 | - |
|
54 | - /** |
|
55 | - * A class that can be returned by this tableMap |
|
56 | - */ |
|
57 | - const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.User'; |
|
58 | - |
|
59 | - /** |
|
60 | - * The total number of columns |
|
61 | - */ |
|
62 | - const NUM_COLUMNS = 3; |
|
63 | - |
|
64 | - /** |
|
65 | - * The number of lazy-loaded columns |
|
66 | - */ |
|
67 | - const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | - |
|
69 | - /** |
|
70 | - * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | - */ |
|
72 | - const NUM_HYDRATE_COLUMNS = 3; |
|
73 | - |
|
74 | - /** |
|
75 | - * the column name for the id field |
|
76 | - */ |
|
77 | - const COL_ID = 'user.id'; |
|
78 | - |
|
79 | - /** |
|
80 | - * the column name for the instance_name field |
|
81 | - */ |
|
82 | - const COL_INSTANCE_NAME = 'user.instance_name'; |
|
83 | - |
|
84 | - /** |
|
85 | - * the column name for the name field |
|
86 | - */ |
|
87 | - const COL_NAME = 'user.name'; |
|
88 | - |
|
89 | - /** |
|
90 | - * The default string format for model objects of the related table |
|
91 | - */ |
|
92 | - const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | - |
|
94 | - /** |
|
95 | - * holds an array of fieldnames |
|
96 | - * |
|
97 | - * first dimension keys are the type constants |
|
98 | - * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | - */ |
|
100 | - protected static $fieldNames = array ( |
|
101 | - self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | - self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | - self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_INSTANCE_NAME, UserTableMap::COL_NAME, ), |
|
104 | - self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | - ); |
|
107 | - |
|
108 | - /** |
|
109 | - * holds an array of keys for quick access to the fieldnames array |
|
110 | - * |
|
111 | - * first dimension keys are the type constants |
|
112 | - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | - */ |
|
114 | - protected static $fieldKeys = array ( |
|
115 | - self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | - self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | - self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_INSTANCE_NAME => 1, UserTableMap::COL_NAME => 2, ), |
|
118 | - self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | - self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | - ); |
|
121 | - |
|
122 | - /** |
|
123 | - * Initialize the table attributes and columns |
|
124 | - * Relations are not initialized by this method since they are lazy loaded |
|
125 | - * |
|
126 | - * @return void |
|
127 | - * @throws PropelException |
|
128 | - */ |
|
129 | - public function initialize() |
|
130 | - { |
|
131 | - // attributes |
|
132 | - $this->setName('user'); |
|
133 | - $this->setPhpName('User'); |
|
134 | - $this->setIdentifierQuoting(false); |
|
135 | - $this->setClassName('\\Jalle19\\StatusManager\\Database\\User'); |
|
136 | - $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | - $this->setUseIdGenerator(true); |
|
138 | - // columns |
|
139 | - $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | - $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | - $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | - } // initialize() |
|
143 | - |
|
144 | - /** |
|
145 | - * Build the RelationMap objects for this table relationships |
|
146 | - */ |
|
147 | - public function buildRelations() |
|
148 | - { |
|
149 | - $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
31 | + use InstancePoolTrait; |
|
32 | + use TableMapTrait; |
|
33 | + |
|
34 | + /** |
|
35 | + * The (dot-path) name of this class |
|
36 | + */ |
|
37 | + const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.UserTableMap'; |
|
38 | + |
|
39 | + /** |
|
40 | + * The default database name for this class |
|
41 | + */ |
|
42 | + const DATABASE_NAME = 'tvheadend_status_manager'; |
|
43 | + |
|
44 | + /** |
|
45 | + * The table name for this class |
|
46 | + */ |
|
47 | + const TABLE_NAME = 'user'; |
|
48 | + |
|
49 | + /** |
|
50 | + * The related Propel class for this table |
|
51 | + */ |
|
52 | + const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\User'; |
|
53 | + |
|
54 | + /** |
|
55 | + * A class that can be returned by this tableMap |
|
56 | + */ |
|
57 | + const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.User'; |
|
58 | + |
|
59 | + /** |
|
60 | + * The total number of columns |
|
61 | + */ |
|
62 | + const NUM_COLUMNS = 3; |
|
63 | + |
|
64 | + /** |
|
65 | + * The number of lazy-loaded columns |
|
66 | + */ |
|
67 | + const NUM_LAZY_LOAD_COLUMNS = 0; |
|
68 | + |
|
69 | + /** |
|
70 | + * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
|
71 | + */ |
|
72 | + const NUM_HYDRATE_COLUMNS = 3; |
|
73 | + |
|
74 | + /** |
|
75 | + * the column name for the id field |
|
76 | + */ |
|
77 | + const COL_ID = 'user.id'; |
|
78 | + |
|
79 | + /** |
|
80 | + * the column name for the instance_name field |
|
81 | + */ |
|
82 | + const COL_INSTANCE_NAME = 'user.instance_name'; |
|
83 | + |
|
84 | + /** |
|
85 | + * the column name for the name field |
|
86 | + */ |
|
87 | + const COL_NAME = 'user.name'; |
|
88 | + |
|
89 | + /** |
|
90 | + * The default string format for model objects of the related table |
|
91 | + */ |
|
92 | + const DEFAULT_STRING_FORMAT = 'YAML'; |
|
93 | + |
|
94 | + /** |
|
95 | + * holds an array of fieldnames |
|
96 | + * |
|
97 | + * first dimension keys are the type constants |
|
98 | + * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
|
99 | + */ |
|
100 | + protected static $fieldNames = array ( |
|
101 | + self::TYPE_PHPNAME => array('Id', 'InstanceName', 'Name', ), |
|
102 | + self::TYPE_CAMELNAME => array('id', 'instanceName', 'name', ), |
|
103 | + self::TYPE_COLNAME => array(UserTableMap::COL_ID, UserTableMap::COL_INSTANCE_NAME, UserTableMap::COL_NAME, ), |
|
104 | + self::TYPE_FIELDNAME => array('id', 'instance_name', 'name', ), |
|
105 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
106 | + ); |
|
107 | + |
|
108 | + /** |
|
109 | + * holds an array of keys for quick access to the fieldnames array |
|
110 | + * |
|
111 | + * first dimension keys are the type constants |
|
112 | + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
|
113 | + */ |
|
114 | + protected static $fieldKeys = array ( |
|
115 | + self::TYPE_PHPNAME => array('Id' => 0, 'InstanceName' => 1, 'Name' => 2, ), |
|
116 | + self::TYPE_CAMELNAME => array('id' => 0, 'instanceName' => 1, 'name' => 2, ), |
|
117 | + self::TYPE_COLNAME => array(UserTableMap::COL_ID => 0, UserTableMap::COL_INSTANCE_NAME => 1, UserTableMap::COL_NAME => 2, ), |
|
118 | + self::TYPE_FIELDNAME => array('id' => 0, 'instance_name' => 1, 'name' => 2, ), |
|
119 | + self::TYPE_NUM => array(0, 1, 2, ) |
|
120 | + ); |
|
121 | + |
|
122 | + /** |
|
123 | + * Initialize the table attributes and columns |
|
124 | + * Relations are not initialized by this method since they are lazy loaded |
|
125 | + * |
|
126 | + * @return void |
|
127 | + * @throws PropelException |
|
128 | + */ |
|
129 | + public function initialize() |
|
130 | + { |
|
131 | + // attributes |
|
132 | + $this->setName('user'); |
|
133 | + $this->setPhpName('User'); |
|
134 | + $this->setIdentifierQuoting(false); |
|
135 | + $this->setClassName('\\Jalle19\\StatusManager\\Database\\User'); |
|
136 | + $this->setPackage('Jalle19.StatusManager.Database'); |
|
137 | + $this->setUseIdGenerator(true); |
|
138 | + // columns |
|
139 | + $this->addPrimaryKey('id', 'Id', 'INTEGER', true, null, null); |
|
140 | + $this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
|
141 | + $this->addColumn('name', 'Name', 'VARCHAR', true, 255, null); |
|
142 | + } // initialize() |
|
143 | + |
|
144 | + /** |
|
145 | + * Build the RelationMap objects for this table relationships |
|
146 | + */ |
|
147 | + public function buildRelations() |
|
148 | + { |
|
149 | + $this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
|
150 | 150 | 0 => |
151 | 151 | array ( |
152 | - 0 => ':instance_name', |
|
153 | - 1 => ':name', |
|
152 | + 0 => ':instance_name', |
|
153 | + 1 => ':name', |
|
154 | 154 | ), |
155 | 155 | ), null, null, null, false); |
156 | - $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
156 | + $this->addRelation('Connection', '\\Jalle19\\StatusManager\\Database\\Connection', RelationMap::ONE_TO_MANY, array ( |
|
157 | 157 | 0 => |
158 | 158 | array ( |
159 | - 0 => ':user_id', |
|
160 | - 1 => ':id', |
|
159 | + 0 => ':user_id', |
|
160 | + 1 => ':id', |
|
161 | 161 | ), |
162 | 162 | ), null, null, 'Connections', false); |
163 | - $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
163 | + $this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
|
164 | 164 | 0 => |
165 | 165 | array ( |
166 | - 0 => ':user_id', |
|
167 | - 1 => ':id', |
|
166 | + 0 => ':user_id', |
|
167 | + 1 => ':id', |
|
168 | 168 | ), |
169 | 169 | ), null, null, 'Subscriptions', false); |
170 | - } // buildRelations() |
|
171 | - |
|
172 | - /** |
|
173 | - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
174 | - * |
|
175 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
176 | - * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
177 | - * |
|
178 | - * @param array $row resultset row. |
|
179 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
180 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
181 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
182 | - * |
|
183 | - * @return string The primary key hash of the row |
|
184 | - */ |
|
185 | - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
186 | - { |
|
187 | - // If the PK cannot be derived from the row, return NULL. |
|
188 | - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
189 | - return null; |
|
190 | - } |
|
191 | - |
|
192 | - return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Retrieves the primary key from the DB resultset row |
|
197 | - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
198 | - * a multi-column primary key, an array of the primary key columns will be returned. |
|
199 | - * |
|
200 | - * @param array $row resultset row. |
|
201 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
202 | - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
203 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
204 | - * |
|
205 | - * @return mixed The primary key of the row |
|
206 | - */ |
|
207 | - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
208 | - { |
|
209 | - return (int) $row[ |
|
210 | - $indexType == TableMap::TYPE_NUM |
|
211 | - ? 0 + $offset |
|
212 | - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
213 | - ]; |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * The class that the tableMap will make instances of. |
|
218 | - * |
|
219 | - * If $withPrefix is true, the returned path |
|
220 | - * uses a dot-path notation which is translated into a path |
|
221 | - * relative to a location on the PHP include_path. |
|
222 | - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
223 | - * |
|
224 | - * @param boolean $withPrefix Whether or not to return the path with the class name |
|
225 | - * @return string path.to.ClassName |
|
226 | - */ |
|
227 | - public static function getOMClass($withPrefix = true) |
|
228 | - { |
|
229 | - return $withPrefix ? UserTableMap::CLASS_DEFAULT : UserTableMap::OM_CLASS; |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Populates an object of the default type or an object that inherit from the default. |
|
234 | - * |
|
235 | - * @param array $row row returned by DataFetcher->fetch(). |
|
236 | - * @param int $offset The 0-based offset for reading from the resultset row. |
|
237 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
170 | + } // buildRelations() |
|
171 | + |
|
172 | + /** |
|
173 | + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
|
174 | + * |
|
175 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
176 | + * a multi-column primary key, a serialize()d version of the primary key will be returned. |
|
177 | + * |
|
178 | + * @param array $row resultset row. |
|
179 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
180 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
181 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
182 | + * |
|
183 | + * @return string The primary key hash of the row |
|
184 | + */ |
|
185 | + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
186 | + { |
|
187 | + // If the PK cannot be derived from the row, return NULL. |
|
188 | + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
|
189 | + return null; |
|
190 | + } |
|
191 | + |
|
192 | + return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Retrieves the primary key from the DB resultset row |
|
197 | + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
|
198 | + * a multi-column primary key, an array of the primary key columns will be returned. |
|
199 | + * |
|
200 | + * @param array $row resultset row. |
|
201 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
202 | + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
203 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
|
204 | + * |
|
205 | + * @return mixed The primary key of the row |
|
206 | + */ |
|
207 | + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
208 | + { |
|
209 | + return (int) $row[ |
|
210 | + $indexType == TableMap::TYPE_NUM |
|
211 | + ? 0 + $offset |
|
212 | + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) |
|
213 | + ]; |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * The class that the tableMap will make instances of. |
|
218 | + * |
|
219 | + * If $withPrefix is true, the returned path |
|
220 | + * uses a dot-path notation which is translated into a path |
|
221 | + * relative to a location on the PHP include_path. |
|
222 | + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
|
223 | + * |
|
224 | + * @param boolean $withPrefix Whether or not to return the path with the class name |
|
225 | + * @return string path.to.ClassName |
|
226 | + */ |
|
227 | + public static function getOMClass($withPrefix = true) |
|
228 | + { |
|
229 | + return $withPrefix ? UserTableMap::CLASS_DEFAULT : UserTableMap::OM_CLASS; |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Populates an object of the default type or an object that inherit from the default. |
|
234 | + * |
|
235 | + * @param array $row row returned by DataFetcher->fetch(). |
|
236 | + * @param int $offset The 0-based offset for reading from the resultset row. |
|
237 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
238 | 238 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
239 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
240 | - * |
|
241 | - * @throws PropelException Any exceptions caught during processing will be |
|
242 | - * rethrown wrapped into a PropelException. |
|
243 | - * @return array (User object, last column rank) |
|
244 | - */ |
|
245 | - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
246 | - { |
|
247 | - $key = UserTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
248 | - if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
249 | - // We no longer rehydrate the object, since this can cause data loss. |
|
250 | - // See http://www.propelorm.org/ticket/509 |
|
251 | - // $obj->hydrate($row, $offset, true); // rehydrate |
|
252 | - $col = $offset + UserTableMap::NUM_HYDRATE_COLUMNS; |
|
253 | - } else { |
|
254 | - $cls = UserTableMap::OM_CLASS; |
|
255 | - /** @var User $obj */ |
|
256 | - $obj = new $cls(); |
|
257 | - $col = $obj->hydrate($row, $offset, false, $indexType); |
|
258 | - UserTableMap::addInstanceToPool($obj, $key); |
|
259 | - } |
|
260 | - |
|
261 | - return array($obj, $col); |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * The returned array will contain objects of the default type or |
|
266 | - * objects that inherit from the default. |
|
267 | - * |
|
268 | - * @param DataFetcherInterface $dataFetcher |
|
269 | - * @return array |
|
270 | - * @throws PropelException Any exceptions caught during processing will be |
|
271 | - * rethrown wrapped into a PropelException. |
|
272 | - */ |
|
273 | - public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
274 | - { |
|
275 | - $results = array(); |
|
276 | - |
|
277 | - // set the class once to avoid overhead in the loop |
|
278 | - $cls = static::getOMClass(false); |
|
279 | - // populate the object(s) |
|
280 | - while ($row = $dataFetcher->fetch()) { |
|
281 | - $key = UserTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
282 | - if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
283 | - // We no longer rehydrate the object, since this can cause data loss. |
|
284 | - // See http://www.propelorm.org/ticket/509 |
|
285 | - // $obj->hydrate($row, 0, true); // rehydrate |
|
286 | - $results[] = $obj; |
|
287 | - } else { |
|
288 | - /** @var User $obj */ |
|
289 | - $obj = new $cls(); |
|
290 | - $obj->hydrate($row); |
|
291 | - $results[] = $obj; |
|
292 | - UserTableMap::addInstanceToPool($obj, $key); |
|
293 | - } // if key exists |
|
294 | - } |
|
295 | - |
|
296 | - return $results; |
|
297 | - } |
|
298 | - /** |
|
299 | - * Add all the columns needed to create a new object. |
|
300 | - * |
|
301 | - * Note: any columns that were marked with lazyLoad="true" in the |
|
302 | - * XML schema will not be added to the select list and only loaded |
|
303 | - * on demand. |
|
304 | - * |
|
305 | - * @param Criteria $criteria object containing the columns to add. |
|
306 | - * @param string $alias optional table alias |
|
307 | - * @throws PropelException Any exceptions caught during processing will be |
|
308 | - * rethrown wrapped into a PropelException. |
|
309 | - */ |
|
310 | - public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
311 | - { |
|
312 | - if (null === $alias) { |
|
313 | - $criteria->addSelectColumn(UserTableMap::COL_ID); |
|
314 | - $criteria->addSelectColumn(UserTableMap::COL_INSTANCE_NAME); |
|
315 | - $criteria->addSelectColumn(UserTableMap::COL_NAME); |
|
316 | - } else { |
|
317 | - $criteria->addSelectColumn($alias . '.id'); |
|
318 | - $criteria->addSelectColumn($alias . '.instance_name'); |
|
319 | - $criteria->addSelectColumn($alias . '.name'); |
|
320 | - } |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Returns the TableMap related to this object. |
|
325 | - * This method is not needed for general use but a specific application could have a need. |
|
326 | - * @return TableMap |
|
327 | - * @throws PropelException Any exceptions caught during processing will be |
|
328 | - * rethrown wrapped into a PropelException. |
|
329 | - */ |
|
330 | - public static function getTableMap() |
|
331 | - { |
|
332 | - return Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME)->getTable(UserTableMap::TABLE_NAME); |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * Add a TableMap instance to the database for this tableMap class. |
|
337 | - */ |
|
338 | - public static function buildTableMap() |
|
339 | - { |
|
340 | - $dbMap = Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME); |
|
341 | - if (!$dbMap->hasTable(UserTableMap::TABLE_NAME)) { |
|
342 | - $dbMap->addTableObject(new UserTableMap()); |
|
343 | - } |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Performs a DELETE on the database, given a User or Criteria object OR a primary key value. |
|
348 | - * |
|
349 | - * @param mixed $values Criteria or User object or primary key or array of primary keys |
|
350 | - * which is used to create the DELETE statement |
|
351 | - * @param ConnectionInterface $con the connection to use |
|
352 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
353 | - * if supported by native driver or if emulated using Propel. |
|
354 | - * @throws PropelException Any exceptions caught during processing will be |
|
355 | - * rethrown wrapped into a PropelException. |
|
356 | - */ |
|
357 | - public static function doDelete($values, ConnectionInterface $con = null) |
|
358 | - { |
|
359 | - if (null === $con) { |
|
360 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
361 | - } |
|
362 | - |
|
363 | - if ($values instanceof Criteria) { |
|
364 | - // rename for clarity |
|
365 | - $criteria = $values; |
|
366 | - } elseif ($values instanceof \Jalle19\StatusManager\Database\User) { // it's a model object |
|
367 | - // create criteria based on pk values |
|
368 | - $criteria = $values->buildPkeyCriteria(); |
|
369 | - } else { // it's a primary key, or an array of pks |
|
370 | - $criteria = new Criteria(UserTableMap::DATABASE_NAME); |
|
371 | - $criteria->add(UserTableMap::COL_ID, (array) $values, Criteria::IN); |
|
372 | - } |
|
373 | - |
|
374 | - $query = UserQuery::create()->mergeWith($criteria); |
|
375 | - |
|
376 | - if ($values instanceof Criteria) { |
|
377 | - UserTableMap::clearInstancePool(); |
|
378 | - } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
379 | - foreach ((array) $values as $singleval) { |
|
380 | - UserTableMap::removeInstanceFromPool($singleval); |
|
381 | - } |
|
382 | - } |
|
383 | - |
|
384 | - return $query->delete($con); |
|
385 | - } |
|
386 | - |
|
387 | - /** |
|
388 | - * Deletes all rows from the user table. |
|
389 | - * |
|
390 | - * @param ConnectionInterface $con the connection to use |
|
391 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
392 | - */ |
|
393 | - public static function doDeleteAll(ConnectionInterface $con = null) |
|
394 | - { |
|
395 | - return UserQuery::create()->doDeleteAll($con); |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * Performs an INSERT on the database, given a User or Criteria object. |
|
400 | - * |
|
401 | - * @param mixed $criteria Criteria or User object containing data that is used to create the INSERT statement. |
|
402 | - * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
403 | - * @return mixed The new primary key. |
|
404 | - * @throws PropelException Any exceptions caught during processing will be |
|
405 | - * rethrown wrapped into a PropelException. |
|
406 | - */ |
|
407 | - public static function doInsert($criteria, ConnectionInterface $con = null) |
|
408 | - { |
|
409 | - if (null === $con) { |
|
410 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
411 | - } |
|
412 | - |
|
413 | - if ($criteria instanceof Criteria) { |
|
414 | - $criteria = clone $criteria; // rename for clarity |
|
415 | - } else { |
|
416 | - $criteria = $criteria->buildCriteria(); // build Criteria from User object |
|
417 | - } |
|
418 | - |
|
419 | - if ($criteria->containsKey(UserTableMap::COL_ID) && $criteria->keyContainsValue(UserTableMap::COL_ID) ) { |
|
420 | - throw new PropelException('Cannot insert a value for auto-increment primary key ('.UserTableMap::COL_ID.')'); |
|
421 | - } |
|
422 | - |
|
423 | - |
|
424 | - // Set the correct dbName |
|
425 | - $query = UserQuery::create()->mergeWith($criteria); |
|
426 | - |
|
427 | - // use transaction because $criteria could contain info |
|
428 | - // for more than one table (I guess, conceivably) |
|
429 | - return $con->transaction(function () use ($con, $query) { |
|
430 | - return $query->doInsert($con); |
|
431 | - }); |
|
432 | - } |
|
239 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
240 | + * |
|
241 | + * @throws PropelException Any exceptions caught during processing will be |
|
242 | + * rethrown wrapped into a PropelException. |
|
243 | + * @return array (User object, last column rank) |
|
244 | + */ |
|
245 | + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
246 | + { |
|
247 | + $key = UserTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
|
248 | + if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
249 | + // We no longer rehydrate the object, since this can cause data loss. |
|
250 | + // See http://www.propelorm.org/ticket/509 |
|
251 | + // $obj->hydrate($row, $offset, true); // rehydrate |
|
252 | + $col = $offset + UserTableMap::NUM_HYDRATE_COLUMNS; |
|
253 | + } else { |
|
254 | + $cls = UserTableMap::OM_CLASS; |
|
255 | + /** @var User $obj */ |
|
256 | + $obj = new $cls(); |
|
257 | + $col = $obj->hydrate($row, $offset, false, $indexType); |
|
258 | + UserTableMap::addInstanceToPool($obj, $key); |
|
259 | + } |
|
260 | + |
|
261 | + return array($obj, $col); |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * The returned array will contain objects of the default type or |
|
266 | + * objects that inherit from the default. |
|
267 | + * |
|
268 | + * @param DataFetcherInterface $dataFetcher |
|
269 | + * @return array |
|
270 | + * @throws PropelException Any exceptions caught during processing will be |
|
271 | + * rethrown wrapped into a PropelException. |
|
272 | + */ |
|
273 | + public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
274 | + { |
|
275 | + $results = array(); |
|
276 | + |
|
277 | + // set the class once to avoid overhead in the loop |
|
278 | + $cls = static::getOMClass(false); |
|
279 | + // populate the object(s) |
|
280 | + while ($row = $dataFetcher->fetch()) { |
|
281 | + $key = UserTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
|
282 | + if (null !== ($obj = UserTableMap::getInstanceFromPool($key))) { |
|
283 | + // We no longer rehydrate the object, since this can cause data loss. |
|
284 | + // See http://www.propelorm.org/ticket/509 |
|
285 | + // $obj->hydrate($row, 0, true); // rehydrate |
|
286 | + $results[] = $obj; |
|
287 | + } else { |
|
288 | + /** @var User $obj */ |
|
289 | + $obj = new $cls(); |
|
290 | + $obj->hydrate($row); |
|
291 | + $results[] = $obj; |
|
292 | + UserTableMap::addInstanceToPool($obj, $key); |
|
293 | + } // if key exists |
|
294 | + } |
|
295 | + |
|
296 | + return $results; |
|
297 | + } |
|
298 | + /** |
|
299 | + * Add all the columns needed to create a new object. |
|
300 | + * |
|
301 | + * Note: any columns that were marked with lazyLoad="true" in the |
|
302 | + * XML schema will not be added to the select list and only loaded |
|
303 | + * on demand. |
|
304 | + * |
|
305 | + * @param Criteria $criteria object containing the columns to add. |
|
306 | + * @param string $alias optional table alias |
|
307 | + * @throws PropelException Any exceptions caught during processing will be |
|
308 | + * rethrown wrapped into a PropelException. |
|
309 | + */ |
|
310 | + public static function addSelectColumns(Criteria $criteria, $alias = null) |
|
311 | + { |
|
312 | + if (null === $alias) { |
|
313 | + $criteria->addSelectColumn(UserTableMap::COL_ID); |
|
314 | + $criteria->addSelectColumn(UserTableMap::COL_INSTANCE_NAME); |
|
315 | + $criteria->addSelectColumn(UserTableMap::COL_NAME); |
|
316 | + } else { |
|
317 | + $criteria->addSelectColumn($alias . '.id'); |
|
318 | + $criteria->addSelectColumn($alias . '.instance_name'); |
|
319 | + $criteria->addSelectColumn($alias . '.name'); |
|
320 | + } |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * Returns the TableMap related to this object. |
|
325 | + * This method is not needed for general use but a specific application could have a need. |
|
326 | + * @return TableMap |
|
327 | + * @throws PropelException Any exceptions caught during processing will be |
|
328 | + * rethrown wrapped into a PropelException. |
|
329 | + */ |
|
330 | + public static function getTableMap() |
|
331 | + { |
|
332 | + return Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME)->getTable(UserTableMap::TABLE_NAME); |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * Add a TableMap instance to the database for this tableMap class. |
|
337 | + */ |
|
338 | + public static function buildTableMap() |
|
339 | + { |
|
340 | + $dbMap = Propel::getServiceContainer()->getDatabaseMap(UserTableMap::DATABASE_NAME); |
|
341 | + if (!$dbMap->hasTable(UserTableMap::TABLE_NAME)) { |
|
342 | + $dbMap->addTableObject(new UserTableMap()); |
|
343 | + } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Performs a DELETE on the database, given a User or Criteria object OR a primary key value. |
|
348 | + * |
|
349 | + * @param mixed $values Criteria or User object or primary key or array of primary keys |
|
350 | + * which is used to create the DELETE statement |
|
351 | + * @param ConnectionInterface $con the connection to use |
|
352 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
353 | + * if supported by native driver or if emulated using Propel. |
|
354 | + * @throws PropelException Any exceptions caught during processing will be |
|
355 | + * rethrown wrapped into a PropelException. |
|
356 | + */ |
|
357 | + public static function doDelete($values, ConnectionInterface $con = null) |
|
358 | + { |
|
359 | + if (null === $con) { |
|
360 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
361 | + } |
|
362 | + |
|
363 | + if ($values instanceof Criteria) { |
|
364 | + // rename for clarity |
|
365 | + $criteria = $values; |
|
366 | + } elseif ($values instanceof \Jalle19\StatusManager\Database\User) { // it's a model object |
|
367 | + // create criteria based on pk values |
|
368 | + $criteria = $values->buildPkeyCriteria(); |
|
369 | + } else { // it's a primary key, or an array of pks |
|
370 | + $criteria = new Criteria(UserTableMap::DATABASE_NAME); |
|
371 | + $criteria->add(UserTableMap::COL_ID, (array) $values, Criteria::IN); |
|
372 | + } |
|
373 | + |
|
374 | + $query = UserQuery::create()->mergeWith($criteria); |
|
375 | + |
|
376 | + if ($values instanceof Criteria) { |
|
377 | + UserTableMap::clearInstancePool(); |
|
378 | + } elseif (!is_object($values)) { // it's a primary key, or an array of pks |
|
379 | + foreach ((array) $values as $singleval) { |
|
380 | + UserTableMap::removeInstanceFromPool($singleval); |
|
381 | + } |
|
382 | + } |
|
383 | + |
|
384 | + return $query->delete($con); |
|
385 | + } |
|
386 | + |
|
387 | + /** |
|
388 | + * Deletes all rows from the user table. |
|
389 | + * |
|
390 | + * @param ConnectionInterface $con the connection to use |
|
391 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
392 | + */ |
|
393 | + public static function doDeleteAll(ConnectionInterface $con = null) |
|
394 | + { |
|
395 | + return UserQuery::create()->doDeleteAll($con); |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * Performs an INSERT on the database, given a User or Criteria object. |
|
400 | + * |
|
401 | + * @param mixed $criteria Criteria or User object containing data that is used to create the INSERT statement. |
|
402 | + * @param ConnectionInterface $con the ConnectionInterface connection to use |
|
403 | + * @return mixed The new primary key. |
|
404 | + * @throws PropelException Any exceptions caught during processing will be |
|
405 | + * rethrown wrapped into a PropelException. |
|
406 | + */ |
|
407 | + public static function doInsert($criteria, ConnectionInterface $con = null) |
|
408 | + { |
|
409 | + if (null === $con) { |
|
410 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
411 | + } |
|
412 | + |
|
413 | + if ($criteria instanceof Criteria) { |
|
414 | + $criteria = clone $criteria; // rename for clarity |
|
415 | + } else { |
|
416 | + $criteria = $criteria->buildCriteria(); // build Criteria from User object |
|
417 | + } |
|
418 | + |
|
419 | + if ($criteria->containsKey(UserTableMap::COL_ID) && $criteria->keyContainsValue(UserTableMap::COL_ID) ) { |
|
420 | + throw new PropelException('Cannot insert a value for auto-increment primary key ('.UserTableMap::COL_ID.')'); |
|
421 | + } |
|
422 | + |
|
423 | + |
|
424 | + // Set the correct dbName |
|
425 | + $query = UserQuery::create()->mergeWith($criteria); |
|
426 | + |
|
427 | + // use transaction because $criteria could contain info |
|
428 | + // for more than one table (I guess, conceivably) |
|
429 | + return $con->transaction(function () use ($con, $query) { |
|
430 | + return $query->doInsert($con); |
|
431 | + }); |
|
432 | + } |
|
433 | 433 | |
434 | 434 | } // UserTableMap |
435 | 435 | // This is the static code needed to register the TableMap for this table with the main Propel class. |
@@ -7,37 +7,37 @@ discard block |
||
7 | 7 | */ |
8 | 8 | class PropelMigration_1455268734 |
9 | 9 | { |
10 | - public $comment = ''; |
|
10 | + public $comment = ''; |
|
11 | 11 | |
12 | - public function preUp($manager) |
|
13 | - { |
|
14 | - // add the pre-migration code here |
|
15 | - } |
|
12 | + public function preUp($manager) |
|
13 | + { |
|
14 | + // add the pre-migration code here |
|
15 | + } |
|
16 | 16 | |
17 | - public function postUp($manager) |
|
18 | - { |
|
19 | - // add the post-migration code here |
|
20 | - } |
|
17 | + public function postUp($manager) |
|
18 | + { |
|
19 | + // add the post-migration code here |
|
20 | + } |
|
21 | 21 | |
22 | - public function preDown($manager) |
|
23 | - { |
|
24 | - // add the pre-migration code here |
|
25 | - } |
|
22 | + public function preDown($manager) |
|
23 | + { |
|
24 | + // add the pre-migration code here |
|
25 | + } |
|
26 | 26 | |
27 | - public function postDown($manager) |
|
28 | - { |
|
29 | - // add the post-migration code here |
|
30 | - } |
|
27 | + public function postDown($manager) |
|
28 | + { |
|
29 | + // add the post-migration code here |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Get the SQL statements for the Up migration |
|
34 | - * |
|
35 | - * @return array list of the SQL strings to execute for the Up migration |
|
36 | - * the keys being the datasources |
|
37 | - */ |
|
38 | - public function getUpSQL() |
|
39 | - { |
|
40 | - return array ( |
|
32 | + /** |
|
33 | + * Get the SQL statements for the Up migration |
|
34 | + * |
|
35 | + * @return array list of the SQL strings to execute for the Up migration |
|
36 | + * the keys being the datasources |
|
37 | + */ |
|
38 | + public function getUpSQL() |
|
39 | + { |
|
40 | + return array ( |
|
41 | 41 | 'tvheadend_status_manager' => ' |
42 | 42 | PRAGMA foreign_keys = OFF; |
43 | 43 | |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | PRAGMA foreign_keys = ON; |
61 | 61 | ', |
62 | 62 | ); |
63 | - } |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Get the SQL statements for the Down migration |
|
67 | - * |
|
68 | - * @return array list of the SQL strings to execute for the Down migration |
|
69 | - * the keys being the datasources |
|
70 | - */ |
|
71 | - public function getDownSQL() |
|
72 | - { |
|
73 | - return array ( |
|
65 | + /** |
|
66 | + * Get the SQL statements for the Down migration |
|
67 | + * |
|
68 | + * @return array list of the SQL strings to execute for the Down migration |
|
69 | + * the keys being the datasources |
|
70 | + */ |
|
71 | + public function getDownSQL() |
|
72 | + { |
|
73 | + return array ( |
|
74 | 74 | 'tvheadend_status_manager' => ' |
75 | 75 | PRAGMA foreign_keys = OFF; |
76 | 76 | |
@@ -79,6 +79,6 @@ discard block |
||
79 | 79 | PRAGMA foreign_keys = ON; |
80 | 80 | ', |
81 | 81 | ); |
82 | - } |
|
82 | + } |
|
83 | 83 | |
84 | 84 | } |
@@ -7,37 +7,37 @@ discard block |
||
7 | 7 | */ |
8 | 8 | class PropelMigration_1455269307 |
9 | 9 | { |
10 | - public $comment = ''; |
|
10 | + public $comment = ''; |
|
11 | 11 | |
12 | - public function preUp($manager) |
|
13 | - { |
|
14 | - // add the pre-migration code here |
|
15 | - } |
|
12 | + public function preUp($manager) |
|
13 | + { |
|
14 | + // add the pre-migration code here |
|
15 | + } |
|
16 | 16 | |
17 | - public function postUp($manager) |
|
18 | - { |
|
19 | - // add the post-migration code here |
|
20 | - } |
|
17 | + public function postUp($manager) |
|
18 | + { |
|
19 | + // add the post-migration code here |
|
20 | + } |
|
21 | 21 | |
22 | - public function preDown($manager) |
|
23 | - { |
|
24 | - // add the pre-migration code here |
|
25 | - } |
|
22 | + public function preDown($manager) |
|
23 | + { |
|
24 | + // add the pre-migration code here |
|
25 | + } |
|
26 | 26 | |
27 | - public function postDown($manager) |
|
28 | - { |
|
29 | - // add the post-migration code here |
|
30 | - } |
|
27 | + public function postDown($manager) |
|
28 | + { |
|
29 | + // add the post-migration code here |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * Get the SQL statements for the Up migration |
|
34 | - * |
|
35 | - * @return array list of the SQL strings to execute for the Up migration |
|
36 | - * the keys being the datasources |
|
37 | - */ |
|
38 | - public function getUpSQL() |
|
39 | - { |
|
40 | - return array ( |
|
32 | + /** |
|
33 | + * Get the SQL statements for the Up migration |
|
34 | + * |
|
35 | + * @return array list of the SQL strings to execute for the Up migration |
|
36 | + * the keys being the datasources |
|
37 | + */ |
|
38 | + public function getUpSQL() |
|
39 | + { |
|
40 | + return array ( |
|
41 | 41 | 'tvheadend_status_manager' => ' |
42 | 42 | PRAGMA foreign_keys = OFF; |
43 | 43 | |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | PRAGMA foreign_keys = ON; |
47 | 47 | ', |
48 | 48 | ); |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * Get the SQL statements for the Down migration |
|
53 | - * |
|
54 | - * @return array list of the SQL strings to execute for the Down migration |
|
55 | - * the keys being the datasources |
|
56 | - */ |
|
57 | - public function getDownSQL() |
|
58 | - { |
|
59 | - return array ( |
|
51 | + /** |
|
52 | + * Get the SQL statements for the Down migration |
|
53 | + * |
|
54 | + * @return array list of the SQL strings to execute for the Down migration |
|
55 | + * the keys being the datasources |
|
56 | + */ |
|
57 | + public function getDownSQL() |
|
58 | + { |
|
59 | + return array ( |
|
60 | 60 | 'tvheadend_status_manager' => ' |
61 | 61 | PRAGMA foreign_keys = OFF; |
62 | 62 | |
@@ -86,6 +86,6 @@ discard block |
||
86 | 86 | PRAGMA foreign_keys = ON; |
87 | 87 | ', |
88 | 88 | ); |
89 | - } |
|
89 | + } |
|
90 | 90 | |
91 | 91 | } |
92 | 92 | \ No newline at end of file |