Completed
Push — master ( 76c71b...91372c )
by dima
05:24
created

UserQuery::findPkSimple()   B

Complexity

Conditions 6
Paths 5

Size

Total Lines 22
Code Lines 16

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
dl 22
loc 22
rs 8.6737
c 0
b 0
f 0
cc 6
eloc 16
nc 5
nop 2
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     ChildUserQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
43
 * @method     ChildUserQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
44
 * @method     ChildUserQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
45
 *
46
 * @method     ChildUser findOne(ConnectionInterface $con = null) Return the first ChildUser matching the query
47
 * @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
48
 *
49
 * @method     ChildUser findOneById(int $id) Return the first ChildUser filtered by the id column
50
 * @method     ChildUser findOneByName(string $name) Return the first ChildUser filtered by the name column
51
 * @method     ChildUser findOneByEmail(string $email) Return the first ChildUser filtered by the email column
52
 * @method     ChildUser findOneByPassword(string $password) Return the first ChildUser filtered by the password column
53
 * @method     ChildUser findOneByRememberToken(string $remember_token) Return the first ChildUser filtered by the remember_token column
54
 * @method     ChildUser findOneByCreatedAt(string $created_at) Return the first ChildUser filtered by the created_at column
55
 * @method     ChildUser findOneByUpdatedAt(string $updated_at) Return the first ChildUser filtered by the updated_at column *
56
57
 * @method     ChildUser requirePk($key, ConnectionInterface $con = null) Return the ChildUser by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
58
 * @method     ChildUser requireOne(ConnectionInterface $con = null) Return the first ChildUser matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
59
 *
60
 * @method     ChildUser requireOneById(int $id) Return the first ChildUser filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
61
 * @method     ChildUser requireOneByName(string $name) Return the first ChildUser filtered by the name column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
62
 * @method     ChildUser requireOneByEmail(string $email) Return the first ChildUser filtered by the email column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
63
 * @method     ChildUser requireOneByPassword(string $password) Return the first ChildUser filtered by the password column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
64
 * @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
65
 * @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
66
 * @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
67
 *
68
 * @method     ChildUser[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildUser objects based on current ModelCriteria
69
 * @method     ChildUser[]|ObjectCollection findById(int $id) Return ChildUser objects filtered by the id column
70
 * @method     ChildUser[]|ObjectCollection findByName(string $name) Return ChildUser objects filtered by the name column
71
 * @method     ChildUser[]|ObjectCollection findByEmail(string $email) Return ChildUser objects filtered by the email column
72
 * @method     ChildUser[]|ObjectCollection findByPassword(string $password) Return ChildUser objects filtered by the password column
73
 * @method     ChildUser[]|ObjectCollection findByRememberToken(string $remember_token) Return ChildUser objects filtered by the remember_token column
74
 * @method     ChildUser[]|ObjectCollection findByCreatedAt(string $created_at) Return ChildUser objects filtered by the created_at column
75
 * @method     ChildUser[]|ObjectCollection findByUpdatedAt(string $updated_at) Return ChildUser objects filtered by the updated_at column
76
 * @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
77
 *
78
 */
79
abstract class UserQuery extends ModelCriteria
80
{
81
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
82
83
    /**
84
     * Initializes internal state of \Core\Models\User\Base\UserQuery object.
85
     *
86
     * @param     string $dbName The database name
87
     * @param     string $modelName The phpName of a model, e.g. 'Book'
88
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
89
     */
90
    public function __construct($dbName = 'default', $modelName = '\\Core\\Models\\User\\User', $modelAlias = null)
91
    {
92
        parent::__construct($dbName, $modelName, $modelAlias);
93
    }
94
95
    /**
96
     * Returns a new ChildUserQuery object.
97
     *
98
     * @param     string $modelAlias The alias of a model in the query
99
     * @param     Criteria $criteria Optional Criteria to build the query from
100
     *
101
     * @return ChildUserQuery
102
     */
103 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...
104
    {
105
        if ($criteria instanceof ChildUserQuery) {
106
            return $criteria;
107
        }
108
        $query = new ChildUserQuery();
109
        if (null !== $modelAlias) {
110
            $query->setModelAlias($modelAlias);
111
        }
112
        if ($criteria instanceof Criteria) {
113
            $query->mergeWith($criteria);
114
        }
115
116
        return $query;
117
    }
118
119
    /**
120
     * Find object by primary key.
121
     * Propel uses the instance pool to skip the database if the object exists.
122
     * Go fast if the query is untouched.
123
     *
124
     * <code>
125
     * $obj  = $c->findPk(12, $con);
126
     * </code>
127
     *
128
     * @param mixed $key Primary key to use for the query
129
     * @param ConnectionInterface $con an optional connection object
130
     *
131
     * @return ChildUser|array|mixed the result, formatted by the current formatter
132
     */
133 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...
134
    {
135
        if ($key === null) {
136
            return null;
137
        }
138
139
        if ($con === null) {
140
            $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME);
141
        }
142
143
        $this->basePreSelect($con);
144
145
        if (
146
            $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...
147
            || $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...
148
            || $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...
149
        ) {
150
            return $this->findPkComplex($key, $con);
151
        }
152
153
        if ((null !== ($obj = UserTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key)))) {
154
            // the object is already in the instance pool
155
            return $obj;
156
        }
157
158
        return $this->findPkSimple($key, $con);
159
    }
160
161
    /**
162
     * Find object by primary key using raw SQL to go fast.
163
     * Bypass doSelect() and the object formatter by using generated code.
164
     *
165
     * @param     mixed $key Primary key to use for the query
166
     * @param     ConnectionInterface $con A connection object
167
     *
168
     * @throws \Propel\Runtime\Exception\PropelException
169
     *
170
     * @return ChildUser A model object, or null if the key is not found
171
     */
172 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...
173
    {
174
        $sql = 'SELECT id, name, email, password, remember_token, created_at, updated_at FROM users WHERE id = :p0';
175
        try {
176
            $stmt = $con->prepare($sql);
177
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
178
            $stmt->execute();
179
        } catch (Exception $e) {
180
            Propel::log($e->getMessage(), Propel::LOG_ERR);
181
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
182
        }
183
        $obj = null;
184
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
185
            /** @var ChildUser $obj */
186
            $obj = new ChildUser();
187
            $obj->hydrate($row);
188
            UserTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key);
189
        }
190
        $stmt->closeCursor();
191
192
        return $obj;
193
    }
194
195
    /**
196
     * Find object by primary key.
197
     *
198
     * @param     mixed $key Primary key to use for the query
199
     * @param     ConnectionInterface $con A connection object
200
     *
201
     * @return ChildUser|array|mixed the result, formatted by the current formatter
202
     */
203 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...
204
    {
205
        // As the query uses a PK condition, no limit(1) is necessary.
206
        $criteria = $this->isKeepQuery() ? clone $this : $this;
207
        $dataFetcher = $criteria
208
            ->filterByPrimaryKey($key)
209
            ->doSelect($con);
210
211
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
212
    }
213
214
    /**
215
     * Find objects by primary key
216
     * <code>
217
     * $objs = $c->findPks(array(12, 56, 832), $con);
218
     * </code>
219
     * @param     array $keys Primary keys to use for the query
220
     * @param     ConnectionInterface $con an optional connection object
221
     *
222
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
223
     */
224 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...
225
    {
226
        if (null === $con) {
227
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
228
        }
229
        $this->basePreSelect($con);
230
        $criteria = $this->isKeepQuery() ? clone $this : $this;
231
        $dataFetcher = $criteria
232
            ->filterByPrimaryKeys($keys)
233
            ->doSelect($con);
234
235
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
236
    }
237
238
    /**
239
     * Filter the query by primary key
240
     *
241
     * @param     mixed $key Primary key to use for the query
242
     *
243
     * @return $this|ChildUserQuery The current query, for fluid interface
244
     */
245
    public function filterByPrimaryKey($key)
246
    {
247
248
        return $this->addUsingAlias(UserTableMap::COL_ID, $key, Criteria::EQUAL);
249
    }
250
251
    /**
252
     * Filter the query by a list of primary keys
253
     *
254
     * @param     array $keys The list of primary key to use for the query
255
     *
256
     * @return $this|ChildUserQuery The current query, for fluid interface
257
     */
258
    public function filterByPrimaryKeys($keys)
259
    {
260
261
        return $this->addUsingAlias(UserTableMap::COL_ID, $keys, Criteria::IN);
262
    }
263
264
    /**
265
     * Filter the query on the id column
266
     *
267
     * Example usage:
268
     * <code>
269
     * $query->filterById(1234); // WHERE id = 1234
270
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
271
     * $query->filterById(array('min' => 12)); // WHERE id > 12
272
     * </code>
273
     *
274
     * @param     mixed $id The value to use as filter.
275
     *              Use scalar values for equality.
276
     *              Use array values for in_array() equivalent.
277
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
278
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
279
     *
280
     * @return $this|ChildUserQuery The current query, for fluid interface
281
     */
282 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...
283
    {
284
        if (is_array($id)) {
285
            $useMinMax = false;
286
            if (isset($id['min'])) {
287
                $this->addUsingAlias(UserTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
288
                $useMinMax = true;
289
            }
290
            if (isset($id['max'])) {
291
                $this->addUsingAlias(UserTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
292
                $useMinMax = true;
293
            }
294
            if ($useMinMax) {
295
                return $this;
296
            }
297
            if (null === $comparison) {
298
                $comparison = Criteria::IN;
299
            }
300
        }
301
302
        return $this->addUsingAlias(UserTableMap::COL_ID, $id, $comparison);
303
    }
304
305
    /**
306
     * Filter the query on the name column
307
     *
308
     * Example usage:
309
     * <code>
310
     * $query->filterByName('fooValue');   // WHERE name = 'fooValue'
311
     * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%'
312
     * </code>
313
     *
314
     * @param     string $name The value to use as filter.
315
     *              Accepts wildcards (* and % trigger a LIKE)
316
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
317
     *
318
     * @return $this|ChildUserQuery The current query, for fluid interface
319
     */
320 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...
321
    {
322
        if (null === $comparison) {
323
            if (is_array($name)) {
324
                $comparison = Criteria::IN;
325
            } elseif (preg_match('/[\%\*]/', $name)) {
326
                $name = str_replace('*', '%', $name);
327
                $comparison = Criteria::LIKE;
328
            }
329
        }
330
331
        return $this->addUsingAlias(UserTableMap::COL_NAME, $name, $comparison);
332
    }
333
334
    /**
335
     * Filter the query on the email column
336
     *
337
     * Example usage:
338
     * <code>
339
     * $query->filterByEmail('fooValue');   // WHERE email = 'fooValue'
340
     * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
341
     * </code>
342
     *
343
     * @param     string $email The value to use as filter.
344
     *              Accepts wildcards (* and % trigger a LIKE)
345
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
346
     *
347
     * @return $this|ChildUserQuery The current query, for fluid interface
348
     */
349 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...
350
    {
351
        if (null === $comparison) {
352
            if (is_array($email)) {
353
                $comparison = Criteria::IN;
354
            } elseif (preg_match('/[\%\*]/', $email)) {
355
                $email = str_replace('*', '%', $email);
356
                $comparison = Criteria::LIKE;
357
            }
358
        }
359
360
        return $this->addUsingAlias(UserTableMap::COL_EMAIL, $email, $comparison);
361
    }
362
363
    /**
364
     * Filter the query on the password column
365
     *
366
     * Example usage:
367
     * <code>
368
     * $query->filterByPassword('fooValue');   // WHERE password = 'fooValue'
369
     * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
370
     * </code>
371
     *
372
     * @param     string $password The value to use as filter.
373
     *              Accepts wildcards (* and % trigger a LIKE)
374
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
375
     *
376
     * @return $this|ChildUserQuery The current query, for fluid interface
377
     */
378 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...
379
    {
380
        if (null === $comparison) {
381
            if (is_array($password)) {
382
                $comparison = Criteria::IN;
383
            } elseif (preg_match('/[\%\*]/', $password)) {
384
                $password = str_replace('*', '%', $password);
385
                $comparison = Criteria::LIKE;
386
            }
387
        }
388
389
        return $this->addUsingAlias(UserTableMap::COL_PASSWORD, $password, $comparison);
390
    }
391
392
    /**
393
     * Filter the query on the remember_token column
394
     *
395
     * Example usage:
396
     * <code>
397
     * $query->filterByRememberToken('fooValue');   // WHERE remember_token = 'fooValue'
398
     * $query->filterByRememberToken('%fooValue%'); // WHERE remember_token LIKE '%fooValue%'
399
     * </code>
400
     *
401
     * @param     string $rememberToken The value to use as filter.
402
     *              Accepts wildcards (* and % trigger a LIKE)
403
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
404
     *
405
     * @return $this|ChildUserQuery The current query, for fluid interface
406
     */
407 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...
408
    {
409
        if (null === $comparison) {
410
            if (is_array($rememberToken)) {
411
                $comparison = Criteria::IN;
412
            } elseif (preg_match('/[\%\*]/', $rememberToken)) {
413
                $rememberToken = str_replace('*', '%', $rememberToken);
414
                $comparison = Criteria::LIKE;
415
            }
416
        }
417
418
        return $this->addUsingAlias(UserTableMap::COL_REMEMBER_TOKEN, $rememberToken, $comparison);
419
    }
420
421
    /**
422
     * Filter the query on the created_at column
423
     *
424
     * Example usage:
425
     * <code>
426
     * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
427
     * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
428
     * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
429
     * </code>
430
     *
431
     * @param     mixed $createdAt The value to use as filter.
432
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
433
     *              Empty strings are treated as NULL.
434
     *              Use scalar values for equality.
435
     *              Use array values for in_array() equivalent.
436
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
437
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
438
     *
439
     * @return $this|ChildUserQuery The current query, for fluid interface
440
     */
441 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...
442
    {
443
        if (is_array($createdAt)) {
444
            $useMinMax = false;
445
            if (isset($createdAt['min'])) {
446
                $this->addUsingAlias(UserTableMap::COL_CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
447
                $useMinMax = true;
448
            }
449
            if (isset($createdAt['max'])) {
450
                $this->addUsingAlias(UserTableMap::COL_CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
451
                $useMinMax = true;
452
            }
453
            if ($useMinMax) {
454
                return $this;
455
            }
456
            if (null === $comparison) {
457
                $comparison = Criteria::IN;
458
            }
459
        }
460
461
        return $this->addUsingAlias(UserTableMap::COL_CREATED_AT, $createdAt, $comparison);
462
    }
463
464
    /**
465
     * Filter the query on the updated_at column
466
     *
467
     * Example usage:
468
     * <code>
469
     * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
470
     * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
471
     * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
472
     * </code>
473
     *
474
     * @param     mixed $updatedAt The value to use as filter.
475
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
476
     *              Empty strings are treated as NULL.
477
     *              Use scalar values for equality.
478
     *              Use array values for in_array() equivalent.
479
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
480
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
481
     *
482
     * @return $this|ChildUserQuery The current query, for fluid interface
483
     */
484 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...
485
    {
486
        if (is_array($updatedAt)) {
487
            $useMinMax = false;
488
            if (isset($updatedAt['min'])) {
489
                $this->addUsingAlias(UserTableMap::COL_UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
490
                $useMinMax = true;
491
            }
492
            if (isset($updatedAt['max'])) {
493
                $this->addUsingAlias(UserTableMap::COL_UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
494
                $useMinMax = true;
495
            }
496
            if ($useMinMax) {
497
                return $this;
498
            }
499
            if (null === $comparison) {
500
                $comparison = Criteria::IN;
501
            }
502
        }
503
504
        return $this->addUsingAlias(UserTableMap::COL_UPDATED_AT, $updatedAt, $comparison);
505
    }
506
507
    /**
508
     * Exclude object from result
509
     *
510
     * @param   ChildUser $user Object to remove from the list of results
511
     *
512
     * @return $this|ChildUserQuery The current query, for fluid interface
513
     */
514
    public function prune($user = null)
515
    {
516
        if ($user) {
517
            $this->addUsingAlias(UserTableMap::COL_ID, $user->getId(), Criteria::NOT_EQUAL);
518
        }
519
520
        return $this;
521
    }
522
523
    /**
524
     * Deletes all rows from the users table.
525
     *
526
     * @param ConnectionInterface $con the connection to use
527
     * @return int The number of affected rows (if supported by underlying database driver).
528
     */
529 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...
530
    {
531
        if (null === $con) {
532
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
533
        }
534
535
        // use transaction because $criteria could contain info
536
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
537
        return $con->transaction(function () use ($con) {
538
            $affectedRows = 0; // initialize var to track total num of affected rows
539
            $affectedRows += parent::doDeleteAll($con);
540
            // Because this db requires some delete cascade/set null emulation, we have to
541
            // clear the cached instance *after* the emulation has happened (since
542
            // instances get re-added by the select statement contained therein).
543
            UserTableMap::clearInstancePool();
544
            UserTableMap::clearRelatedInstancePool();
545
546
            return $affectedRows;
547
        });
548
    }
549
550
    /**
551
     * Performs a DELETE on the database based on the current ModelCriteria
552
     *
553
     * @param ConnectionInterface $con the connection to use
554
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
555
     *                         if supported by native driver or if emulated using Propel.
556
     * @throws PropelException Any exceptions caught during processing will be
557
     *                         rethrown wrapped into a PropelException.
558
     */
559 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...
560
    {
561
        if (null === $con) {
562
            $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME);
563
        }
564
565
        $criteria = $this;
566
567
        // Set the correct dbName
568
        $criteria->setDbName(UserTableMap::DATABASE_NAME);
569
570
        // use transaction because $criteria could contain info
571
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
572
        return $con->transaction(function () use ($con, $criteria) {
573
            $affectedRows = 0; // initialize var to track total num of affected rows
574
575
            UserTableMap::removeInstanceFromPool($criteria);
576
577
            $affectedRows += ModelCriteria::delete($con);
578
            UserTableMap::clearRelatedInstancePool();
579
580
            return $affectedRows;
581
        });
582
    }
583
584
} // UserQuery
585