Completed
Branch master (a15a51)
by Sam
01:56
created

SubscriptionQuery   F

Complexity

Total Complexity 134

Size/Duplication

Total Lines 935
Duplicated Lines 49.73 %

Coupling/Cohesion

Components 3
Dependencies 17

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 134
lcom 3
cbo 17
dl 465
loc 935
rs 1.263
c 2
b 0
f 0

How to fix   Duplicated Code    Complexity   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like SubscriptionQuery often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use SubscriptionQuery, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Jalle19\StatusManager\Database\Base;
4
5
use \Exception;
6
use \PDO;
7
use Jalle19\StatusManager\Database\Subscription as ChildSubscription;
8
use Jalle19\StatusManager\Database\SubscriptionQuery as ChildSubscriptionQuery;
9
use Jalle19\StatusManager\Database\Map\SubscriptionTableMap;
10
use Propel\Runtime\Propel;
11
use Propel\Runtime\ActiveQuery\Criteria;
12
use Propel\Runtime\ActiveQuery\ModelCriteria;
13
use Propel\Runtime\ActiveQuery\ModelJoin;
14
use Propel\Runtime\Collection\ObjectCollection;
15
use Propel\Runtime\Connection\ConnectionInterface;
16
use Propel\Runtime\Exception\PropelException;
17
18
/**
19
 * Base class that represents a query for the 'subscription' table.
20
 *
21
 *
22
 *
23
 * @method     ChildSubscriptionQuery orderById($order = Criteria::ASC) Order by the id column
24
 * @method     ChildSubscriptionQuery orderByInstanceName($order = Criteria::ASC) Order by the instance_name column
25
 * @method     ChildSubscriptionQuery orderByInputUuid($order = Criteria::ASC) Order by the input_uuid column
26
 * @method     ChildSubscriptionQuery orderByUserId($order = Criteria::ASC) Order by the user_id column
27
 * @method     ChildSubscriptionQuery orderByChannelId($order = Criteria::ASC) Order by the channel_id column
28
 * @method     ChildSubscriptionQuery orderBySubscriptionId($order = Criteria::ASC) Order by the subscription_id column
29
 * @method     ChildSubscriptionQuery orderByStarted($order = Criteria::ASC) Order by the started column
30
 * @method     ChildSubscriptionQuery orderByStopped($order = Criteria::ASC) Order by the stopped column
31
 * @method     ChildSubscriptionQuery orderByTitle($order = Criteria::ASC) Order by the title column
32
 * @method     ChildSubscriptionQuery orderByService($order = Criteria::ASC) Order by the service column
33
 *
34
 * @method     ChildSubscriptionQuery groupById() Group by the id column
35
 * @method     ChildSubscriptionQuery groupByInstanceName() Group by the instance_name column
36
 * @method     ChildSubscriptionQuery groupByInputUuid() Group by the input_uuid column
37
 * @method     ChildSubscriptionQuery groupByUserId() Group by the user_id column
38
 * @method     ChildSubscriptionQuery groupByChannelId() Group by the channel_id column
39
 * @method     ChildSubscriptionQuery groupBySubscriptionId() Group by the subscription_id column
40
 * @method     ChildSubscriptionQuery groupByStarted() Group by the started column
41
 * @method     ChildSubscriptionQuery groupByStopped() Group by the stopped column
42
 * @method     ChildSubscriptionQuery groupByTitle() Group by the title column
43
 * @method     ChildSubscriptionQuery groupByService() Group by the service column
44
 *
45
 * @method     ChildSubscriptionQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
46
 * @method     ChildSubscriptionQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
47
 * @method     ChildSubscriptionQuery innerJoin($relation) Adds a INNER JOIN clause to the query
48
 *
49
 * @method     ChildSubscriptionQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
50
 * @method     ChildSubscriptionQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
51
 * @method     ChildSubscriptionQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
52
 *
53
 * @method     ChildSubscriptionQuery leftJoinInstance($relationAlias = null) Adds a LEFT JOIN clause to the query using the Instance relation
54
 * @method     ChildSubscriptionQuery rightJoinInstance($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Instance relation
55
 * @method     ChildSubscriptionQuery innerJoinInstance($relationAlias = null) Adds a INNER JOIN clause to the query using the Instance relation
56
 *
57
 * @method     ChildSubscriptionQuery joinWithInstance($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Instance relation
58
 *
59
 * @method     ChildSubscriptionQuery leftJoinWithInstance() Adds a LEFT JOIN clause and with to the query using the Instance relation
60
 * @method     ChildSubscriptionQuery rightJoinWithInstance() Adds a RIGHT JOIN clause and with to the query using the Instance relation
61
 * @method     ChildSubscriptionQuery innerJoinWithInstance() Adds a INNER JOIN clause and with to the query using the Instance relation
62
 *
63
 * @method     ChildSubscriptionQuery leftJoinInput($relationAlias = null) Adds a LEFT JOIN clause to the query using the Input relation
64
 * @method     ChildSubscriptionQuery rightJoinInput($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Input relation
65
 * @method     ChildSubscriptionQuery innerJoinInput($relationAlias = null) Adds a INNER JOIN clause to the query using the Input relation
66
 *
67
 * @method     ChildSubscriptionQuery joinWithInput($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Input relation
68
 *
69
 * @method     ChildSubscriptionQuery leftJoinWithInput() Adds a LEFT JOIN clause and with to the query using the Input relation
70
 * @method     ChildSubscriptionQuery rightJoinWithInput() Adds a RIGHT JOIN clause and with to the query using the Input relation
71
 * @method     ChildSubscriptionQuery innerJoinWithInput() Adds a INNER JOIN clause and with to the query using the Input relation
72
 *
73
 * @method     ChildSubscriptionQuery leftJoinUser($relationAlias = null) Adds a LEFT JOIN clause to the query using the User relation
74
 * @method     ChildSubscriptionQuery rightJoinUser($relationAlias = null) Adds a RIGHT JOIN clause to the query using the User relation
75
 * @method     ChildSubscriptionQuery innerJoinUser($relationAlias = null) Adds a INNER JOIN clause to the query using the User relation
76
 *
77
 * @method     ChildSubscriptionQuery joinWithUser($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the User relation
78
 *
79
 * @method     ChildSubscriptionQuery leftJoinWithUser() Adds a LEFT JOIN clause and with to the query using the User relation
80
 * @method     ChildSubscriptionQuery rightJoinWithUser() Adds a RIGHT JOIN clause and with to the query using the User relation
81
 * @method     ChildSubscriptionQuery innerJoinWithUser() Adds a INNER JOIN clause and with to the query using the User relation
82
 *
83
 * @method     ChildSubscriptionQuery leftJoinChannel($relationAlias = null) Adds a LEFT JOIN clause to the query using the Channel relation
84
 * @method     ChildSubscriptionQuery rightJoinChannel($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Channel relation
85
 * @method     ChildSubscriptionQuery innerJoinChannel($relationAlias = null) Adds a INNER JOIN clause to the query using the Channel relation
86
 *
87
 * @method     ChildSubscriptionQuery joinWithChannel($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Channel relation
88
 *
89
 * @method     ChildSubscriptionQuery leftJoinWithChannel() Adds a LEFT JOIN clause and with to the query using the Channel relation
90
 * @method     ChildSubscriptionQuery rightJoinWithChannel() Adds a RIGHT JOIN clause and with to the query using the Channel relation
91
 * @method     ChildSubscriptionQuery innerJoinWithChannel() Adds a INNER JOIN clause and with to the query using the Channel relation
92
 *
93
 * @method     \Jalle19\StatusManager\Database\InstanceQuery|\Jalle19\StatusManager\Database\InputQuery|\Jalle19\StatusManager\Database\UserQuery|\Jalle19\StatusManager\Database\ChannelQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria
94
 *
95
 * @method     ChildSubscription findOne(ConnectionInterface $con = null) Return the first ChildSubscription matching the query
96
 * @method     ChildSubscription findOneOrCreate(ConnectionInterface $con = null) Return the first ChildSubscription matching the query, or a new ChildSubscription object populated from the query conditions when no match is found
97
 *
98
 * @method     ChildSubscription findOneById(int $id) Return the first ChildSubscription filtered by the id column
99
 * @method     ChildSubscription findOneByInstanceName(string $instance_name) Return the first ChildSubscription filtered by the instance_name column
100
 * @method     ChildSubscription findOneByInputUuid(string $input_uuid) Return the first ChildSubscription filtered by the input_uuid column
101
 * @method     ChildSubscription findOneByUserId(int $user_id) Return the first ChildSubscription filtered by the user_id column
102
 * @method     ChildSubscription findOneByChannelId(int $channel_id) Return the first ChildSubscription filtered by the channel_id column
103
 * @method     ChildSubscription findOneBySubscriptionId(int $subscription_id) Return the first ChildSubscription filtered by the subscription_id column
104
 * @method     ChildSubscription findOneByStarted(string $started) Return the first ChildSubscription filtered by the started column
105
 * @method     ChildSubscription findOneByStopped(string $stopped) Return the first ChildSubscription filtered by the stopped column
106
 * @method     ChildSubscription findOneByTitle(string $title) Return the first ChildSubscription filtered by the title column
107
 * @method     ChildSubscription findOneByService(string $service) Return the first ChildSubscription filtered by the service column *
108
109
 * @method     ChildSubscription requirePk($key, ConnectionInterface $con = null) Return the ChildSubscription by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
110
 * @method     ChildSubscription requireOne(ConnectionInterface $con = null) Return the first ChildSubscription matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
111
 *
112
 * @method     ChildSubscription requireOneById(int $id) Return the first ChildSubscription filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
113
 * @method     ChildSubscription requireOneByInstanceName(string $instance_name) Return the first ChildSubscription filtered by the instance_name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
114
 * @method     ChildSubscription requireOneByInputUuid(string $input_uuid) Return the first ChildSubscription filtered by the input_uuid column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
115
 * @method     ChildSubscription requireOneByUserId(int $user_id) Return the first ChildSubscription filtered by the user_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
116
 * @method     ChildSubscription requireOneByChannelId(int $channel_id) Return the first ChildSubscription filtered by the channel_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
117
 * @method     ChildSubscription requireOneBySubscriptionId(int $subscription_id) Return the first ChildSubscription filtered by the subscription_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
118
 * @method     ChildSubscription requireOneByStarted(string $started) Return the first ChildSubscription filtered by the started column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
119
 * @method     ChildSubscription requireOneByStopped(string $stopped) Return the first ChildSubscription filtered by the stopped column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
120
 * @method     ChildSubscription requireOneByTitle(string $title) Return the first ChildSubscription filtered by the title column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
121
 * @method     ChildSubscription requireOneByService(string $service) Return the first ChildSubscription filtered by the service column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
122
 *
123
 * @method     ChildSubscription[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildSubscription objects based on current ModelCriteria
124
 * @method     ChildSubscription[]|ObjectCollection findById(int $id) Return ChildSubscription objects filtered by the id column
125
 * @method     ChildSubscription[]|ObjectCollection findByInstanceName(string $instance_name) Return ChildSubscription objects filtered by the instance_name column
126
 * @method     ChildSubscription[]|ObjectCollection findByInputUuid(string $input_uuid) Return ChildSubscription objects filtered by the input_uuid column
127
 * @method     ChildSubscription[]|ObjectCollection findByUserId(int $user_id) Return ChildSubscription objects filtered by the user_id column
128
 * @method     ChildSubscription[]|ObjectCollection findByChannelId(int $channel_id) Return ChildSubscription objects filtered by the channel_id column
129
 * @method     ChildSubscription[]|ObjectCollection findBySubscriptionId(int $subscription_id) Return ChildSubscription objects filtered by the subscription_id column
130
 * @method     ChildSubscription[]|ObjectCollection findByStarted(string $started) Return ChildSubscription objects filtered by the started column
131
 * @method     ChildSubscription[]|ObjectCollection findByStopped(string $stopped) Return ChildSubscription objects filtered by the stopped column
132
 * @method     ChildSubscription[]|ObjectCollection findByTitle(string $title) Return ChildSubscription objects filtered by the title column
133
 * @method     ChildSubscription[]|ObjectCollection findByService(string $service) Return ChildSubscription objects filtered by the service column
134
 * @method     ChildSubscription[]|\Propel\Runtime\Util\PropelModelPager paginate($page = 1, $maxPerPage = 10, ConnectionInterface $con = null) Issue a SELECT query based on the current ModelCriteria and uses a page and a maximum number of results per page to compute an offset and a limit
135
 *
136
 */
137
abstract class SubscriptionQuery extends ModelCriteria
138
{
139
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
140
141
    /**
142
     * Initializes internal state of \Jalle19\StatusManager\Database\Base\SubscriptionQuery object.
143
     *
144
     * @param     string $dbName The database name
145
     * @param     string $modelName The phpName of a model, e.g. 'Book'
146
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
147
     */
148
    public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Subscription', $modelAlias = null)
149
    {
150
        parent::__construct($dbName, $modelName, $modelAlias);
151
    }
152
153
    /**
154
     * Returns a new ChildSubscriptionQuery object.
155
     *
156
     * @param     string $modelAlias The alias of a model in the query
157
     * @param     Criteria $criteria Optional Criteria to build the query from
158
     *
159
     * @return ChildSubscriptionQuery
160
     */
161
    public static function create($modelAlias = null, Criteria $criteria = null)
162
    {
163
        if ($criteria instanceof ChildSubscriptionQuery) {
164
            return $criteria;
165
        }
166
        $query = new ChildSubscriptionQuery();
167
        if (null !== $modelAlias) {
168
            $query->setModelAlias($modelAlias);
169
        }
170
        if ($criteria instanceof Criteria) {
171
            $query->mergeWith($criteria);
172
        }
173
174
        return $query;
175
    }
176
177
    /**
178
     * Find object by primary key.
179
     * Propel uses the instance pool to skip the database if the object exists.
180
     * Go fast if the query is untouched.
181
     *
182
     * <code>
183
     * $obj  = $c->findPk(12, $con);
184
     * </code>
185
     *
186
     * @param mixed $key Primary key to use for the query
187
     * @param ConnectionInterface $con an optional connection object
188
     *
189
     * @return ChildSubscription|array|mixed the result, formatted by the current formatter
190
     */
191
    public function findPk($key, ConnectionInterface $con = null)
192
    {
193
        if ($key === null) {
194
            return null;
195
        }
196
        if ((null !== ($obj = SubscriptionTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) {
197
            // the object is already in the instance pool
198
            return $obj;
199
        }
200
        if ($con === null) {
201
            $con = Propel::getServiceContainer()->getReadConnection(SubscriptionTableMap::DATABASE_NAME);
202
        }
203
        $this->basePreSelect($con);
204
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
205
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
206
         || $this->map || $this->having || $this->joins) {
207
            return $this->findPkComplex($key, $con);
208
        } else {
209
            return $this->findPkSimple($key, $con);
210
        }
211
    }
212
213
    /**
214
     * Find object by primary key using raw SQL to go fast.
215
     * Bypass doSelect() and the object formatter by using generated code.
216
     *
217
     * @param     mixed $key Primary key to use for the query
218
     * @param     ConnectionInterface $con A connection object
219
     *
220
     * @throws \Propel\Runtime\Exception\PropelException
221
     *
222
     * @return ChildSubscription A model object, or null if the key is not found
223
     */
224
    protected function findPkSimple($key, ConnectionInterface $con)
225
    {
226
        $sql = 'SELECT id, instance_name, input_uuid, user_id, channel_id, subscription_id, started, stopped, title, service FROM subscription WHERE id = :p0';
227
        try {
228
            $stmt = $con->prepare($sql);
229
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
230
            $stmt->execute();
231
        } catch (Exception $e) {
232
            Propel::log($e->getMessage(), Propel::LOG_ERR);
233
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
234
        }
235
        $obj = null;
236
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
237
            /** @var ChildSubscription $obj */
238
            $obj = new ChildSubscription();
239
            $obj->hydrate($row);
240
            SubscriptionTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key);
241
        }
242
        $stmt->closeCursor();
243
244
        return $obj;
245
    }
246
247
    /**
248
     * Find object by primary key.
249
     *
250
     * @param     mixed $key Primary key to use for the query
251
     * @param     ConnectionInterface $con A connection object
252
     *
253
     * @return ChildSubscription|array|mixed the result, formatted by the current formatter
254
     */
255
    protected function findPkComplex($key, ConnectionInterface $con)
256
    {
257
        // As the query uses a PK condition, no limit(1) is necessary.
258
        $criteria = $this->isKeepQuery() ? clone $this : $this;
259
        $dataFetcher = $criteria
260
            ->filterByPrimaryKey($key)
261
            ->doSelect($con);
262
263
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
264
    }
265
266
    /**
267
     * Find objects by primary key
268
     * <code>
269
     * $objs = $c->findPks(array(12, 56, 832), $con);
270
     * </code>
271
     * @param     array $keys Primary keys to use for the query
272
     * @param     ConnectionInterface $con an optional connection object
273
     *
274
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
275
     */
276
    public function findPks($keys, ConnectionInterface $con = null)
277
    {
278
        if (null === $con) {
279
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
280
        }
281
        $this->basePreSelect($con);
282
        $criteria = $this->isKeepQuery() ? clone $this : $this;
283
        $dataFetcher = $criteria
284
            ->filterByPrimaryKeys($keys)
285
            ->doSelect($con);
286
287
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
288
    }
289
290
    /**
291
     * Filter the query by primary key
292
     *
293
     * @param     mixed $key Primary key to use for the query
294
     *
295
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
296
     */
297
    public function filterByPrimaryKey($key)
298
    {
299
300
        return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $key, Criteria::EQUAL);
301
    }
302
303
    /**
304
     * Filter the query by a list of primary keys
305
     *
306
     * @param     array $keys The list of primary key to use for the query
307
     *
308
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
309
     */
310
    public function filterByPrimaryKeys($keys)
311
    {
312
313
        return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $keys, Criteria::IN);
314
    }
315
316
    /**
317
     * Filter the query on the id column
318
     *
319
     * Example usage:
320
     * <code>
321
     * $query->filterById(1234); // WHERE id = 1234
322
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
323
     * $query->filterById(array('min' => 12)); // WHERE id > 12
324
     * </code>
325
     *
326
     * @param     mixed $id The value to use as filter.
327
     *              Use scalar values for equality.
328
     *              Use array values for in_array() equivalent.
329
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
330
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
331
     *
332
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
333
     */
334
    public function filterById($id = null, $comparison = null)
335
    {
336
        if (is_array($id)) {
337
            $useMinMax = false;
338
            if (isset($id['min'])) {
339
                $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
340
                $useMinMax = true;
341
            }
342
            if (isset($id['max'])) {
343
                $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
344
                $useMinMax = true;
345
            }
346
            if ($useMinMax) {
347
                return $this;
348
            }
349
            if (null === $comparison) {
350
                $comparison = Criteria::IN;
351
            }
352
        }
353
354
        return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id, $comparison);
355
    }
356
357
    /**
358
     * Filter the query on the instance_name column
359
     *
360
     * Example usage:
361
     * <code>
362
     * $query->filterByInstanceName('fooValue');   // WHERE instance_name = 'fooValue'
363
     * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%'
364
     * </code>
365
     *
366
     * @param     string $instanceName The value to use as filter.
367
     *              Accepts wildcards (* and % trigger a LIKE)
368
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
369
     *
370
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
371
     */
372
    public function filterByInstanceName($instanceName = null, $comparison = null)
373
    {
374
        if (null === $comparison) {
375
            if (is_array($instanceName)) {
376
                $comparison = Criteria::IN;
377
            } elseif (preg_match('/[\%\*]/', $instanceName)) {
378
                $instanceName = str_replace('*', '%', $instanceName);
379
                $comparison = Criteria::LIKE;
380
            }
381
        }
382
383
        return $this->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instanceName, $comparison);
384
    }
385
386
    /**
387
     * Filter the query on the input_uuid column
388
     *
389
     * Example usage:
390
     * <code>
391
     * $query->filterByInputUuid('fooValue');   // WHERE input_uuid = 'fooValue'
392
     * $query->filterByInputUuid('%fooValue%'); // WHERE input_uuid LIKE '%fooValue%'
393
     * </code>
394
     *
395
     * @param     string $inputUuid The value to use as filter.
396
     *              Accepts wildcards (* and % trigger a LIKE)
397
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
398
     *
399
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
400
     */
401
    public function filterByInputUuid($inputUuid = null, $comparison = null)
402
    {
403
        if (null === $comparison) {
404
            if (is_array($inputUuid)) {
405
                $comparison = Criteria::IN;
406
            } elseif (preg_match('/[\%\*]/', $inputUuid)) {
407
                $inputUuid = str_replace('*', '%', $inputUuid);
408
                $comparison = Criteria::LIKE;
409
            }
410
        }
411
412
        return $this->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $inputUuid, $comparison);
413
    }
414
415
    /**
416
     * Filter the query on the user_id column
417
     *
418
     * Example usage:
419
     * <code>
420
     * $query->filterByUserId(1234); // WHERE user_id = 1234
421
     * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34)
422
     * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12
423
     * </code>
424
     *
425
     * @see       filterByUser()
426
     *
427
     * @param     mixed $userId The value to use as filter.
428
     *              Use scalar values for equality.
429
     *              Use array values for in_array() equivalent.
430
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
431
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
432
     *
433
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
434
     */
435
    public function filterByUserId($userId = null, $comparison = null)
436
    {
437
        if (is_array($userId)) {
438
            $useMinMax = false;
439
            if (isset($userId['min'])) {
440
                $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId['min'], Criteria::GREATER_EQUAL);
441
                $useMinMax = true;
442
            }
443
            if (isset($userId['max'])) {
444
                $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId['max'], Criteria::LESS_EQUAL);
445
                $useMinMax = true;
446
            }
447
            if ($useMinMax) {
448
                return $this;
449
            }
450
            if (null === $comparison) {
451
                $comparison = Criteria::IN;
452
            }
453
        }
454
455
        return $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId, $comparison);
456
    }
457
458
    /**
459
     * Filter the query on the channel_id column
460
     *
461
     * Example usage:
462
     * <code>
463
     * $query->filterByChannelId(1234); // WHERE channel_id = 1234
464
     * $query->filterByChannelId(array(12, 34)); // WHERE channel_id IN (12, 34)
465
     * $query->filterByChannelId(array('min' => 12)); // WHERE channel_id > 12
466
     * </code>
467
     *
468
     * @see       filterByChannel()
469
     *
470
     * @param     mixed $channelId The value to use as filter.
471
     *              Use scalar values for equality.
472
     *              Use array values for in_array() equivalent.
473
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
474
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
475
     *
476
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
477
     */
478
    public function filterByChannelId($channelId = null, $comparison = null)
479
    {
480
        if (is_array($channelId)) {
481
            $useMinMax = false;
482
            if (isset($channelId['min'])) {
483
                $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId['min'], Criteria::GREATER_EQUAL);
484
                $useMinMax = true;
485
            }
486
            if (isset($channelId['max'])) {
487
                $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId['max'], Criteria::LESS_EQUAL);
488
                $useMinMax = true;
489
            }
490
            if ($useMinMax) {
491
                return $this;
492
            }
493
            if (null === $comparison) {
494
                $comparison = Criteria::IN;
495
            }
496
        }
497
498
        return $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId, $comparison);
499
    }
500
501
    /**
502
     * Filter the query on the subscription_id column
503
     *
504
     * Example usage:
505
     * <code>
506
     * $query->filterBySubscriptionId(1234); // WHERE subscription_id = 1234
507
     * $query->filterBySubscriptionId(array(12, 34)); // WHERE subscription_id IN (12, 34)
508
     * $query->filterBySubscriptionId(array('min' => 12)); // WHERE subscription_id > 12
509
     * </code>
510
     *
511
     * @param     mixed $subscriptionId The value to use as filter.
512
     *              Use scalar values for equality.
513
     *              Use array values for in_array() equivalent.
514
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
515
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
516
     *
517
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
518
     */
519
    public function filterBySubscriptionId($subscriptionId = null, $comparison = null)
520
    {
521
        if (is_array($subscriptionId)) {
522
            $useMinMax = false;
523
            if (isset($subscriptionId['min'])) {
524
                $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId['min'], Criteria::GREATER_EQUAL);
525
                $useMinMax = true;
526
            }
527
            if (isset($subscriptionId['max'])) {
528
                $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId['max'], Criteria::LESS_EQUAL);
529
                $useMinMax = true;
530
            }
531
            if ($useMinMax) {
532
                return $this;
533
            }
534
            if (null === $comparison) {
535
                $comparison = Criteria::IN;
536
            }
537
        }
538
539
        return $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId, $comparison);
540
    }
541
542
    /**
543
     * Filter the query on the started column
544
     *
545
     * Example usage:
546
     * <code>
547
     * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14'
548
     * $query->filterByStarted('now'); // WHERE started = '2011-03-14'
549
     * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13'
550
     * </code>
551
     *
552
     * @param     mixed $started The value to use as filter.
553
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
554
     *              Empty strings are treated as NULL.
555
     *              Use scalar values for equality.
556
     *              Use array values for in_array() equivalent.
557
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
558
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
559
     *
560
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
561
     */
562
    public function filterByStarted($started = null, $comparison = null)
563
    {
564
        if (is_array($started)) {
565
            $useMinMax = false;
566
            if (isset($started['min'])) {
567
                $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL);
568
                $useMinMax = true;
569
            }
570
            if (isset($started['max'])) {
571
                $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL);
572
                $useMinMax = true;
573
            }
574
            if ($useMinMax) {
575
                return $this;
576
            }
577
            if (null === $comparison) {
578
                $comparison = Criteria::IN;
579
            }
580
        }
581
582
        return $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started, $comparison);
583
    }
584
585
    /**
586
     * Filter the query on the stopped column
587
     *
588
     * Example usage:
589
     * <code>
590
     * $query->filterByStopped('2011-03-14'); // WHERE stopped = '2011-03-14'
591
     * $query->filterByStopped('now'); // WHERE stopped = '2011-03-14'
592
     * $query->filterByStopped(array('max' => 'yesterday')); // WHERE stopped > '2011-03-13'
593
     * </code>
594
     *
595
     * @param     mixed $stopped The value to use as filter.
596
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
597
     *              Empty strings are treated as NULL.
598
     *              Use scalar values for equality.
599
     *              Use array values for in_array() equivalent.
600
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
601
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
602
     *
603
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
604
     */
605
    public function filterByStopped($stopped = null, $comparison = null)
606
    {
607
        if (is_array($stopped)) {
608
            $useMinMax = false;
609
            if (isset($stopped['min'])) {
610
                $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped['min'], Criteria::GREATER_EQUAL);
611
                $useMinMax = true;
612
            }
613
            if (isset($stopped['max'])) {
614
                $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped['max'], Criteria::LESS_EQUAL);
615
                $useMinMax = true;
616
            }
617
            if ($useMinMax) {
618
                return $this;
619
            }
620
            if (null === $comparison) {
621
                $comparison = Criteria::IN;
622
            }
623
        }
624
625
        return $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped, $comparison);
626
    }
627
628
    /**
629
     * Filter the query on the title column
630
     *
631
     * Example usage:
632
     * <code>
633
     * $query->filterByTitle('fooValue');   // WHERE title = 'fooValue'
634
     * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%'
635
     * </code>
636
     *
637
     * @param     string $title The value to use as filter.
638
     *              Accepts wildcards (* and % trigger a LIKE)
639
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
640
     *
641
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
642
     */
643
    public function filterByTitle($title = null, $comparison = null)
644
    {
645
        if (null === $comparison) {
646
            if (is_array($title)) {
647
                $comparison = Criteria::IN;
648
            } elseif (preg_match('/[\%\*]/', $title)) {
649
                $title = str_replace('*', '%', $title);
650
                $comparison = Criteria::LIKE;
651
            }
652
        }
653
654
        return $this->addUsingAlias(SubscriptionTableMap::COL_TITLE, $title, $comparison);
655
    }
656
657
    /**
658
     * Filter the query on the service column
659
     *
660
     * Example usage:
661
     * <code>
662
     * $query->filterByService('fooValue');   // WHERE service = 'fooValue'
663
     * $query->filterByService('%fooValue%'); // WHERE service LIKE '%fooValue%'
664
     * </code>
665
     *
666
     * @param     string $service The value to use as filter.
667
     *              Accepts wildcards (* and % trigger a LIKE)
668
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
669
     *
670
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
671
     */
672
    public function filterByService($service = null, $comparison = null)
673
    {
674
        if (null === $comparison) {
675
            if (is_array($service)) {
676
                $comparison = Criteria::IN;
677
            } elseif (preg_match('/[\%\*]/', $service)) {
678
                $service = str_replace('*', '%', $service);
679
                $comparison = Criteria::LIKE;
680
            }
681
        }
682
683
        return $this->addUsingAlias(SubscriptionTableMap::COL_SERVICE, $service, $comparison);
684
    }
685
686
    /**
687
     * Filter the query by a related \Jalle19\StatusManager\Database\Instance object
688
     *
689
     * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter
690
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
691
     *
692
     * @throws \Propel\Runtime\Exception\PropelException
693
     *
694
     * @return ChildSubscriptionQuery The current query, for fluid interface
695
     */
696
    public function filterByInstance($instance, $comparison = null)
697
    {
698
        if ($instance instanceof \Jalle19\StatusManager\Database\Instance) {
699
            return $this
700
                ->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison);
701
        } elseif ($instance instanceof ObjectCollection) {
702
            if (null === $comparison) {
703
                $comparison = Criteria::IN;
704
            }
705
706
            return $this
707
                ->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison);
708
        } else {
709
            throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection');
710
        }
711
    }
712
713
    /**
714
     * Adds a JOIN clause to the query using the Instance relation
715
     *
716
     * @param     string $relationAlias optional alias for the relation
717
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
718
     *
719
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
720
     */
721
    public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN)
722
    {
723
        $tableMap = $this->getTableMap();
724
        $relationMap = $tableMap->getRelation('Instance');
725
726
        // create a ModelJoin object for this join
727
        $join = new ModelJoin();
728
        $join->setJoinType($joinType);
729
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
730
        if ($previousJoin = $this->getPreviousJoin()) {
731
            $join->setPreviousJoin($previousJoin);
732
        }
733
734
        // add the ModelJoin to the current object
735
        if ($relationAlias) {
736
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
737
            $this->addJoinObject($join, $relationAlias);
738
        } else {
739
            $this->addJoinObject($join, 'Instance');
740
        }
741
742
        return $this;
743
    }
744
745
    /**
746
     * Use the Instance relation Instance object
747
     *
748
     * @see useQuery()
749
     *
750
     * @param     string $relationAlias optional alias for the relation,
751
     *                                   to be used as main alias in the secondary query
752
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
753
     *
754
     * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query
755
     */
756
    public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
757
    {
758
        return $this
759
            ->joinInstance($relationAlias, $joinType)
760
            ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery');
761
    }
762
763
    /**
764
     * Filter the query by a related \Jalle19\StatusManager\Database\Input object
765
     *
766
     * @param \Jalle19\StatusManager\Database\Input|ObjectCollection $input The related object(s) to use as filter
767
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
768
     *
769
     * @throws \Propel\Runtime\Exception\PropelException
770
     *
771
     * @return ChildSubscriptionQuery The current query, for fluid interface
772
     */
773
    public function filterByInput($input, $comparison = null)
774
    {
775
        if ($input instanceof \Jalle19\StatusManager\Database\Input) {
776
            return $this
777
                ->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $input->getUuid(), $comparison);
778
        } elseif ($input instanceof ObjectCollection) {
779
            if (null === $comparison) {
780
                $comparison = Criteria::IN;
781
            }
782
783
            return $this
784
                ->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $input->toKeyValue('PrimaryKey', 'Uuid'), $comparison);
785
        } else {
786
            throw new PropelException('filterByInput() only accepts arguments of type \Jalle19\StatusManager\Database\Input or Collection');
787
        }
788
    }
789
790
    /**
791
     * Adds a JOIN clause to the query using the Input relation
792
     *
793
     * @param     string $relationAlias optional alias for the relation
794
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
795
     *
796
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
797
     */
798
    public function joinInput($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
799
    {
800
        $tableMap = $this->getTableMap();
801
        $relationMap = $tableMap->getRelation('Input');
802
803
        // create a ModelJoin object for this join
804
        $join = new ModelJoin();
805
        $join->setJoinType($joinType);
806
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
807
        if ($previousJoin = $this->getPreviousJoin()) {
808
            $join->setPreviousJoin($previousJoin);
809
        }
810
811
        // add the ModelJoin to the current object
812
        if ($relationAlias) {
813
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
814
            $this->addJoinObject($join, $relationAlias);
815
        } else {
816
            $this->addJoinObject($join, 'Input');
817
        }
818
819
        return $this;
820
    }
821
822
    /**
823
     * Use the Input relation Input object
824
     *
825
     * @see useQuery()
826
     *
827
     * @param     string $relationAlias optional alias for the relation,
828
     *                                   to be used as main alias in the secondary query
829
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
830
     *
831
     * @return \Jalle19\StatusManager\Database\InputQuery A secondary query class using the current class as primary query
832
     */
833
    public function useInputQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
834
    {
835
        return $this
836
            ->joinInput($relationAlias, $joinType)
837
            ->useQuery($relationAlias ? $relationAlias : 'Input', '\Jalle19\StatusManager\Database\InputQuery');
838
    }
839
840
    /**
841
     * Filter the query by a related \Jalle19\StatusManager\Database\User object
842
     *
843
     * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user The related object(s) to use as filter
844
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
845
     *
846
     * @throws \Propel\Runtime\Exception\PropelException
847
     *
848
     * @return ChildSubscriptionQuery The current query, for fluid interface
849
     */
850
    public function filterByUser($user, $comparison = null)
851
    {
852
        if ($user instanceof \Jalle19\StatusManager\Database\User) {
853
            return $this
854
                ->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $user->getId(), $comparison);
855
        } elseif ($user instanceof ObjectCollection) {
856
            if (null === $comparison) {
857
                $comparison = Criteria::IN;
858
            }
859
860
            return $this
861
                ->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison);
862
        } else {
863
            throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection');
864
        }
865
    }
866
867
    /**
868
     * Adds a JOIN clause to the query using the User relation
869
     *
870
     * @param     string $relationAlias optional alias for the relation
871
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
872
     *
873
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
874
     */
875
    public function joinUser($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
876
    {
877
        $tableMap = $this->getTableMap();
878
        $relationMap = $tableMap->getRelation('User');
879
880
        // create a ModelJoin object for this join
881
        $join = new ModelJoin();
882
        $join->setJoinType($joinType);
883
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
884
        if ($previousJoin = $this->getPreviousJoin()) {
885
            $join->setPreviousJoin($previousJoin);
886
        }
887
888
        // add the ModelJoin to the current object
889
        if ($relationAlias) {
890
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
891
            $this->addJoinObject($join, $relationAlias);
892
        } else {
893
            $this->addJoinObject($join, 'User');
894
        }
895
896
        return $this;
897
    }
898
899
    /**
900
     * Use the User relation User object
901
     *
902
     * @see useQuery()
903
     *
904
     * @param     string $relationAlias optional alias for the relation,
905
     *                                   to be used as main alias in the secondary query
906
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
907
     *
908
     * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query
909
     */
910
    public function useUserQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
911
    {
912
        return $this
913
            ->joinUser($relationAlias, $joinType)
914
            ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery');
915
    }
916
917
    /**
918
     * Filter the query by a related \Jalle19\StatusManager\Database\Channel object
919
     *
920
     * @param \Jalle19\StatusManager\Database\Channel|ObjectCollection $channel The related object(s) to use as filter
921
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
922
     *
923
     * @throws \Propel\Runtime\Exception\PropelException
924
     *
925
     * @return ChildSubscriptionQuery The current query, for fluid interface
926
     */
927
    public function filterByChannel($channel, $comparison = null)
928
    {
929
        if ($channel instanceof \Jalle19\StatusManager\Database\Channel) {
930
            return $this
931
                ->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channel->getId(), $comparison);
932
        } elseif ($channel instanceof ObjectCollection) {
933
            if (null === $comparison) {
934
                $comparison = Criteria::IN;
935
            }
936
937
            return $this
938
                ->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channel->toKeyValue('PrimaryKey', 'Id'), $comparison);
939
        } else {
940
            throw new PropelException('filterByChannel() only accepts arguments of type \Jalle19\StatusManager\Database\Channel or Collection');
941
        }
942
    }
943
944
    /**
945
     * Adds a JOIN clause to the query using the Channel relation
946
     *
947
     * @param     string $relationAlias optional alias for the relation
948
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
949
     *
950
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
951
     */
952
    public function joinChannel($relationAlias = null, $joinType = Criteria::INNER_JOIN)
953
    {
954
        $tableMap = $this->getTableMap();
955
        $relationMap = $tableMap->getRelation('Channel');
956
957
        // create a ModelJoin object for this join
958
        $join = new ModelJoin();
959
        $join->setJoinType($joinType);
960
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
961
        if ($previousJoin = $this->getPreviousJoin()) {
962
            $join->setPreviousJoin($previousJoin);
963
        }
964
965
        // add the ModelJoin to the current object
966
        if ($relationAlias) {
967
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
968
            $this->addJoinObject($join, $relationAlias);
969
        } else {
970
            $this->addJoinObject($join, 'Channel');
971
        }
972
973
        return $this;
974
    }
975
976
    /**
977
     * Use the Channel relation Channel object
978
     *
979
     * @see useQuery()
980
     *
981
     * @param     string $relationAlias optional alias for the relation,
982
     *                                   to be used as main alias in the secondary query
983
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
984
     *
985
     * @return \Jalle19\StatusManager\Database\ChannelQuery A secondary query class using the current class as primary query
986
     */
987
    public function useChannelQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
988
    {
989
        return $this
990
            ->joinChannel($relationAlias, $joinType)
991
            ->useQuery($relationAlias ? $relationAlias : 'Channel', '\Jalle19\StatusManager\Database\ChannelQuery');
992
    }
993
994
    /**
995
     * Exclude object from result
996
     *
997
     * @param   ChildSubscription $subscription Object to remove from the list of results
998
     *
999
     * @return $this|ChildSubscriptionQuery The current query, for fluid interface
1000
     */
1001
    public function prune($subscription = null)
1002
    {
1003
        if ($subscription) {
1004
            $this->addUsingAlias(SubscriptionTableMap::COL_ID, $subscription->getId(), Criteria::NOT_EQUAL);
1005
        }
1006
1007
        return $this;
1008
    }
1009
1010
    /**
1011
     * Deletes all rows from the subscription table.
1012
     *
1013
     * @param ConnectionInterface $con the connection to use
1014
     * @return int The number of affected rows (if supported by underlying database driver).
1015
     */
1016
    public function doDeleteAll(ConnectionInterface $con = null)
1017
    {
1018
        if (null === $con) {
1019
            $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME);
1020
        }
1021
1022
        // use transaction because $criteria could contain info
1023
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
1024
        return $con->transaction(function () use ($con) {
1025
            $affectedRows = 0; // initialize var to track total num of affected rows
1026
            $affectedRows += parent::doDeleteAll($con);
1027
            // Because this db requires some delete cascade/set null emulation, we have to
1028
            // clear the cached instance *after* the emulation has happened (since
1029
            // instances get re-added by the select statement contained therein).
1030
            SubscriptionTableMap::clearInstancePool();
1031
            SubscriptionTableMap::clearRelatedInstancePool();
1032
1033
            return $affectedRows;
1034
        });
1035
    }
1036
1037
    /**
1038
     * Performs a DELETE on the database based on the current ModelCriteria
1039
     *
1040
     * @param ConnectionInterface $con the connection to use
1041
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
1042
     *                         if supported by native driver or if emulated using Propel.
1043
     * @throws PropelException Any exceptions caught during processing will be
1044
     *                         rethrown wrapped into a PropelException.
1045
     */
1046
    public function delete(ConnectionInterface $con = null)
1047
    {
1048
        if (null === $con) {
1049
            $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME);
1050
        }
1051
1052
        $criteria = $this;
1053
1054
        // Set the correct dbName
1055
        $criteria->setDbName(SubscriptionTableMap::DATABASE_NAME);
1056
1057
        // use transaction because $criteria could contain info
1058
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
1059
        return $con->transaction(function () use ($con, $criteria) {
1060
            $affectedRows = 0; // initialize var to track total num of affected rows
1061
1062
            SubscriptionTableMap::removeInstanceFromPool($criteria);
1063
1064
            $affectedRows += ModelCriteria::delete($con);
1065
            SubscriptionTableMap::clearRelatedInstancePool();
1066
1067
            return $affectedRows;
1068
        });
1069
    }
1070
1071
} // SubscriptionQuery
1072