Completed
Push — development ( 006c45...63d178 )
by Andrij
19:41 queued 09:38
created

BannerImageI18nQuery   F

Complexity

Total Complexity 87

Size/Duplication

Total Lines 554
Duplicated Lines 20.04 %

Coupling/Cohesion

Components 4
Dependencies 14

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 111
loc 554
rs 1.5789
wmc 87
lcom 4
cbo 14

20 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 15 15 4
D findPk() 0 27 20
A filterByPrimaryKey() 0 7 1
B filterById() 22 22 6
B filterByClicks() 22 22 6
A useBannerImageQuery() 0 6 2
A doDeleteAll() 0 20 2
C findPkSimple() 0 23 9
A findPkComplex() 0 10 2
A findPks() 0 13 3
A filterByPrimaryKeys() 0 14 3
A filterByLocale() 13 13 4
A filterBySrc() 13 13 4
A filterByName() 13 13 4
A filterByDescription() 13 13 4
A filterByBannerImage() 0 16 4
B joinBannerImage() 0 23 4
A prune() 0 10 2
B delete() 0 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
 */
0 ignored issues
show
introduced by
Additional blank lines found at end of doc comment
Loading history...
87
abstract class BannerImageI18nQuery extends ModelCriteria
88
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
89
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
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>
0 ignored issues
show
introduced by
Doc comment long description must start with a capital letter
Loading history...
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...
introduced by
Expected 1 spaces after parameter type; 0 found
Loading history...
introduced by
Doc comment for parameter $id, does not match actual variable name $con
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
    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 (
0 ignored issues
show
Coding Style introduced by
First condition of a multi-line IF statement must directly follow the opening parenthesis
Loading history...
154
            $this->formatter || $this->modelAlias || $this->with || $this->select
0 ignored issues
show
Coding Style introduced by
Each line in a multi-line IF statement must begin with a boolean operator
Loading history...
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
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
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
    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
    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
    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
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
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
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
268
     */
269
    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.
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
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
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
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%'); // WHERE locale LIKE '%fooValue%'
334
     * </code>
335
     *
336
     * @param     string $locale The value to use as filter.
337
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
338
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
339
     *
340
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
341
     */
342 View Code Duplication
    public function filterByLocale($locale = null, $comparison = null)
343
    {
344
        if (null === $comparison) {
345
            if (is_array($locale)) {
346
                $comparison = Criteria::IN;
347
            } elseif (preg_match('/[\%\*]/', $locale)) {
348
                $locale = str_replace('*', '%', $locale);
349
                $comparison = Criteria::LIKE;
350
            }
351
        }
352
353
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_LOCALE, $locale, $comparison);
354
    }
355
356
    /**
357
     * Filter the query on the src column
358
     *
359
     * Example usage:
360
     * <code>
361
     * $query->filterBySrc('fooValue');   // WHERE src = 'fooValue'
362
     * $query->filterBySrc('%fooValue%'); // WHERE src LIKE '%fooValue%'
363
     * </code>
364
     *
365
     * @param     string $src The value to use as filter.
366
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
367
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
368
     *
369
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
370
     */
371 View Code Duplication
    public function filterBySrc($src = null, $comparison = null)
372
    {
373
        if (null === $comparison) {
374
            if (is_array($src)) {
375
                $comparison = Criteria::IN;
376
            } elseif (preg_match('/[\%\*]/', $src)) {
377
                $src = str_replace('*', '%', $src);
378
                $comparison = Criteria::LIKE;
379
            }
380
        }
381
382
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_SRC, $src, $comparison);
383
    }
384
385
    /**
386
     * Filter the query on the name column
387
     *
388
     * Example usage:
389
     * <code>
390
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
391
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
392
     * </code>
393
     *
394
     * @param     string $name The value to use as filter.
395
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
396
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
397
     *
398
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
399
     */
400 View Code Duplication
    public function filterByName($name = null, $comparison = null)
401
    {
402
        if (null === $comparison) {
403
            if (is_array($name)) {
404
                $comparison = Criteria::IN;
405
            } elseif (preg_match('/[\%\*]/', $name)) {
406
                $name = str_replace('*', '%', $name);
407
                $comparison = Criteria::LIKE;
408
            }
409
        }
410
411
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_NAME, $name, $comparison);
412
    }
413
414
    /**
415
     * Filter the query on the clicks column
416
     *
417
     * Example usage:
418
     * <code>
419
     * $query->filterByClicks(1234); // WHERE clicks = 1234
420
     * $query->filterByClicks(array(12, 34)); // WHERE clicks IN (12, 34)
421
     * $query->filterByClicks(array('min' => 12)); // WHERE clicks > 12
422
     * </code>
423
     *
424
     * @param     mixed $clicks The value to use as filter.
425
     *              Use scalar values for equality.
426
     *              Use array values for in_array() equivalent.
427
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
428
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
429
     *
430
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
431
     */
432 View Code Duplication
    public function filterByClicks($clicks = null, $comparison = null)
433
    {
434
        if (is_array($clicks)) {
435
            $useMinMax = false;
436
            if (isset($clicks['min'])) {
437
                $this->addUsingAlias(BannerImageI18nTableMap::COL_CLICKS, $clicks['min'], Criteria::GREATER_EQUAL);
438
                $useMinMax = true;
439
            }
440
            if (isset($clicks['max'])) {
441
                $this->addUsingAlias(BannerImageI18nTableMap::COL_CLICKS, $clicks['max'], Criteria::LESS_EQUAL);
442
                $useMinMax = true;
443
            }
444
            if ($useMinMax) {
445
                return $this;
446
            }
447
            if (null === $comparison) {
448
                $comparison = Criteria::IN;
449
            }
450
        }
451
452
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_CLICKS, $clicks, $comparison);
453
    }
454
455
    /**
456
     * Filter the query on the description column
457
     *
458
     * Example usage:
459
     * <code>
460
     * $query->filterByDescription('fooValue');   // WHERE description = 'fooValue'
461
     * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%'
462
     * </code>
463
     *
464
     * @param     string $description The value to use as filter.
465
     *              Accepts wildcards (* and % trigger a LIKE)
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
466
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
467
     *
468
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
469
     */
470 View Code Duplication
    public function filterByDescription($description = null, $comparison = null)
471
    {
472
        if (null === $comparison) {
473
            if (is_array($description)) {
474
                $comparison = Criteria::IN;
475
            } elseif (preg_match('/[\%\*]/', $description)) {
476
                $description = str_replace('*', '%', $description);
477
                $comparison = Criteria::LIKE;
478
            }
479
        }
480
481
        return $this->addUsingAlias(BannerImageI18nTableMap::COL_DESCRIPTION, $description, $comparison);
482
    }
483
484
    /**
485
     * Filter the query by a related \xbanners\models\BannerImage object
486
     *
487
     * @param \xbanners\models\BannerImage|ObjectCollection $bannerImage The related object(s) to use as filter
488
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
489
     *
490
     * @throws \Propel\Runtime\Exception\PropelException
0 ignored issues
show
introduced by
Comment missing or not on the next line for @throws tag in function comment
Loading history...
491
     *
492
     * @return ChildBannerImageI18nQuery The current query, for fluid interface
493
     */
494
    public function filterByBannerImage($bannerImage, $comparison = null)
495
    {
496
        if ($bannerImage instanceof \xbanners\models\BannerImage) {
497
            return $this
498
                ->addUsingAlias(BannerImageI18nTableMap::COL_ID, $bannerImage->getId(), $comparison);
499
        } elseif ($bannerImage instanceof ObjectCollection) {
500
            if (null === $comparison) {
501
                $comparison = Criteria::IN;
502
            }
503
504
            return $this
505
                ->addUsingAlias(BannerImageI18nTableMap::COL_ID, $bannerImage->toKeyValue('PrimaryKey', 'Id'), $comparison);
506
        } else {
507
            throw new PropelException('filterByBannerImage() only accepts arguments of type \xbanners\models\BannerImage or Collection');
508
        }
509
    }
510
511
    /**
512
     * Adds a JOIN clause to the query using the BannerImage relation
513
     *
514
     * @param     string $relationAlias optional alias for the relation
515
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
516
     *
517
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
518
     */
519
    public function joinBannerImage($relationAlias = null, $joinType = 'LEFT JOIN')
520
    {
521
        $tableMap = $this->getTableMap();
522
        $relationMap = $tableMap->getRelation('BannerImage');
523
524
        // create a ModelJoin object for this join
525
        $join = new ModelJoin();
526
        $join->setJoinType($joinType);
527
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
528
        if ($previousJoin = $this->getPreviousJoin()) {
529
            $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...
530
        }
531
532
        // add the ModelJoin to the current object
533
        if ($relationAlias) {
534
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
535
            $this->addJoinObject($join, $relationAlias);
536
        } else {
537
            $this->addJoinObject($join, 'BannerImage');
538
        }
539
540
        return $this;
541
    }
542
543
    /**
544
     * Use the BannerImage relation BannerImage object
545
     *
546
     * @see useQuery()
547
     *
548
     * @param     string $relationAlias optional alias for the relation,
0 ignored issues
show
introduced by
Paramater tags must be defined first in a doc commment
Loading history...
549
     *                                   to be used as main alias in the secondary query
0 ignored issues
show
introduced by
Parameter comment must start with a capital letter
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
550
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
551
     *
552
     * @return \xbanners\models\BannerImageQuery A secondary query class using the current class as primary query
553
     */
554
    public function useBannerImageQuery($relationAlias = null, $joinType = 'LEFT JOIN')
555
    {
556
        return $this
557
            ->joinBannerImage($relationAlias, $joinType)
558
            ->useQuery($relationAlias ? $relationAlias : 'BannerImage', '\xbanners\models\BannerImageQuery');
559
    }
560
561
    /**
562
     * Exclude object from result
563
     *
564
     * @param   ChildBannerImageI18n $bannerImageI18n Object to remove from the list of results
565
     *
566
     * @return $this|ChildBannerImageI18nQuery The current query, for fluid interface
0 ignored issues
show
introduced by
@return data type must not contain "$"
Loading history...
567
     */
568
    public function prune($bannerImageI18n = null)
569
    {
570
        if ($bannerImageI18n) {
571
            $this->addCond('pruneCond0', $this->getAliasedColName(BannerImageI18nTableMap::COL_ID), $bannerImageI18n->getId(), Criteria::NOT_EQUAL);
572
            $this->addCond('pruneCond1', $this->getAliasedColName(BannerImageI18nTableMap::COL_LOCALE), $bannerImageI18n->getLocale(), Criteria::NOT_EQUAL);
573
            $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR);
574
        }
575
576
        return $this;
577
    }
578
579
    /**
580
     * Deletes all rows from the banner_image_i18n table.
581
     *
582
     * @param ConnectionInterface $con the connection to use
583
     * @return int The number of affected rows (if supported by underlying database driver).
584
     */
585
    public function doDeleteAll(ConnectionInterface $con = null)
586
    {
587
        if (null === $con) {
588
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageI18nTableMap::DATABASE_NAME);
589
        }
590
591
        // use transaction because $criteria could contain info
592
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
593
        return $con->transaction(function () use ($con) {
594
            $affectedRows = 0; // initialize var to track total num of affected rows
595
            $affectedRows += parent::doDeleteAll($con);
596
            // Because this db requires some delete cascade/set null emulation, we have to
597
            // clear the cached instance *after* the emulation has happened (since
598
            // instances get re-added by the select statement contained therein).
599
            BannerImageI18nTableMap::clearInstancePool();
600
            BannerImageI18nTableMap::clearRelatedInstancePool();
601
602
            return $affectedRows;
603
        });
604
    }
605
606
    /**
607
     * Performs a DELETE on the database based on the current ModelCriteria
608
     *
609
     * @param ConnectionInterface $con the connection to use
610
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
611
     *                         if supported by native driver or if emulated using Propel.
612
     * @throws PropelException Any exceptions caught during processing will be
613
     *                         rethrown wrapped into a PropelException.
0 ignored issues
show
introduced by
@throws tag comment must start with a capital letter
Loading history...
614
     */
615
    public function delete(ConnectionInterface $con = null)
616
    {
617
        if (null === $con) {
618
            $con = Propel::getServiceContainer()->getWriteConnection(BannerImageI18nTableMap::DATABASE_NAME);
619
        }
620
621
        $criteria = $this;
622
623
        // Set the correct dbName
624
        $criteria->setDbName(BannerImageI18nTableMap::DATABASE_NAME);
625
626
        // use transaction because $criteria could contain info
627
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
628
        return $con->transaction(function () use ($con, $criteria) {
629
            $affectedRows = 0; // initialize var to track total num of affected rows
630
631
            BannerImageI18nTableMap::removeInstanceFromPool($criteria);
632
633
            $affectedRows += ModelCriteria::delete($con);
634
            BannerImageI18nTableMap::clearRelatedInstancePool();
635
636
            return $affectedRows;
637
        });
638
    }
639
640
} // BannerImageI18nQuery
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
641