UserQuery   C
last analyzed

Complexity

Total Complexity 70

Size/Duplication

Total Lines 500
Duplicated Lines 48.6 %

Coupling/Cohesion

Components 2
Dependencies 9

Importance

Changes 0
Metric Value
wmc 70
c 0
b 0
f 0
lcom 2
cbo 9
dl 243
loc 500
rs 5.6163

18 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 15 15 4
C findPk() 21 21 15
A findPkSimple() 22 22 3
A findPkComplex() 10 10 2
A findPks() 13 13 3
A filterByPrimaryKey() 0 5 1
A filterByPrimaryKeys() 0 5 1
B filterById() 22 22 6
A filterByName() 13 13 4
A filterByEmail() 13 13 4
A filterByPassword() 13 13 4
A filterByRememberToken() 13 13 4
B filterByCreatedAt() 22 22 6
B filterByUpdatedAt() 22 22 6
A prune() 0 8 2
A doDeleteAll() 20 20 2
B 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 UserQuery 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 UserQuery, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Core\Models\User\Base;
4
5
use \Exception;
6
use \PDO;
7
use Core\Models\User\User as ChildUser;
8
use Core\Models\User\UserQuery as ChildUserQuery;
9
use Core\Models\User\Map\UserTableMap;
10
use Propel\Runtime\Propel;
11
use Propel\Runtime\ActiveQuery\Criteria;
12
use Propel\Runtime\ActiveQuery\ModelCriteria;
13
use Propel\Runtime\Collection\ObjectCollection;
14
use Propel\Runtime\Connection\ConnectionInterface;
15
use Propel\Runtime\Exception\PropelException;
16
17
/**
18
 * Base class that represents a query for the 'users' table.
19
 *
20
 *
21
 *
22
 * @method     ChildUserQuery orderById($order = Criteria::ASC) Order by the id column
23
 * @method     ChildUserQuery orderByName($order = Criteria::ASC) Order by the name column
24
 * @method     ChildUserQuery orderByEmail($order = Criteria::ASC) Order by the email column
25
 * @method     ChildUserQuery orderByPassword($order = Criteria::ASC) Order by the password column
26
 * @method     ChildUserQuery orderByRememberToken($order = Criteria::ASC) Order by the remember_token column
27
 * @method     ChildUserQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
28
 * @method     ChildUserQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
29
 *
30
 * @method     ChildUserQuery groupById() Group by the id column
31
 * @method     ChildUserQuery groupByName() Group by the name column
32
 * @method     ChildUserQuery groupByEmail() Group by the email column
33
 * @method     ChildUserQuery groupByPassword() Group by the password column
34
 * @method     ChildUserQuery groupByRememberToken() Group by the remember_token column
35
 * @method     ChildUserQuery groupByCreatedAt() Group by the created_at column
36
 * @method     ChildUserQuery groupByUpdatedAt() Group by the updated_at column
37
 *
38
 * @method     ChildUserQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
39
 * @method     ChildUserQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
40
 * @method     ChildUserQuery innerJoin($relation) Adds a INNER JOIN clause to the query
41
 *
42
 * @method     ChildUser findOne(ConnectionInterface $con = null) Return the first ChildUser matching the query
43
 * @method     ChildUser findOneOrCreate(ConnectionInterface $con = null) Return the first ChildUser matching the query, or a new ChildUser object populated from the query conditions when no match is found
44
 *
45
 * @method     ChildUser findOneById(int $id) Return the first ChildUser filtered by the id column
46
 * @method     ChildUser findOneByName(string $name) Return the first ChildUser filtered by the name column
47
 * @method     ChildUser findOneByEmail(string $email) Return the first ChildUser filtered by the email column
48
 * @method     ChildUser findOneByPassword(string $password) Return the first ChildUser filtered by the password column
49
 * @method     ChildUser findOneByRememberToken(string $remember_token) Return the first ChildUser filtered by the remember_token column
50
 * @method     ChildUser findOneByCreatedAt(string $created_at) Return the first ChildUser filtered by the created_at column
51
 * @method     ChildUser findOneByUpdatedAt(string $updated_at) Return the first ChildUser filtered by the updated_at column *
52
53
 * @method     ChildUser requirePk($key, ConnectionInterface $con = null) Return the ChildUser by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
54
 * @method     ChildUser requireOne(ConnectionInterface $con = null) Return the first ChildUser matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
55
 *
56
 * @method     ChildUser requireOneById(int $id) Return the first ChildUser filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
57
 * @method     ChildUser requireOneByName(string $name) Return the first ChildUser filtered by the name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
58
 * @method     ChildUser requireOneByEmail(string $email) Return the first ChildUser filtered by the email column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
59
 * @method     ChildUser requireOneByPassword(string $password) Return the first ChildUser filtered by the password column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
60
 * @method     ChildUser requireOneByRememberToken(string $remember_token) Return the first ChildUser filtered by the remember_token column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
61
 * @method     ChildUser requireOneByCreatedAt(string $created_at) Return the first ChildUser filtered by the created_at column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
62
 * @method     ChildUser requireOneByUpdatedAt(string $updated_at) Return the first ChildUser filtered by the updated_at column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
63
 *
64
 * @method     ChildUser[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildUser objects based on current ModelCriteria
65
 * @method     ChildUser[]|ObjectCollection findById(int $id) Return ChildUser objects filtered by the id column
66
 * @method     ChildUser[]|ObjectCollection findByName(string $name) Return ChildUser objects filtered by the name column
67
 * @method     ChildUser[]|ObjectCollection findByEmail(string $email) Return ChildUser objects filtered by the email column
68
 * @method     ChildUser[]|ObjectCollection findByPassword(string $password) Return ChildUser objects filtered by the password column
69
 * @method     ChildUser[]|ObjectCollection findByRememberToken(string $remember_token) Return ChildUser objects filtered by the remember_token column
70
 * @method     ChildUser[]|ObjectCollection findByCreatedAt(string $created_at) Return ChildUser objects filtered by the created_at column
71
 * @method     ChildUser[]|ObjectCollection findByUpdatedAt(string $updated_at) Return ChildUser objects filtered by the updated_at column
72
 * @method     ChildUser[]|\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
73
 *
74
 */
75
abstract class UserQuery extends ModelCriteria
76
{
77
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
78
79
    /**
80
     * Initializes internal state of \Core\Models\User\Base\UserQuery object.
81
     *
82
     * @param     string $dbName The database name
83
     * @param     string $modelName The phpName of a model, e.g. 'Book'
84
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
85
     */
86
    public function __construct($dbName = 'default', $modelName = '\\Core\\Models\\User\\User', $modelAlias = null)
87
    {
88
        parent::__construct($dbName, $modelName, $modelAlias);
89
    }
90
91
    /**
92
     * Returns a new ChildUserQuery object.
93
     *
94
     * @param     string $modelAlias The alias of a model in the query
95
     * @param     Criteria $criteria Optional Criteria to build the query from
96
     *
97
     * @return ChildUserQuery
98
     */
99 View Code Duplication
    public static function create($modelAlias = null, Criteria $criteria = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
100
    {
101
        if ($criteria instanceof ChildUserQuery) {
102
            return $criteria;
103
        }
104
        $query = new ChildUserQuery();
105
        if (null !== $modelAlias) {
106
            $query->setModelAlias($modelAlias);
107
        }
108
        if ($criteria instanceof Criteria) {
109
            $query->mergeWith($criteria);
110
        }
111
112
        return $query;
113
    }
114
115
    /**
116
     * Find object by primary key.
117
     * Propel uses the instance pool to skip the database if the object exists.
118
     * Go fast if the query is untouched.
119
     *
120
     * <code>
121
     * $obj  = $c->findPk(12, $con);
122
     * </code>
123
     *
124
     * @param mixed $key Primary key to use for the query
125
     * @param ConnectionInterface $con an optional connection object
126
     *
127
     * @return ChildUser|array|mixed the result, formatted by the current formatter
128
     */
129 View Code Duplication
    public function findPk($key, ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
130
    {
131
        if ($key === null) {
132
            return null;
133
        }
134
        if ((null !== ($obj = UserTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) {
135
            // the object is already in the instance pool
136
            return $obj;
137
        }
138
        if ($con === null) {
139
            $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME);
140
        }
141
        $this->basePreSelect($con);
142
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->modelAlias of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
Bug Best Practice introduced by
The expression $this->with of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
143
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->selectColumns of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
Bug Best Practice introduced by
The expression $this->asColumns of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
Bug Best Practice introduced by
The expression $this->selectModifiers of type string[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
144
         || $this->map || $this->having || $this->joins) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->map of type Propel\Runtime\ActiveQue...ion\AbstractCriterion[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
Bug Best Practice introduced by
The expression $this->joins of type Propel\Runtime\ActiveQuery\Join[] is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
145
            return $this->findPkComplex($key, $con);
146
        } else {
147
            return $this->findPkSimple($key, $con);
148
        }
149
    }
150
151
    /**
152
     * Find object by primary key using raw SQL to go fast.
153
     * Bypass doSelect() and the object formatter by using generated code.
154
     *
155
     * @param     mixed $key Primary key to use for the query
156
     * @param     ConnectionInterface $con A connection object
157
     *
158
     * @throws \Propel\Runtime\Exception\PropelException
159
     *
160
     * @return ChildUser A model object, or null if the key is not found
161
     */
162 View Code Duplication
    protected function findPkSimple($key, ConnectionInterface $con)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
163
    {
164
        $sql = 'SELECT id, name, email, password, remember_token, created_at, updated_at FROM users WHERE id = :p0';
165
        try {
166
            $stmt = $con->prepare($sql);
167
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
168
            $stmt->execute();
169
        } catch (Exception $e) {
170
            Propel::log($e->getMessage(), Propel::LOG_ERR);
171
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
172
        }
173
        $obj = null;
174
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
175
            /** @var ChildUser $obj */
176
            $obj = new ChildUser();
177
            $obj->hydrate($row);
178
            UserTableMap::addInstanceToPool($obj, (string) $key);
179
        }
180
        $stmt->closeCursor();
181
182
        return $obj;
183
    }
184
185
    /**
186
     * Find object by primary key.
187
     *
188
     * @param     mixed $key Primary key to use for the query
189
     * @param     ConnectionInterface $con A connection object
190
     *
191
     * @return ChildUser|array|mixed the result, formatted by the current formatter
192
     */
193 View Code Duplication
    protected function findPkComplex($key, ConnectionInterface $con)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
194
    {
195
        // As the query uses a PK condition, no limit(1) is necessary.
196
        $criteria = $this->isKeepQuery() ? clone $this : $this;
197
        $dataFetcher = $criteria
198
            ->filterByPrimaryKey($key)
199
            ->doSelect($con);
200
201
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
202
    }
203
204
    /**
205
     * Find objects by primary key
206
     * <code>
207
     * $objs = $c->findPks(array(12, 56, 832), $con);
208
     * </code>
209
     * @param     array $keys Primary keys to use for the query
210
     * @param     ConnectionInterface $con an optional connection object
211
     *
212
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
213
     */
214 View Code Duplication
    public function findPks($keys, ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
215
    {
216
        if (null === $con) {
217
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
218
        }
219
        $this->basePreSelect($con);
220
        $criteria = $this->isKeepQuery() ? clone $this : $this;
221
        $dataFetcher = $criteria
222
            ->filterByPrimaryKeys($keys)
223
            ->doSelect($con);
224
225
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
226
    }
227
228
    /**
229
     * Filter the query by primary key
230
     *
231
     * @param     mixed $key Primary key to use for the query
232
     *
233
     * @return $this|ChildUserQuery The current query, for fluid interface
234
     */
235
    public function filterByPrimaryKey($key)
236
    {
237
238
        return $this->addUsingAlias(UserTableMap::COL_ID, $key, Criteria::EQUAL);
239
    }
240
241
    /**
242
     * Filter the query by a list of primary keys
243
     *
244
     * @param     array $keys The list of primary key to use for the query
245
     *
246
     * @return $this|ChildUserQuery The current query, for fluid interface
247
     */
248
    public function filterByPrimaryKeys($keys)
249
    {
250
251
        return $this->addUsingAlias(UserTableMap::COL_ID, $keys, Criteria::IN);
252
    }
253
254
    /**
255
     * Filter the query on the id column
256
     *
257
     * Example usage:
258
     * <code>
259
     * $query->filterById(1234); // WHERE id = 1234
260
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
261
     * $query->filterById(array('min' => 12)); // WHERE id > 12
262
     * </code>
263
     *
264
     * @param     mixed $id The value to use as filter.
265
     *              Use scalar values for equality.
266
     *              Use array values for in_array() equivalent.
267
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
268
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
269
     *
270
     * @return $this|ChildUserQuery The current query, for fluid interface
271
     */
272 View Code Duplication
    public function filterById($id = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
273
    {
274
        if (is_array($id)) {
275
            $useMinMax = false;
276
            if (isset($id['min'])) {
277
                $this->addUsingAlias(UserTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
278
                $useMinMax = true;
279
            }
280
            if (isset($id['max'])) {
281
                $this->addUsingAlias(UserTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
282
                $useMinMax = true;
283
            }
284
            if ($useMinMax) {
285
                return $this;
286
            }
287
            if (null === $comparison) {
288
                $comparison = Criteria::IN;
289
            }
290
        }
291
292
        return $this->addUsingAlias(UserTableMap::COL_ID, $id, $comparison);
293
    }
294
295
    /**
296
     * Filter the query on the name column
297
     *
298
     * Example usage:
299
     * <code>
300
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
301
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
302
     * </code>
303
     *
304
     * @param     string $name The value to use as filter.
305
     *              Accepts wildcards (* and % trigger a LIKE)
306
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
307
     *
308
     * @return $this|ChildUserQuery The current query, for fluid interface
309
     */
310 View Code Duplication
    public function filterByName($name = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
311
    {
312
        if (null === $comparison) {
313
            if (is_array($name)) {
314
                $comparison = Criteria::IN;
315
            } elseif (preg_match('/[\%\*]/', $name)) {
316
                $name = str_replace('*', '%', $name);
317
                $comparison = Criteria::LIKE;
318
            }
319
        }
320
321
        return $this->addUsingAlias(UserTableMap::COL_NAME, $name, $comparison);
322
    }
323
324
    /**
325
     * Filter the query on the email column
326
     *
327
     * Example usage:
328
     * <code>
329
     * $query->filterByEmail('fooValue');   // WHERE email = 'fooValue'
330
     * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
331
     * </code>
332
     *
333
     * @param     string $email The value to use as filter.
334
     *              Accepts wildcards (* and % trigger a LIKE)
335
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
336
     *
337
     * @return $this|ChildUserQuery The current query, for fluid interface
338
     */
339 View Code Duplication
    public function filterByEmail($email = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
340
    {
341
        if (null === $comparison) {
342
            if (is_array($email)) {
343
                $comparison = Criteria::IN;
344
            } elseif (preg_match('/[\%\*]/', $email)) {
345
                $email = str_replace('*', '%', $email);
346
                $comparison = Criteria::LIKE;
347
            }
348
        }
349
350
        return $this->addUsingAlias(UserTableMap::COL_EMAIL, $email, $comparison);
351
    }
352
353
    /**
354
     * Filter the query on the password column
355
     *
356
     * Example usage:
357
     * <code>
358
     * $query->filterByPassword('fooValue');   // WHERE password = 'fooValue'
359
     * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
360
     * </code>
361
     *
362
     * @param     string $password The value to use as filter.
363
     *              Accepts wildcards (* and % trigger a LIKE)
364
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
365
     *
366
     * @return $this|ChildUserQuery The current query, for fluid interface
367
     */
368 View Code Duplication
    public function filterByPassword($password = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
369
    {
370
        if (null === $comparison) {
371
            if (is_array($password)) {
372
                $comparison = Criteria::IN;
373
            } elseif (preg_match('/[\%\*]/', $password)) {
374
                $password = str_replace('*', '%', $password);
375
                $comparison = Criteria::LIKE;
376
            }
377
        }
378
379
        return $this->addUsingAlias(UserTableMap::COL_PASSWORD, $password, $comparison);
380
    }
381
382
    /**
383
     * Filter the query on the remember_token column
384
     *
385
     * Example usage:
386
     * <code>
387
     * $query->filterByRememberToken('fooValue');   // WHERE remember_token = 'fooValue'
388
     * $query->filterByRememberToken('%fooValue%'); // WHERE remember_token LIKE '%fooValue%'
389
     * </code>
390
     *
391
     * @param     string $rememberToken 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|ChildUserQuery The current query, for fluid interface
396
     */
397 View Code Duplication
    public function filterByRememberToken($rememberToken = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
398
    {
399
        if (null === $comparison) {
400
            if (is_array($rememberToken)) {
401
                $comparison = Criteria::IN;
402
            } elseif (preg_match('/[\%\*]/', $rememberToken)) {
403
                $rememberToken = str_replace('*', '%', $rememberToken);
404
                $comparison = Criteria::LIKE;
405
            }
406
        }
407
408
        return $this->addUsingAlias(UserTableMap::COL_REMEMBER_TOKEN, $rememberToken, $comparison);
409
    }
410
411
    /**
412
     * Filter the query on the created_at column
413
     *
414
     * Example usage:
415
     * <code>
416
     * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
417
     * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
418
     * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
419
     * </code>
420
     *
421
     * @param     mixed $createdAt The value to use as filter.
422
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
423
     *              Empty strings are treated as NULL.
424
     *              Use scalar values for equality.
425
     *              Use array values for in_array() equivalent.
426
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
427
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
428
     *
429
     * @return $this|ChildUserQuery The current query, for fluid interface
430
     */
431 View Code Duplication
    public function filterByCreatedAt($createdAt = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
432
    {
433
        if (is_array($createdAt)) {
434
            $useMinMax = false;
435
            if (isset($createdAt['min'])) {
436
                $this->addUsingAlias(UserTableMap::COL_CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
437
                $useMinMax = true;
438
            }
439
            if (isset($createdAt['max'])) {
440
                $this->addUsingAlias(UserTableMap::COL_CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
441
                $useMinMax = true;
442
            }
443
            if ($useMinMax) {
444
                return $this;
445
            }
446
            if (null === $comparison) {
447
                $comparison = Criteria::IN;
448
            }
449
        }
450
451
        return $this->addUsingAlias(UserTableMap::COL_CREATED_AT, $createdAt, $comparison);
452
    }
453
454
    /**
455
     * Filter the query on the updated_at column
456
     *
457
     * Example usage:
458
     * <code>
459
     * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
460
     * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
461
     * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
462
     * </code>
463
     *
464
     * @param     mixed $updatedAt The value to use as filter.
465
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
466
     *              Empty strings are treated as NULL.
467
     *              Use scalar values for equality.
468
     *              Use array values for in_array() equivalent.
469
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
470
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
471
     *
472
     * @return $this|ChildUserQuery The current query, for fluid interface
473
     */
474 View Code Duplication
    public function filterByUpdatedAt($updatedAt = null, $comparison = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
475
    {
476
        if (is_array($updatedAt)) {
477
            $useMinMax = false;
478
            if (isset($updatedAt['min'])) {
479
                $this->addUsingAlias(UserTableMap::COL_UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
480
                $useMinMax = true;
481
            }
482
            if (isset($updatedAt['max'])) {
483
                $this->addUsingAlias(UserTableMap::COL_UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
484
                $useMinMax = true;
485
            }
486
            if ($useMinMax) {
487
                return $this;
488
            }
489
            if (null === $comparison) {
490
                $comparison = Criteria::IN;
491
            }
492
        }
493
494
        return $this->addUsingAlias(UserTableMap::COL_UPDATED_AT, $updatedAt, $comparison);
495
    }
496
497
    /**
498
     * Exclude object from result
499
     *
500
     * @param   ChildUser $user Object to remove from the list of results
501
     *
502
     * @return $this|ChildUserQuery The current query, for fluid interface
503
     */
504
    public function prune($user = null)
505
    {
506
        if ($user) {
507
            $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
508
        }
509
510
        return $this;
511
    }
512
513
    /**
514
     * Deletes all rows from the users table.
515
     *
516
     * @param ConnectionInterface $con the connection to use
517
     * @return int The number of affected rows (if supported by underlying database driver).
518
     */
519 View Code Duplication
    public function doDeleteAll(ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
520
    {
521
        if (null === $con) {
522
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
523
        }
524
525
        // use transaction because $criteria could contain info
526
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
527
        return $con->transaction(function () use ($con) {
528
            $affectedRows = 0; // initialize var to track total num of affected rows
529
            $affectedRows += parent::doDeleteAll($con);
530
            // Because this db requires some delete cascade/set null emulation, we have to
531
            // clear the cached instance *after* the emulation has happened (since
532
            // instances get re-added by the select statement contained therein).
533
            UserTableMap::clearInstancePool();
534
            UserTableMap::clearRelatedInstancePool();
535
536
            return $affectedRows;
537
        });
538
    }
539
540
    /**
541
     * Performs a DELETE on the database based on the current ModelCriteria
542
     *
543
     * @param ConnectionInterface $con the connection to use
544
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
545
     *                         if supported by native driver or if emulated using Propel.
546
     * @throws PropelException Any exceptions caught during processing will be
547
     *                         rethrown wrapped into a PropelException.
548
     */
549 View Code Duplication
    public function delete(ConnectionInterface $con = null)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
550
    {
551
        if (null === $con) {
552
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
553
        }
554
555
        $criteria = $this;
556
557
        // Set the correct dbName
558
        $criteria->setDbName(UserTableMap::DATABASE_NAME);
559
560
        // use transaction because $criteria could contain info
561
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
562
        return $con->transaction(function () use ($con, $criteria) {
563
            $affectedRows = 0; // initialize var to track total num of affected rows
564
565
            UserTableMap::removeInstanceFromPool($criteria);
566
567
            $affectedRows += ModelCriteria::delete($con);
568
            UserTableMap::clearRelatedInstancePool();
569
570
            return $affectedRows;
571
        });
572
    }
573
574
} // UserQuery
575