BannerImageI18nQuery   F
last analyzed

Complexity

Total Complexity 83

Size/Duplication

Total Lines 538
Duplicated Lines 51.86 %

Coupling/Cohesion

Components 4
Dependencies 14

Importance

Changes 0
Metric Value
dl 279
loc 538
rs 2
c 0
b 0
f 0
wmc 83
lcom 4
cbo 14

20 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 15 15 4
D findPk() 27 27 20
B findPkSimple() 23 23 9
A findPkComplex() 10 10 2
A findPks() 13 13 3
A filterByPrimaryKey() 0 7 1
A filterByPrimaryKeys() 14 14 3
B filterById() 22 22 6
A filterByLocale() 10 10 3
A filterBySrc() 10 10 3
A filterByName() 10 10 3
B filterByClicks() 22 22 6
A filterByDescription() 10 10 3
A filterByBannerImage() 16 16 4
A joinBannerImage() 23 23 4
A useBannerImageQuery() 0 6 2
A prune() 10 10 2
A doDeleteAll() 20 20 2
A delete() 24 24 2

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 BannerImageI18nQuery 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 BannerImageI18nQuery, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace xbanners\models\Base;
4
5
use \Exception;
6
use \PDO;
7
use Propel\Runtime\Propel;
8
use Propel\Runtime\ActiveQuery\Criteria;
9
use Propel\Runtime\ActiveQuery\ModelCriteria;
10
use Propel\Runtime\ActiveQuery\ModelJoin;
11
use Propel\Runtime\Collection\ObjectCollection;
12
use Propel\Runtime\Connection\ConnectionInterface;
13
use Propel\Runtime\Exception\PropelException;
14
use xbanners\models\BannerImageI18n as ChildBannerImageI18n;
15
use xbanners\models\BannerImageI18nQuery as ChildBannerImageI18nQuery;
16
use xbanners\models\Map\BannerImageI18nTableMap;
17
18
/**
19
 * Base class that represents a query for the 'banner_image_i18n' table.
20
 *
21
 *
22
 *
23
 * @method     ChildBannerImageI18nQuery orderById($order = Criteria::ASC) Order by the id column
24
 * @method     ChildBannerImageI18nQuery orderByLocale($order = Criteria::ASC) Order by the locale column
25
 * @method     ChildBannerImageI18nQuery orderBySrc($order = Criteria::ASC) Order by the src column
26
 * @method     ChildBannerImageI18nQuery orderByName($order = Criteria::ASC) Order by the name column
27
 * @method     ChildBannerImageI18nQuery orderByClicks($order = Criteria::ASC) Order by the clicks column
28
 * @method     ChildBannerImageI18nQuery orderByDescription($order = Criteria::ASC) Order by the description column
29
 *
30
 * @method     ChildBannerImageI18nQuery groupById() Group by the id column
31
 * @method     ChildBannerImageI18nQuery groupByLocale() Group by the locale column
32
 * @method     ChildBannerImageI18nQuery groupBySrc() Group by the src column
33
 * @method     ChildBannerImageI18nQuery groupByName() Group by the name column
34
 * @method     ChildBannerImageI18nQuery groupByClicks() Group by the clicks column
35
 * @method     ChildBannerImageI18nQuery groupByDescription() Group by the description column
36
 *
37
 * @method     ChildBannerImageI18nQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
38
 * @method     ChildBannerImageI18nQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
39
 * @method     ChildBannerImageI18nQuery innerJoin($relation) Adds a INNER JOIN clause to the query
40
 *
41
 * @method     ChildBannerImageI18nQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
42
 * @method     ChildBannerImageI18nQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
43
 * @method     ChildBannerImageI18nQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
44
 *
45
 * @method     ChildBannerImageI18nQuery leftJoinBannerImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the BannerImage relation
46
 * @method     ChildBannerImageI18nQuery rightJoinBannerImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the BannerImage relation
47
 * @method     ChildBannerImageI18nQuery innerJoinBannerImage($relationAlias = null) Adds a INNER JOIN clause to the query using the BannerImage relation
48
 *
49
 * @method     ChildBannerImageI18nQuery joinWithBannerImage($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the BannerImage relation
50
 *
51
 * @method     ChildBannerImageI18nQuery leftJoinWithBannerImage() Adds a LEFT JOIN clause and with to the query using the BannerImage relation
52
 * @method     ChildBannerImageI18nQuery rightJoinWithBannerImage() Adds a RIGHT JOIN clause and with to the query using the BannerImage relation
53
 * @method     ChildBannerImageI18nQuery innerJoinWithBannerImage() Adds a INNER JOIN clause and with to the query using the BannerImage relation
54
 *
55
 * @method     \xbanners\models\BannerImageQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria
56
 *
57
 * @method     ChildBannerImageI18n findOne(ConnectionInterface $con = null) Return the first ChildBannerImageI18n matching the query
58
 * @method     ChildBannerImageI18n findOneOrCreate(ConnectionInterface $con = null) Return the first ChildBannerImageI18n matching the query, or a new ChildBannerImageI18n object populated from the query conditions when no match is found
59
 *
60
 * @method     ChildBannerImageI18n findOneById(int $id) Return the first ChildBannerImageI18n filtered by the id column
61
 * @method     ChildBannerImageI18n findOneByLocale(string $locale) Return the first ChildBannerImageI18n filtered by the locale column
62
 * @method     ChildBannerImageI18n findOneBySrc(string $src) Return the first ChildBannerImageI18n filtered by the src column
63
 * @method     ChildBannerImageI18n findOneByName(string $name) Return the first ChildBannerImageI18n filtered by the name column
64
 * @method     ChildBannerImageI18n findOneByClicks(int $clicks) Return the first ChildBannerImageI18n filtered by the clicks column
65
 * @method     ChildBannerImageI18n findOneByDescription(string $description) Return the first ChildBannerImageI18n filtered by the description column *
66
67
 * @method     ChildBannerImageI18n requirePk($key, ConnectionInterface $con = null) Return the ChildBannerImageI18n by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
68
 * @method     ChildBannerImageI18n requireOne(ConnectionInterface $con = null) Return the first ChildBannerImageI18n matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
69
 *
70
 * @method     ChildBannerImageI18n requireOneById(int $id) Return the first ChildBannerImageI18n filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
71
 * @method     ChildBannerImageI18n requireOneByLocale(string $locale) Return the first ChildBannerImageI18n filtered by the locale column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
72
 * @method     ChildBannerImageI18n requireOneBySrc(string $src) Return the first ChildBannerImageI18n filtered by the src column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
73
 * @method     ChildBannerImageI18n requireOneByName(string $name) Return the first ChildBannerImageI18n filtered by the name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
74
 * @method     ChildBannerImageI18n requireOneByClicks(int $clicks) Return the first ChildBannerImageI18n filtered by the clicks column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
75
 * @method     ChildBannerImageI18n requireOneByDescription(string $description) Return the first ChildBannerImageI18n filtered by the description column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
76
 *
77
 * @method     ChildBannerImageI18n[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildBannerImageI18n objects based on current ModelCriteria
78
 * @method     ChildBannerImageI18n[]|ObjectCollection findById(int $id) Return ChildBannerImageI18n objects filtered by the id column
79
 * @method     ChildBannerImageI18n[]|ObjectCollection findByLocale(string $locale) Return ChildBannerImageI18n objects filtered by the locale column
80
 * @method     ChildBannerImageI18n[]|ObjectCollection findBySrc(string $src) Return ChildBannerImageI18n objects filtered by the src column
81
 * @method     ChildBannerImageI18n[]|ObjectCollection findByName(string $name) Return ChildBannerImageI18n objects filtered by the name column
82
 * @method     ChildBannerImageI18n[]|ObjectCollection findByClicks(int $clicks) Return ChildBannerImageI18n objects filtered by the clicks column
83
 * @method     ChildBannerImageI18n[]|ObjectCollection findByDescription(string $description) Return ChildBannerImageI18n objects filtered by the description column
84
 * @method     ChildBannerImageI18n[]|\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
85
 *
86
 */
87
abstract class BannerImageI18nQuery extends ModelCriteria
88
{
89
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
90
91
    /**
92
     * Initializes internal state of \xbanners\models\Base\BannerImageI18nQuery object.
93
     *
94
     * @param     string $dbName The database name
95
     * @param     string $modelName The phpName of a model, e.g. 'Book'
96
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
97
     */
98
    public function __construct($dbName = 'Shop', $modelName = '\\xbanners\\models\\BannerImageI18n', $modelAlias = null)
99
    {
100
        parent::__construct($dbName, $modelName, $modelAlias);
101
    }
102
103
    /**
104
     * Returns a new ChildBannerImageI18nQuery object.
105
     *
106
     * @param     string $modelAlias The alias of a model in the query
107
     * @param     Criteria $criteria Optional Criteria to build the query from
108
     *
109
     * @return ChildBannerImageI18nQuery
110
     */
111 View Code Duplication
    public static function create($modelAlias = null, Criteria $criteria = null)
112
    {
113
        if ($criteria instanceof ChildBannerImageI18nQuery) {
114
            return $criteria;
115
        }
116
        $query = new ChildBannerImageI18nQuery();
117
        if (null !== $modelAlias) {
118
            $query->setModelAlias($modelAlias);
119
        }
120
        if ($criteria instanceof Criteria) {
121
            $query->mergeWith($criteria);
122
        }
123
124
        return $query;
125
    }
126
127
    /**
128
     * Find object by primary key.
129
     * Propel uses the instance pool to skip the database if the object exists.
130
     * Go fast if the query is untouched.
131
     *
132
     * <code>
133
     * $obj = $c->findPk(array(12, 34), $con);
134
     * </code>
135
     *
136
     * @param array[$id, $locale] $key Primary key to use for the query
0 ignored issues
show
Documentation introduced by
The doc-type array[$id, could not be parsed: Expected "]" at position 2, but found "$id". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
Bug introduced by
There is no parameter named $locale]. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
137
     * @param ConnectionInterface $con an optional connection object
138
     *
139
     * @return ChildBannerImageI18n|array|mixed the result, formatted by the current formatter
140
     */
141 View Code Duplication
    public function findPk($key, ConnectionInterface $con = null)
142
    {
143
        if ($key === null) {
144
            return null;
145
        }
146
147
        if ($con === null) {
148
            $con = Propel::getServiceContainer()->getReadConnection(BannerImageI18nTableMap::DATABASE_NAME);
149
        }
150
151
        $this->basePreSelect($con);
152
153
        if (
154
            $this->formatter || $this->modelAlias || $this->with || $this->select
155
            || $this->selectColumns || $this->asColumns || $this->selectModifiers
156
            || $this->map || $this->having || $this->joins
157
        ) {
158
            return $this->findPkComplex($key, $con);
159
        }
160
161
        if ((null !== ($obj = BannerImageI18nTableMap::getInstanceFromPool(serialize([(null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0]), (null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1])]))))) {
162
            // the object is already in the instance pool
163
            return $obj;
164
        }
165
166
        return $this->findPkSimple($key, $con);
167
    }
168
169
    /**
170
     * Find object by primary key using raw SQL to go fast.
171
     * Bypass doSelect() and the object formatter by using generated code.
172
     *
173
     * @param     mixed $key Primary key to use for the query
174
     * @param     ConnectionInterface $con A connection object
175
     *
176
     * @throws \Propel\Runtime\Exception\PropelException
177
     *
178
     * @return ChildBannerImageI18n A model object, or null if the key is not found
0 ignored issues
show
Documentation introduced by
Should the return type not be ChildBannerImageI18n|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
179
     */
180 View Code Duplication
    protected function findPkSimple($key, ConnectionInterface $con)
181
    {
182
        $sql = 'SELECT id, locale, src, name, clicks, description FROM banner_image_i18n WHERE id = :p0 AND locale = :p1';
183
        try {
184
            $stmt = $con->prepare($sql);
185
            $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT);
186
            $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR);
187
            $stmt->execute();
188
        } catch (Exception $e) {
189
            Propel::log($e->getMessage(), Propel::LOG_ERR);
190
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
191
        }
192
        $obj = null;
193
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
194
            /** @var ChildBannerImageI18n $obj */
195
            $obj = new ChildBannerImageI18n();
196
            $obj->hydrate($row);
197
            BannerImageI18nTableMap::addInstanceToPool($obj, serialize([(null === $key[0] || is_scalar($key[0]) || is_callable([$key[0], '__toString']) ? (string) $key[0] : $key[0]), (null === $key[1] || is_scalar($key[1]) || is_callable([$key[1], '__toString']) ? (string) $key[1] : $key[1])]));
198
        }
199
        $stmt->closeCursor();
200
201
        return $obj;
202
    }
203
204
    /**
205
     * Find object by primary key.
206
     *
207
     * @param     mixed $key Primary key to use for the query
208
     * @param     ConnectionInterface $con A connection object
209
     *
210
     * @return ChildBannerImageI18n|array|mixed the result, formatted by the current formatter
211
     */
212 View Code Duplication
    protected function findPkComplex($key, ConnectionInterface $con)
213
    {
214
        // As the query uses a PK condition, no limit(1) is necessary.
215
        $criteria = $this->isKeepQuery() ? clone $this : $this;
216
        $dataFetcher = $criteria
217
            ->filterByPrimaryKey($key)
218
            ->doSelect($con);
219
220
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
221
    }
222
223
    /**
224
     * Find objects by primary key
225
     * <code>
226
     * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con);
227
     * </code>
228
     * @param     array $keys Primary keys to use for the query
229
     * @param     ConnectionInterface $con an optional connection object
230
     *
231
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
232
     */
233 View Code Duplication
    public function findPks($keys, ConnectionInterface $con = null)
234
    {
235
        if (null === $con) {
236
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
237
        }
238
        $this->basePreSelect($con);
239
        $criteria = $this->isKeepQuery() ? clone $this : $this;
240
        $dataFetcher = $criteria
241
            ->filterByPrimaryKeys($keys)
242
            ->doSelect($con);
243
244
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
245
    }
246
247
    /**
248
     * Filter the query by primary key
249
     *
250
     * @param     mixed $key Primary key to use for the query
251
     *
252
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
253
     */
254
    public function filterByPrimaryKey($key)
255
    {
256
        $this->addUsingAlias(BannerImageI18nTableMap::COL_ID, $key[0], Criteria::EQUAL);
257
        $this->addUsingAlias(BannerImageI18nTableMap::COL_LOCALE, $key[1], Criteria::EQUAL);
258
259
        return $this;
260
    }
261
262
    /**
263
     * Filter the query by a list of primary keys
264
     *
265
     * @param     array $keys The list of primary key to use for the query
266
     *
267
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
268
     */
269 View Code Duplication
    public function filterByPrimaryKeys($keys)
270
    {
271
        if (empty($keys)) {
272
            return $this->add(null, '1<>1', Criteria::CUSTOM);
273
        }
274
        foreach ($keys as $key) {
275
            $cton0 = $this->getNewCriterion(BannerImageI18nTableMap::COL_ID, $key[0], Criteria::EQUAL);
276
            $cton1 = $this->getNewCriterion(BannerImageI18nTableMap::COL_LOCALE, $key[1], Criteria::EQUAL);
277
            $cton0->addAnd($cton1);
278
            $this->addOr($cton0);
279
        }
280
281
        return $this;
282
    }
283
284
    /**
285
     * Filter the query on the id column
286
     *
287
     * Example usage:
288
     * <code>
289
     * $query->filterById(1234); // WHERE id = 1234
290
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
291
     * $query->filterById(array('min' => 12)); // WHERE id > 12
292
     * </code>
293
     *
294
     * @see       filterByBannerImage()
295
     *
296
     * @param     mixed $id The value to use as filter.
297
     *              Use scalar values for equality.
298
     *              Use array values for in_array() equivalent.
299
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
300
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
301
     *
302
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
303
     */
304 View Code Duplication
    public function filterById($id = null, $comparison = null)
305
    {
306
        if (is_array($id)) {
307
            $useMinMax = false;
308
            if (isset($id['min'])) {
309
                $this->addUsingAlias(BannerImageI18nTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
310
                $useMinMax = true;
311
            }
312
            if (isset($id['max'])) {
313
                $this->addUsingAlias(BannerImageI18nTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
314
                $useMinMax = true;
315
            }
316
            if ($useMinMax) {
317
                return $this;
318
            }
319
            if (null === $comparison) {
320
                $comparison = Criteria::IN;
321
            }
322
        }
323
324
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_ID, $id, $comparison);
325
    }
326
327
    /**
328
     * Filter the query on the locale column
329
     *
330
     * Example usage:
331
     * <code>
332
     * $query->filterByLocale('fooValue');   // WHERE locale = 'fooValue'
333
     * $query->filterByLocale('%fooValue%', Criteria::LIKE); // WHERE locale LIKE '%fooValue%'
334
     * </code>
335
     *
336
     * @param     string $locale The value to use as filter.
337
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
338
     *
339
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
340
     */
341 View Code Duplication
    public function filterByLocale($locale = null, $comparison = null)
342
    {
343
        if (null === $comparison) {
344
            if (is_array($locale)) {
345
                $comparison = Criteria::IN;
346
            }
347
        }
348
349
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_LOCALE, $locale, $comparison);
350
    }
351
352
    /**
353
     * Filter the query on the src column
354
     *
355
     * Example usage:
356
     * <code>
357
     * $query->filterBySrc('fooValue');   // WHERE src = 'fooValue'
358
     * $query->filterBySrc('%fooValue%', Criteria::LIKE); // WHERE src LIKE '%fooValue%'
359
     * </code>
360
     *
361
     * @param     string $src The value to use as filter.
362
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
363
     *
364
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
365
     */
366 View Code Duplication
    public function filterBySrc($src = null, $comparison = null)
367
    {
368
        if (null === $comparison) {
369
            if (is_array($src)) {
370
                $comparison = Criteria::IN;
371
            }
372
        }
373
374
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_SRC, $src, $comparison);
375
    }
376
377
    /**
378
     * Filter the query on the name column
379
     *
380
     * Example usage:
381
     * <code>
382
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
383
     * $query->filterByName('%fooValue%', Criteria::LIKE); // WHERE name LIKE '%fooValue%'
384
     * </code>
385
     *
386
     * @param     string $name The value to use as filter.
387
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
388
     *
389
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
390
     */
391 View Code Duplication
    public function filterByName($name = null, $comparison = null)
392
    {
393
        if (null === $comparison) {
394
            if (is_array($name)) {
395
                $comparison = Criteria::IN;
396
            }
397
        }
398
399
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_NAME, $name, $comparison);
400
    }
401
402
    /**
403
     * Filter the query on the clicks column
404
     *
405
     * Example usage:
406
     * <code>
407
     * $query->filterByClicks(1234); // WHERE clicks = 1234
408
     * $query->filterByClicks(array(12, 34)); // WHERE clicks IN (12, 34)
409
     * $query->filterByClicks(array('min' => 12)); // WHERE clicks > 12
410
     * </code>
411
     *
412
     * @param     mixed $clicks The value to use as filter.
413
     *              Use scalar values for equality.
414
     *              Use array values for in_array() equivalent.
415
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
416
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
417
     *
418
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
419
     */
420 View Code Duplication
    public function filterByClicks($clicks = null, $comparison = null)
421
    {
422
        if (is_array($clicks)) {
423
            $useMinMax = false;
424
            if (isset($clicks['min'])) {
425
                $this->addUsingAlias(BannerImageI18nTableMap::COL_CLICKS, $clicks['min'], Criteria::GREATER_EQUAL);
426
                $useMinMax = true;
427
            }
428
            if (isset($clicks['max'])) {
429
                $this->addUsingAlias(BannerImageI18nTableMap::COL_CLICKS, $clicks['max'], Criteria::LESS_EQUAL);
430
                $useMinMax = true;
431
            }
432
            if ($useMinMax) {
433
                return $this;
434
            }
435
            if (null === $comparison) {
436
                $comparison = Criteria::IN;
437
            }
438
        }
439
440
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_CLICKS, $clicks, $comparison);
441
    }
442
443
    /**
444
     * Filter the query on the description column
445
     *
446
     * Example usage:
447
     * <code>
448
     * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue'
449
     * $query->filterByDescription('%fooValue%', Criteria::LIKE); // WHERE description LIKE '%fooValue%'
450
     * </code>
451
     *
452
     * @param     string $description The value to use as filter.
453
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
454
     *
455
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
456
     */
457 View Code Duplication
    public function filterByDescription($description = null, $comparison = null)
458
    {
459
        if (null === $comparison) {
460
            if (is_array($description)) {
461
                $comparison = Criteria::IN;
462
            }
463
        }
464
465
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_DESCRIPTION, $description, $comparison);
466
    }
467
468
    /**
469
     * Filter the query by a related \xbanners\models\BannerImage object
470
     *
471
     * @param \xbanners\models\BannerImage|ObjectCollection $bannerImage The related object(s) to use as filter
472
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
473
     *
474
     * @throws \Propel\Runtime\Exception\PropelException
475
     *
476
     * @return ChildBannerImageI18nQuery The current query, for fluid interface
477
     */
478 View Code Duplication
    public function filterByBannerImage($bannerImage, $comparison = null)
479
    {
480
        if ($bannerImage instanceof \xbanners\models\BannerImage) {
481
            return $this
482
                ->addUsingAlias(BannerImageI18nTableMap::COL_ID, $bannerImage->getId(), $comparison);
483
        } elseif ($bannerImage instanceof ObjectCollection) {
484
            if (null === $comparison) {
485
                $comparison = Criteria::IN;
486
            }
487
488
            return $this
489
                ->addUsingAlias(BannerImageI18nTableMap::COL_ID, $bannerImage->toKeyValue('PrimaryKey', 'Id'), $comparison);
490
        } else {
491
            throw new PropelException('filterByBannerImage() only accepts arguments of type \xbanners\models\BannerImage or Collection');
492
        }
493
    }
494
495
    /**
496
     * Adds a JOIN clause to the query using the BannerImage relation
497
     *
498
     * @param     string $relationAlias optional alias for the relation
499
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
500
     *
501
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
502
     */
503 View Code Duplication
    public function joinBannerImage($relationAlias = null, $joinType = 'LEFT JOIN')
504
    {
505
        $tableMap = $this->getTableMap();
506
        $relationMap = $tableMap->getRelation('BannerImage');
507
508
        // create a ModelJoin object for this join
509
        $join = new ModelJoin();
510
        $join->setJoinType($joinType);
511
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
512
        if ($previousJoin = $this->getPreviousJoin()) {
513
            $join->setPreviousJoin($previousJoin);
0 ignored issues
show
Compatibility introduced by
$previousJoin of type object<Propel\Runtime\ActiveQuery\Join> is not a sub-type of object<Propel\Runtime\ActiveQuery\ModelJoin>. It seems like you assume a child class of the class Propel\Runtime\ActiveQuery\Join to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
514
        }
515
516
        // add the ModelJoin to the current object
517
        if ($relationAlias) {
518
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
519
            $this->addJoinObject($join, $relationAlias);
520
        } else {
521
            $this->addJoinObject($join, 'BannerImage');
522
        }
523
524
        return $this;
525
    }
526
527
    /**
528
     * Use the BannerImage relation BannerImage object
529
     *
530
     * @see useQuery()
531
     *
532
     * @param     string $relationAlias optional alias for the relation,
533
     *                                   to be used as main alias in the secondary query
534
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
535
     *
536
     * @return \xbanners\models\BannerImageQuery A secondary query class using the current class as primary query
537
     */
538
    public function useBannerImageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
539
    {
540
        return $this
541
            ->joinBannerImage($relationAlias, $joinType)
542
            ->useQuery($relationAlias ? $relationAlias : 'BannerImage', '\xbanners\models\BannerImageQuery');
543
    }
544
545
    /**
546
     * Exclude object from result
547
     *
548
     * @param   ChildBannerImageI18n $bannerImageI18n Object to remove from the list of results
549
     *
550
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
551
     */
552 View Code Duplication
    public function prune($bannerImageI18n = null)
553
    {
554
        if ($bannerImageI18n) {
555
            $this->addCond('pruneCond0', $this->getAliasedColName(BannerImageI18nTableMap::COL_ID), $bannerImageI18n->getId(), Criteria::NOT_EQUAL);
556
            $this->addCond('pruneCond1', $this->getAliasedColName(BannerImageI18nTableMap::COL_LOCALE), $bannerImageI18n->getLocale(), Criteria::NOT_EQUAL);
557
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
558
        }
559
560
        return $this;
561
    }
562
563
    /**
564
     * Deletes all rows from the banner_image_i18n table.
565
     *
566
     * @param ConnectionInterface $con the connection to use
567
     * @return int The number of affected rows (if supported by underlying database driver).
568
     */
569 View Code Duplication
    public function doDeleteAll(ConnectionInterface $con = null)
570
    {
571
        if (null === $con) {
572
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageI18nTableMap::DATABASE_NAME);
573
        }
574
575
        // use transaction because $criteria could contain info
576
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
577
        return $con->transaction(function () use ($con) {
578
            $affectedRows = 0; // initialize var to track total num of affected rows
579
            $affectedRows += parent::doDeleteAll($con);
580
            // Because this db requires some delete cascade/set null emulation, we have to
581
            // clear the cached instance *after* the emulation has happened (since
582
            // instances get re-added by the select statement contained therein).
583
            BannerImageI18nTableMap::clearInstancePool();
584
            BannerImageI18nTableMap::clearRelatedInstancePool();
585
586
            return $affectedRows;
587
        });
588
    }
589
590
    /**
591
     * Performs a DELETE on the database based on the current ModelCriteria
592
     *
593
     * @param ConnectionInterface $con the connection to use
594
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
595
     *                         if supported by native driver or if emulated using Propel.
596
     * @throws PropelException Any exceptions caught during processing will be
597
     *                         rethrown wrapped into a PropelException.
598
     */
599 View Code Duplication
    public function delete(ConnectionInterface $con = null)
600
    {
601
        if (null === $con) {
602
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageI18nTableMap::DATABASE_NAME);
603
        }
604
605
        $criteria = $this;
606
607
        // Set the correct dbName
608
        $criteria->setDbName(BannerImageI18nTableMap::DATABASE_NAME);
609
610
        // use transaction because $criteria could contain info
611
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
612
        return $con->transaction(function () use ($con, $criteria) {
613
            $affectedRows = 0; // initialize var to track total num of affected rows
614
615
            BannerImageI18nTableMap::removeInstanceFromPool($criteria);
616
617
            $affectedRows += ModelCriteria::delete($con);
618
            BannerImageI18nTableMap::clearRelatedInstancePool();
619
620
            return $affectedRows;
621
        });
622
    }
623
624
} // BannerImageI18nQuery
625