1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Database\Base; |
4
|
|
|
|
5
|
|
|
use \Exception; |
6
|
|
|
use \PDO; |
7
|
|
|
use Jalle19\StatusManager\Database\Input as ChildInput; |
8
|
|
|
use Jalle19\StatusManager\Database\InputQuery as ChildInputQuery; |
9
|
|
|
use Jalle19\StatusManager\Database\Map\InputTableMap; |
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 'input' table. |
20
|
|
|
* |
21
|
|
|
* |
22
|
|
|
* |
23
|
|
|
* @method ChildInputQuery orderByUuid($order = Criteria::ASC) Order by the uuid column |
24
|
|
|
* @method ChildInputQuery orderByInstanceName($order = Criteria::ASC) Order by the instance_name column |
25
|
|
|
* @method ChildInputQuery orderByStarted($order = Criteria::ASC) Order by the started column |
26
|
|
|
* @method ChildInputQuery orderByInput($order = Criteria::ASC) Order by the input column |
27
|
|
|
* @method ChildInputQuery orderByNetwork($order = Criteria::ASC) Order by the network column |
28
|
|
|
* @method ChildInputQuery orderByMux($order = Criteria::ASC) Order by the mux column |
29
|
|
|
* @method ChildInputQuery orderByWeight($order = Criteria::ASC) Order by the weight column |
30
|
|
|
* |
31
|
|
|
* @method ChildInputQuery groupByUuid() Group by the uuid column |
32
|
|
|
* @method ChildInputQuery groupByInstanceName() Group by the instance_name column |
33
|
|
|
* @method ChildInputQuery groupByStarted() Group by the started column |
34
|
|
|
* @method ChildInputQuery groupByInput() Group by the input column |
35
|
|
|
* @method ChildInputQuery groupByNetwork() Group by the network column |
36
|
|
|
* @method ChildInputQuery groupByMux() Group by the mux column |
37
|
|
|
* @method ChildInputQuery groupByWeight() Group by the weight column |
38
|
|
|
* |
39
|
|
|
* @method ChildInputQuery leftJoin($relation) Adds a LEFT JOIN clause to the query |
40
|
|
|
* @method ChildInputQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query |
41
|
|
|
* @method ChildInputQuery innerJoin($relation) Adds a INNER JOIN clause to the query |
42
|
|
|
* |
43
|
|
|
* @method ChildInputQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query |
44
|
|
|
* @method ChildInputQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query |
45
|
|
|
* @method ChildInputQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query |
46
|
|
|
* |
47
|
|
|
* @method ChildInputQuery leftJoinInstance($relationAlias = null) Adds a LEFT JOIN clause to the query using the Instance relation |
48
|
|
|
* @method ChildInputQuery rightJoinInstance($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Instance relation |
49
|
|
|
* @method ChildInputQuery innerJoinInstance($relationAlias = null) Adds a INNER JOIN clause to the query using the Instance relation |
50
|
|
|
* |
51
|
|
|
* @method ChildInputQuery joinWithInstance($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Instance relation |
52
|
|
|
* |
53
|
|
|
* @method ChildInputQuery leftJoinWithInstance() Adds a LEFT JOIN clause and with to the query using the Instance relation |
54
|
|
|
* @method ChildInputQuery rightJoinWithInstance() Adds a RIGHT JOIN clause and with to the query using the Instance relation |
55
|
|
|
* @method ChildInputQuery innerJoinWithInstance() Adds a INNER JOIN clause and with to the query using the Instance relation |
56
|
|
|
* |
57
|
|
|
* @method ChildInputQuery leftJoinSubscription($relationAlias = null) Adds a LEFT JOIN clause to the query using the Subscription relation |
58
|
|
|
* @method ChildInputQuery rightJoinSubscription($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Subscription relation |
59
|
|
|
* @method ChildInputQuery innerJoinSubscription($relationAlias = null) Adds a INNER JOIN clause to the query using the Subscription relation |
60
|
|
|
* |
61
|
|
|
* @method ChildInputQuery joinWithSubscription($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Subscription relation |
62
|
|
|
* |
63
|
|
|
* @method ChildInputQuery leftJoinWithSubscription() Adds a LEFT JOIN clause and with to the query using the Subscription relation |
64
|
|
|
* @method ChildInputQuery rightJoinWithSubscription() Adds a RIGHT JOIN clause and with to the query using the Subscription relation |
65
|
|
|
* @method ChildInputQuery innerJoinWithSubscription() Adds a INNER JOIN clause and with to the query using the Subscription relation |
66
|
|
|
* |
67
|
|
|
* @method \Jalle19\StatusManager\Database\InstanceQuery|\Jalle19\StatusManager\Database\SubscriptionQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria |
68
|
|
|
* |
69
|
|
|
* @method ChildInput findOne(ConnectionInterface $con = null) Return the first ChildInput matching the query |
70
|
|
|
* @method ChildInput findOneOrCreate(ConnectionInterface $con = null) Return the first ChildInput matching the query, or a new ChildInput object populated from the query conditions when no match is found |
71
|
|
|
* |
72
|
|
|
* @method ChildInput findOneByUuid(string $uuid) Return the first ChildInput filtered by the uuid column |
73
|
|
|
* @method ChildInput findOneByInstanceName(string $instance_name) Return the first ChildInput filtered by the instance_name column |
74
|
|
|
* @method ChildInput findOneByStarted(string $started) Return the first ChildInput filtered by the started column |
75
|
|
|
* @method ChildInput findOneByInput(string $input) Return the first ChildInput filtered by the input column |
76
|
|
|
* @method ChildInput findOneByNetwork(string $network) Return the first ChildInput filtered by the network column |
77
|
|
|
* @method ChildInput findOneByMux(string $mux) Return the first ChildInput filtered by the mux column |
78
|
|
|
* @method ChildInput findOneByWeight(int $weight) Return the first ChildInput filtered by the weight column * |
79
|
|
|
|
80
|
|
|
* @method ChildInput requirePk($key, ConnectionInterface $con = null) Return the ChildInput by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
81
|
|
|
* @method ChildInput requireOne(ConnectionInterface $con = null) Return the first ChildInput matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
82
|
|
|
* |
83
|
|
|
* @method ChildInput requireOneByUuid(string $uuid) Return the first ChildInput filtered by the uuid column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
84
|
|
|
* @method ChildInput requireOneByInstanceName(string $instance_name) Return the first ChildInput filtered by the instance_name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
85
|
|
|
* @method ChildInput requireOneByStarted(string $started) Return the first ChildInput filtered by the started column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
86
|
|
|
* @method ChildInput requireOneByInput(string $input) Return the first ChildInput filtered by the input column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
87
|
|
|
* @method ChildInput requireOneByNetwork(string $network) Return the first ChildInput filtered by the network column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
88
|
|
|
* @method ChildInput requireOneByMux(string $mux) Return the first ChildInput filtered by the mux column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
89
|
|
|
* @method ChildInput requireOneByWeight(int $weight) Return the first ChildInput filtered by the weight column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
90
|
|
|
* |
91
|
|
|
* @method ChildInput[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildInput objects based on current ModelCriteria |
92
|
|
|
* @method ChildInput[]|ObjectCollection findByUuid(string $uuid) Return ChildInput objects filtered by the uuid column |
93
|
|
|
* @method ChildInput[]|ObjectCollection findByInstanceName(string $instance_name) Return ChildInput objects filtered by the instance_name column |
94
|
|
|
* @method ChildInput[]|ObjectCollection findByStarted(string $started) Return ChildInput objects filtered by the started column |
95
|
|
|
* @method ChildInput[]|ObjectCollection findByInput(string $input) Return ChildInput objects filtered by the input column |
96
|
|
|
* @method ChildInput[]|ObjectCollection findByNetwork(string $network) Return ChildInput objects filtered by the network column |
97
|
|
|
* @method ChildInput[]|ObjectCollection findByMux(string $mux) Return ChildInput objects filtered by the mux column |
98
|
|
|
* @method ChildInput[]|ObjectCollection findByWeight(int $weight) Return ChildInput objects filtered by the weight column |
99
|
|
|
* @method ChildInput[]|\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 |
100
|
|
|
* |
101
|
|
|
*/ |
102
|
|
|
abstract class InputQuery extends ModelCriteria |
103
|
|
|
{ |
104
|
|
|
protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Initializes internal state of \Jalle19\StatusManager\Database\Base\InputQuery object. |
108
|
|
|
* |
109
|
|
|
* @param string $dbName The database name |
110
|
|
|
* @param string $modelName The phpName of a model, e.g. 'Book' |
111
|
|
|
* @param string $modelAlias The alias for the model in this query, e.g. 'b' |
112
|
|
|
*/ |
113
|
|
|
public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Input', $modelAlias = null) |
114
|
|
|
{ |
115
|
|
|
parent::__construct($dbName, $modelName, $modelAlias); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Returns a new ChildInputQuery object. |
120
|
|
|
* |
121
|
|
|
* @param string $modelAlias The alias of a model in the query |
122
|
|
|
* @param Criteria $criteria Optional Criteria to build the query from |
123
|
|
|
* |
124
|
|
|
* @return ChildInputQuery |
125
|
|
|
*/ |
126
|
|
|
public static function create($modelAlias = null, Criteria $criteria = null) |
127
|
|
|
{ |
128
|
|
|
if ($criteria instanceof ChildInputQuery) { |
129
|
|
|
return $criteria; |
130
|
|
|
} |
131
|
|
|
$query = new ChildInputQuery(); |
132
|
|
|
if (null !== $modelAlias) { |
133
|
|
|
$query->setModelAlias($modelAlias); |
134
|
|
|
} |
135
|
|
|
if ($criteria instanceof Criteria) { |
136
|
|
|
$query->mergeWith($criteria); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
return $query; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Find object by primary key. |
144
|
|
|
* Propel uses the instance pool to skip the database if the object exists. |
145
|
|
|
* Go fast if the query is untouched. |
146
|
|
|
* |
147
|
|
|
* <code> |
148
|
|
|
* $obj = $c->findPk(12, $con); |
149
|
|
|
* </code> |
150
|
|
|
* |
151
|
|
|
* @param mixed $key Primary key to use for the query |
152
|
|
|
* @param ConnectionInterface $con an optional connection object |
153
|
|
|
* |
154
|
|
|
* @return ChildInput|array|mixed the result, formatted by the current formatter |
155
|
|
|
*/ |
156
|
|
View Code Duplication |
public function findPk($key, ConnectionInterface $con = null) |
|
|
|
|
157
|
|
|
{ |
158
|
|
|
if ($key === null) { |
159
|
|
|
return null; |
160
|
|
|
} |
161
|
|
|
if ((null !== ($obj = InputTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
162
|
|
|
// the object is already in the instance pool |
163
|
|
|
return $obj; |
164
|
|
|
} |
165
|
|
|
if ($con === null) { |
166
|
|
|
$con = Propel::getServiceContainer()->getReadConnection(InputTableMap::DATABASE_NAME); |
167
|
|
|
} |
168
|
|
|
$this->basePreSelect($con); |
169
|
|
|
if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
|
|
|
170
|
|
|
|| $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
|
|
|
171
|
|
|
|| $this->map || $this->having || $this->joins) { |
|
|
|
|
172
|
|
|
return $this->findPkComplex($key, $con); |
173
|
|
|
} else { |
174
|
|
|
return $this->findPkSimple($key, $con); |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Find object by primary key using raw SQL to go fast. |
180
|
|
|
* Bypass doSelect() and the object formatter by using generated code. |
181
|
|
|
* |
182
|
|
|
* @param mixed $key Primary key to use for the query |
183
|
|
|
* @param ConnectionInterface $con A connection object |
184
|
|
|
* |
185
|
|
|
* @throws \Propel\Runtime\Exception\PropelException |
186
|
|
|
* |
187
|
|
|
* @return ChildInput A model object, or null if the key is not found |
188
|
|
|
*/ |
189
|
|
|
protected function findPkSimple($key, ConnectionInterface $con) |
190
|
|
|
{ |
191
|
|
|
$sql = 'SELECT uuid, instance_name, started, input, network, mux, weight FROM input WHERE uuid = :p0'; |
192
|
|
|
try { |
193
|
|
|
$stmt = $con->prepare($sql); |
194
|
|
|
$stmt->bindValue(':p0', $key, PDO::PARAM_STR); |
195
|
|
|
$stmt->execute(); |
196
|
|
|
} catch (Exception $e) { |
197
|
|
|
Propel::log($e->getMessage(), Propel::LOG_ERR); |
198
|
|
|
throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
199
|
|
|
} |
200
|
|
|
$obj = null; |
201
|
|
|
if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
202
|
|
|
/** @var ChildInput $obj */ |
203
|
|
|
$obj = new ChildInput(); |
204
|
|
|
$obj->hydrate($row); |
205
|
|
|
InputTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
206
|
|
|
} |
207
|
|
|
$stmt->closeCursor(); |
208
|
|
|
|
209
|
|
|
return $obj; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Find object by primary key. |
214
|
|
|
* |
215
|
|
|
* @param mixed $key Primary key to use for the query |
216
|
|
|
* @param ConnectionInterface $con A connection object |
217
|
|
|
* |
218
|
|
|
* @return ChildInput|array|mixed the result, formatted by the current formatter |
219
|
|
|
*/ |
220
|
|
View Code Duplication |
protected function findPkComplex($key, ConnectionInterface $con) |
|
|
|
|
221
|
|
|
{ |
222
|
|
|
// As the query uses a PK condition, no limit(1) is necessary. |
223
|
|
|
$criteria = $this->isKeepQuery() ? clone $this : $this; |
224
|
|
|
$dataFetcher = $criteria |
225
|
|
|
->filterByPrimaryKey($key) |
226
|
|
|
->doSelect($con); |
227
|
|
|
|
228
|
|
|
return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Find objects by primary key |
233
|
|
|
* <code> |
234
|
|
|
* $objs = $c->findPks(array(12, 56, 832), $con); |
235
|
|
|
* </code> |
236
|
|
|
* @param array $keys Primary keys to use for the query |
237
|
|
|
* @param ConnectionInterface $con an optional connection object |
238
|
|
|
* |
239
|
|
|
* @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
240
|
|
|
*/ |
241
|
|
View Code Duplication |
public function findPks($keys, ConnectionInterface $con = null) |
|
|
|
|
242
|
|
|
{ |
243
|
|
|
if (null === $con) { |
244
|
|
|
$con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
245
|
|
|
} |
246
|
|
|
$this->basePreSelect($con); |
247
|
|
|
$criteria = $this->isKeepQuery() ? clone $this : $this; |
248
|
|
|
$dataFetcher = $criteria |
249
|
|
|
->filterByPrimaryKeys($keys) |
250
|
|
|
->doSelect($con); |
251
|
|
|
|
252
|
|
|
return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Filter the query by primary key |
257
|
|
|
* |
258
|
|
|
* @param mixed $key Primary key to use for the query |
259
|
|
|
* |
260
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
261
|
|
|
*/ |
262
|
|
|
public function filterByPrimaryKey($key) |
263
|
|
|
{ |
264
|
|
|
|
265
|
|
|
return $this->addUsingAlias(InputTableMap::COL_UUID, $key, Criteria::EQUAL); |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Filter the query by a list of primary keys |
270
|
|
|
* |
271
|
|
|
* @param array $keys The list of primary key to use for the query |
272
|
|
|
* |
273
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
274
|
|
|
*/ |
275
|
|
|
public function filterByPrimaryKeys($keys) |
276
|
|
|
{ |
277
|
|
|
|
278
|
|
|
return $this->addUsingAlias(InputTableMap::COL_UUID, $keys, Criteria::IN); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Filter the query on the uuid column |
283
|
|
|
* |
284
|
|
|
* Example usage: |
285
|
|
|
* <code> |
286
|
|
|
* $query->filterByUuid('fooValue'); // WHERE uuid = 'fooValue' |
287
|
|
|
* $query->filterByUuid('%fooValue%'); // WHERE uuid LIKE '%fooValue%' |
288
|
|
|
* </code> |
289
|
|
|
* |
290
|
|
|
* @param string $uuid The value to use as filter. |
291
|
|
|
* Accepts wildcards (* and % trigger a LIKE) |
292
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
293
|
|
|
* |
294
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
295
|
|
|
*/ |
296
|
|
View Code Duplication |
public function filterByUuid($uuid = null, $comparison = null) |
|
|
|
|
297
|
|
|
{ |
298
|
|
|
if (null === $comparison) { |
299
|
|
|
if (is_array($uuid)) { |
300
|
|
|
$comparison = Criteria::IN; |
301
|
|
|
} elseif (preg_match('/[\%\*]/', $uuid)) { |
302
|
|
|
$uuid = str_replace('*', '%', $uuid); |
303
|
|
|
$comparison = Criteria::LIKE; |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return $this->addUsingAlias(InputTableMap::COL_UUID, $uuid, $comparison); |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
/** |
311
|
|
|
* Filter the query on the instance_name column |
312
|
|
|
* |
313
|
|
|
* Example usage: |
314
|
|
|
* <code> |
315
|
|
|
* $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
316
|
|
|
* $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
317
|
|
|
* </code> |
318
|
|
|
* |
319
|
|
|
* @param string $instanceName The value to use as filter. |
320
|
|
|
* Accepts wildcards (* and % trigger a LIKE) |
321
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
322
|
|
|
* |
323
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
324
|
|
|
*/ |
325
|
|
View Code Duplication |
public function filterByInstanceName($instanceName = null, $comparison = null) |
|
|
|
|
326
|
|
|
{ |
327
|
|
|
if (null === $comparison) { |
328
|
|
|
if (is_array($instanceName)) { |
329
|
|
|
$comparison = Criteria::IN; |
330
|
|
|
} elseif (preg_match('/[\%\*]/', $instanceName)) { |
331
|
|
|
$instanceName = str_replace('*', '%', $instanceName); |
332
|
|
|
$comparison = Criteria::LIKE; |
333
|
|
|
} |
334
|
|
|
} |
335
|
|
|
|
336
|
|
|
return $this->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* Filter the query on the started column |
341
|
|
|
* |
342
|
|
|
* Example usage: |
343
|
|
|
* <code> |
344
|
|
|
* $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
345
|
|
|
* $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
346
|
|
|
* $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
347
|
|
|
* </code> |
348
|
|
|
* |
349
|
|
|
* @param mixed $started The value to use as filter. |
350
|
|
|
* Values can be integers (unix timestamps), DateTime objects, or strings. |
351
|
|
|
* Empty strings are treated as NULL. |
352
|
|
|
* Use scalar values for equality. |
353
|
|
|
* Use array values for in_array() equivalent. |
354
|
|
|
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
355
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
356
|
|
|
* |
357
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
358
|
|
|
*/ |
359
|
|
|
public function filterByStarted($started = null, $comparison = null) |
360
|
|
|
{ |
361
|
|
|
if (is_array($started)) { |
362
|
|
|
$useMinMax = false; |
363
|
|
|
if (isset($started['min'])) { |
364
|
|
|
$this->addUsingAlias(InputTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
365
|
|
|
$useMinMax = true; |
366
|
|
|
} |
367
|
|
|
if (isset($started['max'])) { |
368
|
|
|
$this->addUsingAlias(InputTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
369
|
|
|
$useMinMax = true; |
370
|
|
|
} |
371
|
|
|
if ($useMinMax) { |
372
|
|
|
return $this; |
373
|
|
|
} |
374
|
|
|
if (null === $comparison) { |
375
|
|
|
$comparison = Criteria::IN; |
376
|
|
|
} |
377
|
|
|
} |
378
|
|
|
|
379
|
|
|
return $this->addUsingAlias(InputTableMap::COL_STARTED, $started, $comparison); |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* Filter the query on the input column |
384
|
|
|
* |
385
|
|
|
* Example usage: |
386
|
|
|
* <code> |
387
|
|
|
* $query->filterByInput('fooValue'); // WHERE input = 'fooValue' |
388
|
|
|
* $query->filterByInput('%fooValue%'); // WHERE input LIKE '%fooValue%' |
389
|
|
|
* </code> |
390
|
|
|
* |
391
|
|
|
* @param string $input The value to use as filter. |
392
|
|
|
* Accepts wildcards (* and % trigger a LIKE) |
393
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
394
|
|
|
* |
395
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
396
|
|
|
*/ |
397
|
|
View Code Duplication |
public function filterByInput($input = null, $comparison = null) |
|
|
|
|
398
|
|
|
{ |
399
|
|
|
if (null === $comparison) { |
400
|
|
|
if (is_array($input)) { |
401
|
|
|
$comparison = Criteria::IN; |
402
|
|
|
} elseif (preg_match('/[\%\*]/', $input)) { |
403
|
|
|
$input = str_replace('*', '%', $input); |
404
|
|
|
$comparison = Criteria::LIKE; |
405
|
|
|
} |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
return $this->addUsingAlias(InputTableMap::COL_INPUT, $input, $comparison); |
409
|
|
|
} |
410
|
|
|
|
411
|
|
|
/** |
412
|
|
|
* Filter the query on the network column |
413
|
|
|
* |
414
|
|
|
* Example usage: |
415
|
|
|
* <code> |
416
|
|
|
* $query->filterByNetwork('fooValue'); // WHERE network = 'fooValue' |
417
|
|
|
* $query->filterByNetwork('%fooValue%'); // WHERE network LIKE '%fooValue%' |
418
|
|
|
* </code> |
419
|
|
|
* |
420
|
|
|
* @param string $network The value to use as filter. |
421
|
|
|
* Accepts wildcards (* and % trigger a LIKE) |
422
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
423
|
|
|
* |
424
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
425
|
|
|
*/ |
426
|
|
View Code Duplication |
public function filterByNetwork($network = null, $comparison = null) |
|
|
|
|
427
|
|
|
{ |
428
|
|
|
if (null === $comparison) { |
429
|
|
|
if (is_array($network)) { |
430
|
|
|
$comparison = Criteria::IN; |
431
|
|
|
} elseif (preg_match('/[\%\*]/', $network)) { |
432
|
|
|
$network = str_replace('*', '%', $network); |
433
|
|
|
$comparison = Criteria::LIKE; |
434
|
|
|
} |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
return $this->addUsingAlias(InputTableMap::COL_NETWORK, $network, $comparison); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* Filter the query on the mux column |
442
|
|
|
* |
443
|
|
|
* Example usage: |
444
|
|
|
* <code> |
445
|
|
|
* $query->filterByMux('fooValue'); // WHERE mux = 'fooValue' |
446
|
|
|
* $query->filterByMux('%fooValue%'); // WHERE mux LIKE '%fooValue%' |
447
|
|
|
* </code> |
448
|
|
|
* |
449
|
|
|
* @param string $mux The value to use as filter. |
450
|
|
|
* Accepts wildcards (* and % trigger a LIKE) |
451
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
452
|
|
|
* |
453
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
454
|
|
|
*/ |
455
|
|
View Code Duplication |
public function filterByMux($mux = null, $comparison = null) |
|
|
|
|
456
|
|
|
{ |
457
|
|
|
if (null === $comparison) { |
458
|
|
|
if (is_array($mux)) { |
459
|
|
|
$comparison = Criteria::IN; |
460
|
|
|
} elseif (preg_match('/[\%\*]/', $mux)) { |
461
|
|
|
$mux = str_replace('*', '%', $mux); |
462
|
|
|
$comparison = Criteria::LIKE; |
463
|
|
|
} |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
return $this->addUsingAlias(InputTableMap::COL_MUX, $mux, $comparison); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* Filter the query on the weight column |
471
|
|
|
* |
472
|
|
|
* Example usage: |
473
|
|
|
* <code> |
474
|
|
|
* $query->filterByWeight(1234); // WHERE weight = 1234 |
475
|
|
|
* $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34) |
476
|
|
|
* $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 |
477
|
|
|
* </code> |
478
|
|
|
* |
479
|
|
|
* @param mixed $weight The value to use as filter. |
480
|
|
|
* Use scalar values for equality. |
481
|
|
|
* Use array values for in_array() equivalent. |
482
|
|
|
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
483
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
484
|
|
|
* |
485
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
486
|
|
|
*/ |
487
|
|
|
public function filterByWeight($weight = null, $comparison = null) |
488
|
|
|
{ |
489
|
|
|
if (is_array($weight)) { |
490
|
|
|
$useMinMax = false; |
491
|
|
|
if (isset($weight['min'])) { |
492
|
|
|
$this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); |
493
|
|
|
$useMinMax = true; |
494
|
|
|
} |
495
|
|
|
if (isset($weight['max'])) { |
496
|
|
|
$this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight['max'], Criteria::LESS_EQUAL); |
497
|
|
|
$useMinMax = true; |
498
|
|
|
} |
499
|
|
|
if ($useMinMax) { |
500
|
|
|
return $this; |
501
|
|
|
} |
502
|
|
|
if (null === $comparison) { |
503
|
|
|
$comparison = Criteria::IN; |
504
|
|
|
} |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
return $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight, $comparison); |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
/** |
511
|
|
|
* Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
512
|
|
|
* |
513
|
|
|
* @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
514
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
515
|
|
|
* |
516
|
|
|
* @throws \Propel\Runtime\Exception\PropelException |
517
|
|
|
* |
518
|
|
|
* @return ChildInputQuery The current query, for fluid interface |
519
|
|
|
*/ |
520
|
|
View Code Duplication |
public function filterByInstance($instance, $comparison = null) |
|
|
|
|
521
|
|
|
{ |
522
|
|
|
if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
523
|
|
|
return $this |
524
|
|
|
->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
525
|
|
|
} elseif ($instance instanceof ObjectCollection) { |
526
|
|
|
if (null === $comparison) { |
527
|
|
|
$comparison = Criteria::IN; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
return $this |
531
|
|
|
->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
532
|
|
|
} else { |
533
|
|
|
throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
534
|
|
|
} |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* Adds a JOIN clause to the query using the Instance relation |
539
|
|
|
* |
540
|
|
|
* @param string $relationAlias optional alias for the relation |
541
|
|
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
542
|
|
|
* |
543
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
544
|
|
|
*/ |
545
|
|
View Code Duplication |
public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
|
|
|
546
|
|
|
{ |
547
|
|
|
$tableMap = $this->getTableMap(); |
548
|
|
|
$relationMap = $tableMap->getRelation('Instance'); |
549
|
|
|
|
550
|
|
|
// create a ModelJoin object for this join |
551
|
|
|
$join = new ModelJoin(); |
552
|
|
|
$join->setJoinType($joinType); |
553
|
|
|
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
554
|
|
|
if ($previousJoin = $this->getPreviousJoin()) { |
555
|
|
|
$join->setPreviousJoin($previousJoin); |
|
|
|
|
556
|
|
|
} |
557
|
|
|
|
558
|
|
|
// add the ModelJoin to the current object |
559
|
|
|
if ($relationAlias) { |
|
|
|
|
560
|
|
|
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
561
|
|
|
$this->addJoinObject($join, $relationAlias); |
562
|
|
|
} else { |
563
|
|
|
$this->addJoinObject($join, 'Instance'); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
return $this; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
/** |
570
|
|
|
* Use the Instance relation Instance object |
571
|
|
|
* |
572
|
|
|
* @see useQuery() |
573
|
|
|
* |
574
|
|
|
* @param string $relationAlias optional alias for the relation, |
575
|
|
|
* to be used as main alias in the secondary query |
576
|
|
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
577
|
|
|
* |
578
|
|
|
* @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
579
|
|
|
*/ |
580
|
|
|
public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
581
|
|
|
{ |
582
|
|
|
return $this |
583
|
|
|
->joinInstance($relationAlias, $joinType) |
584
|
|
|
->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
589
|
|
|
* |
590
|
|
|
* @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
591
|
|
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
592
|
|
|
* |
593
|
|
|
* @return ChildInputQuery The current query, for fluid interface |
594
|
|
|
*/ |
595
|
|
View Code Duplication |
public function filterBySubscription($subscription, $comparison = null) |
|
|
|
|
596
|
|
|
{ |
597
|
|
|
if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
598
|
|
|
return $this |
599
|
|
|
->addUsingAlias(InputTableMap::COL_UUID, $subscription->getInputUuid(), $comparison); |
600
|
|
|
} elseif ($subscription instanceof ObjectCollection) { |
601
|
|
|
return $this |
|
|
|
|
602
|
|
|
->useSubscriptionQuery() |
603
|
|
|
->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
604
|
|
|
->endUse(); |
605
|
|
|
} else { |
606
|
|
|
throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
607
|
|
|
} |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
/** |
611
|
|
|
* Adds a JOIN clause to the query using the Subscription relation |
612
|
|
|
* |
613
|
|
|
* @param string $relationAlias optional alias for the relation |
614
|
|
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
615
|
|
|
* |
616
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
617
|
|
|
*/ |
618
|
|
View Code Duplication |
public function joinSubscription($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
|
|
|
619
|
|
|
{ |
620
|
|
|
$tableMap = $this->getTableMap(); |
621
|
|
|
$relationMap = $tableMap->getRelation('Subscription'); |
622
|
|
|
|
623
|
|
|
// create a ModelJoin object for this join |
624
|
|
|
$join = new ModelJoin(); |
625
|
|
|
$join->setJoinType($joinType); |
626
|
|
|
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
627
|
|
|
if ($previousJoin = $this->getPreviousJoin()) { |
628
|
|
|
$join->setPreviousJoin($previousJoin); |
|
|
|
|
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
// add the ModelJoin to the current object |
632
|
|
|
if ($relationAlias) { |
|
|
|
|
633
|
|
|
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
634
|
|
|
$this->addJoinObject($join, $relationAlias); |
635
|
|
|
} else { |
636
|
|
|
$this->addJoinObject($join, 'Subscription'); |
637
|
|
|
} |
638
|
|
|
|
639
|
|
|
return $this; |
640
|
|
|
} |
641
|
|
|
|
642
|
|
|
/** |
643
|
|
|
* Use the Subscription relation Subscription object |
644
|
|
|
* |
645
|
|
|
* @see useQuery() |
646
|
|
|
* |
647
|
|
|
* @param string $relationAlias optional alias for the relation, |
648
|
|
|
* to be used as main alias in the secondary query |
649
|
|
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
650
|
|
|
* |
651
|
|
|
* @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
652
|
|
|
*/ |
653
|
|
|
public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
654
|
|
|
{ |
655
|
|
|
return $this |
656
|
|
|
->joinSubscription($relationAlias, $joinType) |
657
|
|
|
->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
658
|
|
|
} |
659
|
|
|
|
660
|
|
|
/** |
661
|
|
|
* Exclude object from result |
662
|
|
|
* |
663
|
|
|
* @param ChildInput $input Object to remove from the list of results |
664
|
|
|
* |
665
|
|
|
* @return $this|ChildInputQuery The current query, for fluid interface |
666
|
|
|
*/ |
667
|
|
|
public function prune($input = null) |
668
|
|
|
{ |
669
|
|
|
if ($input) { |
670
|
|
|
$this->addUsingAlias(InputTableMap::COL_UUID, $input->getUuid(), Criteria::NOT_EQUAL); |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
return $this; |
674
|
|
|
} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* Deletes all rows from the input table. |
678
|
|
|
* |
679
|
|
|
* @param ConnectionInterface $con the connection to use |
680
|
|
|
* @return int The number of affected rows (if supported by underlying database driver). |
681
|
|
|
*/ |
682
|
|
|
public function doDeleteAll(ConnectionInterface $con = null) |
683
|
|
|
{ |
684
|
|
|
if (null === $con) { |
685
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
686
|
|
|
} |
687
|
|
|
|
688
|
|
|
// use transaction because $criteria could contain info |
689
|
|
|
// for more than one table or we could emulating ON DELETE CASCADE, etc. |
690
|
|
|
return $con->transaction(function () use ($con) { |
691
|
|
|
$affectedRows = 0; // initialize var to track total num of affected rows |
692
|
|
|
$affectedRows += parent::doDeleteAll($con); |
693
|
|
|
// Because this db requires some delete cascade/set null emulation, we have to |
694
|
|
|
// clear the cached instance *after* the emulation has happened (since |
695
|
|
|
// instances get re-added by the select statement contained therein). |
696
|
|
|
InputTableMap::clearInstancePool(); |
697
|
|
|
InputTableMap::clearRelatedInstancePool(); |
698
|
|
|
|
699
|
|
|
return $affectedRows; |
700
|
|
|
}); |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
/** |
704
|
|
|
* Performs a DELETE on the database based on the current ModelCriteria |
705
|
|
|
* |
706
|
|
|
* @param ConnectionInterface $con the connection to use |
707
|
|
|
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
708
|
|
|
* if supported by native driver or if emulated using Propel. |
709
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
710
|
|
|
* rethrown wrapped into a PropelException. |
711
|
|
|
*/ |
712
|
|
View Code Duplication |
public function delete(ConnectionInterface $con = null) |
|
|
|
|
713
|
|
|
{ |
714
|
|
|
if (null === $con) { |
715
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
$criteria = $this; |
719
|
|
|
|
720
|
|
|
// Set the correct dbName |
721
|
|
|
$criteria->setDbName(InputTableMap::DATABASE_NAME); |
722
|
|
|
|
723
|
|
|
// use transaction because $criteria could contain info |
724
|
|
|
// for more than one table or we could emulating ON DELETE CASCADE, etc. |
725
|
|
|
return $con->transaction(function () use ($con, $criteria) { |
726
|
|
|
$affectedRows = 0; // initialize var to track total num of affected rows |
727
|
|
|
|
728
|
|
|
InputTableMap::removeInstanceFromPool($criteria); |
729
|
|
|
|
730
|
|
|
$affectedRows += ModelCriteria::delete($con); |
731
|
|
|
InputTableMap::clearRelatedInstancePool(); |
732
|
|
|
|
733
|
|
|
return $affectedRows; |
734
|
|
|
}); |
735
|
|
|
} |
736
|
|
|
|
737
|
|
|
} // InputQuery |
738
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.