Completed
Pull Request — master (#131)
by De Cramer
05:13 queued 02:26
created

RecordQuery   F

Complexity

Total Complexity 111

Size/Duplication

Total Lines 790
Duplicated Lines 44.3 %

Coupling/Cohesion

Components 3
Dependencies 14

Importance

Changes 0
Metric Value
wmc 111
lcom 3
cbo 14
dl 350
loc 790
rs 1.5999
c 0
b 0
f 0

30 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 15 15 4
D findPk() 27 27 17
B findPkSimple() 22 22 6
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 filterByMapuid() 10 10 3
B filterByNblaps() 22 22 6
B filterByScore() 22 22 6
B filterByNbfinish() 22 22 6
B filterByAvgscore() 22 22 6
A filterByCheckpoints() 10 10 3
B filterByPlayerId() 22 22 6
B filterByCreatedAt() 22 22 6
B filterByUpdatedAt() 22 22 6
A filterByPlayer() 0 16 4
B joinPlayer() 23 23 4
A usePlayerQuery() 0 6 2
A prune() 0 8 2
A doDeleteAll() 20 20 2
B delete() 24 24 2
A recentlyUpdated() 0 4 1
A lastUpdatedFirst() 0 4 1
A firstUpdatedFirst() 0 4 1
A lastCreatedFirst() 0 4 1
A recentlyCreated() 0 4 1
A firstCreatedFirst() 0 4 1

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

1
<?php
2
3
namespace eXpansion\Bundle\LocalRecords\Model\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 eXpansion\Bundle\LocalRecords\Model\Record as ChildRecord;
15
use eXpansion\Bundle\LocalRecords\Model\RecordQuery as ChildRecordQuery;
16
use eXpansion\Bundle\LocalRecords\Model\Map\RecordTableMap;
17
use eXpansion\Framework\PlayersBundle\Model\Player;
18
19
/**
20
 * Base class that represents a query for the 'record' table.
21
 *
22
 *
23
 *
24
 * @method     ChildRecordQuery orderById($order = Criteria::ASC) Order by the id column
25
 * @method     ChildRecordQuery orderByMapuid($order = Criteria::ASC) Order by the mapUid column
26
 * @method     ChildRecordQuery orderByNblaps($order = Criteria::ASC) Order by the nbLaps column
27
 * @method     ChildRecordQuery orderByScore($order = Criteria::ASC) Order by the score column
28
 * @method     ChildRecordQuery orderByNbfinish($order = Criteria::ASC) Order by the nbFinish column
29
 * @method     ChildRecordQuery orderByAvgscore($order = Criteria::ASC) Order by the avgScore column
30
 * @method     ChildRecordQuery orderByCheckpoints($order = Criteria::ASC) Order by the checkpoints column
31
 * @method     ChildRecordQuery orderByPlayerId($order = Criteria::ASC) Order by the player_id column
32
 * @method     ChildRecordQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
33
 * @method     ChildRecordQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
34
 *
35
 * @method     ChildRecordQuery groupById() Group by the id column
36
 * @method     ChildRecordQuery groupByMapuid() Group by the mapUid column
37
 * @method     ChildRecordQuery groupByNblaps() Group by the nbLaps column
38
 * @method     ChildRecordQuery groupByScore() Group by the score column
39
 * @method     ChildRecordQuery groupByNbfinish() Group by the nbFinish column
40
 * @method     ChildRecordQuery groupByAvgscore() Group by the avgScore column
41
 * @method     ChildRecordQuery groupByCheckpoints() Group by the checkpoints column
42
 * @method     ChildRecordQuery groupByPlayerId() Group by the player_id column
43
 * @method     ChildRecordQuery groupByCreatedAt() Group by the created_at column
44
 * @method     ChildRecordQuery groupByUpdatedAt() Group by the updated_at column
45
 *
46
 * @method     ChildRecordQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
47
 * @method     ChildRecordQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
48
 * @method     ChildRecordQuery innerJoin($relation) Adds a INNER JOIN clause to the query
49
 *
50
 * @method     ChildRecordQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
51
 * @method     ChildRecordQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
52
 * @method     ChildRecordQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
53
 *
54
 * @method     ChildRecordQuery leftJoinPlayer($relationAlias = null) Adds a LEFT JOIN clause to the query using the Player relation
55
 * @method     ChildRecordQuery rightJoinPlayer($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Player relation
56
 * @method     ChildRecordQuery innerJoinPlayer($relationAlias = null) Adds a INNER JOIN clause to the query using the Player relation
57
 *
58
 * @method     ChildRecordQuery joinWithPlayer($joinType = Criteria::INNER_JOIN) Adds a join clause and with to the query using the Player relation
59
 *
60
 * @method     ChildRecordQuery leftJoinWithPlayer() Adds a LEFT JOIN clause and with to the query using the Player relation
61
 * @method     ChildRecordQuery rightJoinWithPlayer() Adds a RIGHT JOIN clause and with to the query using the Player relation
62
 * @method     ChildRecordQuery innerJoinWithPlayer() Adds a INNER JOIN clause and with to the query using the Player relation
63
 *
64
 * @method     \eXpansion\Framework\PlayersBundle\Model\PlayerQuery endUse() Finalizes a secondary criteria and merges it with its primary Criteria
65
 *
66
 * @method     ChildRecord findOne(ConnectionInterface $con = null) Return the first ChildRecord matching the query
67
 * @method     ChildRecord findOneOrCreate(ConnectionInterface $con = null) Return the first ChildRecord matching the query, or a new ChildRecord object populated from the query conditions when no match is found
68
 *
69
 * @method     ChildRecord findOneById(int $id) Return the first ChildRecord filtered by the id column
70
 * @method     ChildRecord findOneByMapuid(string $mapUid) Return the first ChildRecord filtered by the mapUid column
71
 * @method     ChildRecord findOneByNblaps(int $nbLaps) Return the first ChildRecord filtered by the nbLaps column
72
 * @method     ChildRecord findOneByScore(int $score) Return the first ChildRecord filtered by the score column
73
 * @method     ChildRecord findOneByNbfinish(int $nbFinish) Return the first ChildRecord filtered by the nbFinish column
74
 * @method     ChildRecord findOneByAvgscore(int $avgScore) Return the first ChildRecord filtered by the avgScore column
75
 * @method     ChildRecord findOneByCheckpoints(string $checkpoints) Return the first ChildRecord filtered by the checkpoints column
76
 * @method     ChildRecord findOneByPlayerId(int $player_id) Return the first ChildRecord filtered by the player_id column
77
 * @method     ChildRecord findOneByCreatedAt(string $created_at) Return the first ChildRecord filtered by the created_at column
78
 * @method     ChildRecord findOneByUpdatedAt(string $updated_at) Return the first ChildRecord filtered by the updated_at column *
79
80
 * @method     ChildRecord requirePk($key, ConnectionInterface $con = null) Return the ChildRecord by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
81
 * @method     ChildRecord requireOne(ConnectionInterface $con = null) Return the first ChildRecord matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
82
 *
83
 * @method     ChildRecord requireOneById(int $id) Return the first ChildRecord filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
84
 * @method     ChildRecord requireOneByMapuid(string $mapUid) Return the first ChildRecord filtered by the mapUid column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
85
 * @method     ChildRecord requireOneByNblaps(int $nbLaps) Return the first ChildRecord filtered by the nbLaps column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
86
 * @method     ChildRecord requireOneByScore(int $score) Return the first ChildRecord filtered by the score column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
87
 * @method     ChildRecord requireOneByNbfinish(int $nbFinish) Return the first ChildRecord filtered by the nbFinish column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
88
 * @method     ChildRecord requireOneByAvgscore(int $avgScore) Return the first ChildRecord filtered by the avgScore column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
89
 * @method     ChildRecord requireOneByCheckpoints(string $checkpoints) Return the first ChildRecord filtered by the checkpoints column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
90
 * @method     ChildRecord requireOneByPlayerId(int $player_id) Return the first ChildRecord filtered by the player_id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
91
 * @method     ChildRecord requireOneByCreatedAt(string $created_at) Return the first ChildRecord filtered by the created_at column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
92
 * @method     ChildRecord requireOneByUpdatedAt(string $updated_at) Return the first ChildRecord filtered by the updated_at column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
93
 *
94
 * @method     ChildRecord[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildRecord objects based on current ModelCriteria
95
 * @method     ChildRecord[]|ObjectCollection findById(int $id) Return ChildRecord objects filtered by the id column
96
 * @method     ChildRecord[]|ObjectCollection findByMapuid(string $mapUid) Return ChildRecord objects filtered by the mapUid column
97
 * @method     ChildRecord[]|ObjectCollection findByNblaps(int $nbLaps) Return ChildRecord objects filtered by the nbLaps column
98
 * @method     ChildRecord[]|ObjectCollection findByScore(int $score) Return ChildRecord objects filtered by the score column
99
 * @method     ChildRecord[]|ObjectCollection findByNbfinish(int $nbFinish) Return ChildRecord objects filtered by the nbFinish column
100
 * @method     ChildRecord[]|ObjectCollection findByAvgscore(int $avgScore) Return ChildRecord objects filtered by the avgScore column
101
 * @method     ChildRecord[]|ObjectCollection findByCheckpoints(string $checkpoints) Return ChildRecord objects filtered by the checkpoints column
102
 * @method     ChildRecord[]|ObjectCollection findByPlayerId(int $player_id) Return ChildRecord objects filtered by the player_id column
103
 * @method     ChildRecord[]|ObjectCollection findByCreatedAt(string $created_at) Return ChildRecord objects filtered by the created_at column
104
 * @method     ChildRecord[]|ObjectCollection findByUpdatedAt(string $updated_at) Return ChildRecord objects filtered by the updated_at column
105
 * @method     ChildRecord[]|\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
106
 *
107
 */
108
abstract class RecordQuery extends ModelCriteria
109
{
110
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
111
112
    /**
113
     * Initializes internal state of \eXpansion\Bundle\LocalRecords\Model\Base\RecordQuery object.
114
     *
115
     * @param     string $dbName The database name
116
     * @param     string $modelName The phpName of a model, e.g. 'Book'
117
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
118
     */
119
    public function __construct($dbName = 'expansion', $modelName = '\\eXpansion\\Bundle\\LocalRecords\\Model\\Record', $modelAlias = null)
120
    {
121
        parent::__construct($dbName, $modelName, $modelAlias);
122
    }
123
124
    /**
125
     * Returns a new ChildRecordQuery object.
126
     *
127
     * @param     string $modelAlias The alias of a model in the query
128
     * @param     Criteria $criteria Optional Criteria to build the query from
129
     *
130
     * @return ChildRecordQuery
131
     */
132 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...
133
    {
134
        if ($criteria instanceof ChildRecordQuery) {
135
            return $criteria;
136
        }
137
        $query = new ChildRecordQuery();
138
        if (null !== $modelAlias) {
139
            $query->setModelAlias($modelAlias);
140
        }
141
        if ($criteria instanceof Criteria) {
142
            $query->mergeWith($criteria);
143
        }
144
145
        return $query;
146
    }
147
148
    /**
149
     * Find object by primary key.
150
     * Propel uses the instance pool to skip the database if the object exists.
151
     * Go fast if the query is untouched.
152
     *
153
     * <code>
154
     * $obj  = $c->findPk(12, $con);
155
     * </code>
156
     *
157
     * @param mixed $key Primary key to use for the query
158
     * @param ConnectionInterface $con an optional connection object
159
     *
160
     * @return ChildRecord|array|mixed the result, formatted by the current formatter
161
     */
162 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...
163
    {
164
        if ($key === null) {
165
            return null;
166
        }
167
168
        if ($con === null) {
169
            $con = Propel::getServiceContainer()->getReadConnection(RecordTableMap::DATABASE_NAME);
170
        }
171
172
        $this->basePreSelect($con);
173
174
        if (
175
            $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...
176
            || $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...
177
            || $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...
178
        ) {
179
            return $this->findPkComplex($key, $con);
180
        }
181
182
        if ((null !== ($obj = RecordTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key)))) {
183
            // the object is already in the instance pool
184
            return $obj;
185
        }
186
187
        return $this->findPkSimple($key, $con);
188
    }
189
190
    /**
191
     * Find object by primary key using raw SQL to go fast.
192
     * Bypass doSelect() and the object formatter by using generated code.
193
     *
194
     * @param     mixed $key Primary key to use for the query
195
     * @param     ConnectionInterface $con A connection object
196
     *
197
     * @throws \Propel\Runtime\Exception\PropelException
198
     *
199
     * @return ChildRecord A model object, or null if the key is not found
200
     */
201 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...
202
    {
203
        $sql = 'SELECT id, mapUid, nbLaps, score, nbFinish, avgScore, checkpoints, player_id, created_at, updated_at FROM record WHERE id = :p0';
204
        try {
205
            $stmt = $con->prepare($sql);
206
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
207
            $stmt->execute();
208
        } catch (Exception $e) {
209
            Propel::log($e->getMessage(), Propel::LOG_ERR);
210
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
211
        }
212
        $obj = null;
213
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
214
            /** @var ChildRecord $obj */
215
            $obj = new ChildRecord();
216
            $obj->hydrate($row);
217
            RecordTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key);
218
        }
219
        $stmt->closeCursor();
220
221
        return $obj;
222
    }
223
224
    /**
225
     * Find object by primary key.
226
     *
227
     * @param     mixed $key Primary key to use for the query
228
     * @param     ConnectionInterface $con A connection object
229
     *
230
     * @return ChildRecord|array|mixed the result, formatted by the current formatter
231
     */
232 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...
233
    {
234
        // As the query uses a PK condition, no limit(1) is necessary.
235
        $criteria = $this->isKeepQuery() ? clone $this : $this;
236
        $dataFetcher = $criteria
237
            ->filterByPrimaryKey($key)
238
            ->doSelect($con);
239
240
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
241
    }
242
243
    /**
244
     * Find objects by primary key
245
     * <code>
246
     * $objs = $c->findPks(array(12, 56, 832), $con);
247
     * </code>
248
     * @param     array $keys Primary keys to use for the query
249
     * @param     ConnectionInterface $con an optional connection object
250
     *
251
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
252
     */
253 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...
254
    {
255
        if (null === $con) {
256
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
257
        }
258
        $this->basePreSelect($con);
259
        $criteria = $this->isKeepQuery() ? clone $this : $this;
260
        $dataFetcher = $criteria
261
            ->filterByPrimaryKeys($keys)
262
            ->doSelect($con);
263
264
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
265
    }
266
267
    /**
268
     * Filter the query by primary key
269
     *
270
     * @param     mixed $key Primary key to use for the query
271
     *
272
     * @return $this|ChildRecordQuery The current query, for fluid interface
273
     */
274
    public function filterByPrimaryKey($key)
275
    {
276
277
        return $this->addUsingAlias(RecordTableMap::COL_ID, $key, Criteria::EQUAL);
278
    }
279
280
    /**
281
     * Filter the query by a list of primary keys
282
     *
283
     * @param     array $keys The list of primary key to use for the query
284
     *
285
     * @return $this|ChildRecordQuery The current query, for fluid interface
286
     */
287
    public function filterByPrimaryKeys($keys)
288
    {
289
290
        return $this->addUsingAlias(RecordTableMap::COL_ID, $keys, Criteria::IN);
291
    }
292
293
    /**
294
     * Filter the query on the id column
295
     *
296
     * Example usage:
297
     * <code>
298
     * $query->filterById(1234); // WHERE id = 1234
299
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
300
     * $query->filterById(array('min' => 12)); // WHERE id > 12
301
     * </code>
302
     *
303
     * @param     mixed $id The value to use as filter.
304
     *              Use scalar values for equality.
305
     *              Use array values for in_array() equivalent.
306
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
307
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
308
     *
309
     * @return $this|ChildRecordQuery The current query, for fluid interface
310
     */
311 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...
312
    {
313
        if (is_array($id)) {
314
            $useMinMax = false;
315
            if (isset($id['min'])) {
316
                $this->addUsingAlias(RecordTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
317
                $useMinMax = true;
318
            }
319
            if (isset($id['max'])) {
320
                $this->addUsingAlias(RecordTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
321
                $useMinMax = true;
322
            }
323
            if ($useMinMax) {
324
                return $this;
325
            }
326
            if (null === $comparison) {
327
                $comparison = Criteria::IN;
328
            }
329
        }
330
331
        return $this->addUsingAlias(RecordTableMap::COL_ID, $id, $comparison);
332
    }
333
334
    /**
335
     * Filter the query on the mapUid column
336
     *
337
     * Example usage:
338
     * <code>
339
     * $query->filterByMapuid('fooValue');   // WHERE mapUid = 'fooValue'
340
     * $query->filterByMapuid('%fooValue%', Criteria::LIKE); // WHERE mapUid LIKE '%fooValue%'
341
     * </code>
342
     *
343
     * @param     string $mapuid The value to use as filter.
344
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
345
     *
346
     * @return $this|ChildRecordQuery The current query, for fluid interface
347
     */
348 View Code Duplication
    public function filterByMapuid($mapuid = 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...
349
    {
350
        if (null === $comparison) {
351
            if (is_array($mapuid)) {
352
                $comparison = Criteria::IN;
353
            }
354
        }
355
356
        return $this->addUsingAlias(RecordTableMap::COL_MAPUID, $mapuid, $comparison);
357
    }
358
359
    /**
360
     * Filter the query on the nbLaps column
361
     *
362
     * Example usage:
363
     * <code>
364
     * $query->filterByNblaps(1234); // WHERE nbLaps = 1234
365
     * $query->filterByNblaps(array(12, 34)); // WHERE nbLaps IN (12, 34)
366
     * $query->filterByNblaps(array('min' => 12)); // WHERE nbLaps > 12
367
     * </code>
368
     *
369
     * @param     mixed $nblaps The value to use as filter.
370
     *              Use scalar values for equality.
371
     *              Use array values for in_array() equivalent.
372
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
373
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
374
     *
375
     * @return $this|ChildRecordQuery The current query, for fluid interface
376
     */
377 View Code Duplication
    public function filterByNblaps($nblaps = 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...
378
    {
379
        if (is_array($nblaps)) {
380
            $useMinMax = false;
381
            if (isset($nblaps['min'])) {
382
                $this->addUsingAlias(RecordTableMap::COL_NBLAPS, $nblaps['min'], Criteria::GREATER_EQUAL);
383
                $useMinMax = true;
384
            }
385
            if (isset($nblaps['max'])) {
386
                $this->addUsingAlias(RecordTableMap::COL_NBLAPS, $nblaps['max'], Criteria::LESS_EQUAL);
387
                $useMinMax = true;
388
            }
389
            if ($useMinMax) {
390
                return $this;
391
            }
392
            if (null === $comparison) {
393
                $comparison = Criteria::IN;
394
            }
395
        }
396
397
        return $this->addUsingAlias(RecordTableMap::COL_NBLAPS, $nblaps, $comparison);
398
    }
399
400
    /**
401
     * Filter the query on the score column
402
     *
403
     * Example usage:
404
     * <code>
405
     * $query->filterByScore(1234); // WHERE score = 1234
406
     * $query->filterByScore(array(12, 34)); // WHERE score IN (12, 34)
407
     * $query->filterByScore(array('min' => 12)); // WHERE score > 12
408
     * </code>
409
     *
410
     * @param     mixed $score The value to use as filter.
411
     *              Use scalar values for equality.
412
     *              Use array values for in_array() equivalent.
413
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
414
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
415
     *
416
     * @return $this|ChildRecordQuery The current query, for fluid interface
417
     */
418 View Code Duplication
    public function filterByScore($score = 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...
419
    {
420
        if (is_array($score)) {
421
            $useMinMax = false;
422
            if (isset($score['min'])) {
423
                $this->addUsingAlias(RecordTableMap::COL_SCORE, $score['min'], Criteria::GREATER_EQUAL);
424
                $useMinMax = true;
425
            }
426
            if (isset($score['max'])) {
427
                $this->addUsingAlias(RecordTableMap::COL_SCORE, $score['max'], Criteria::LESS_EQUAL);
428
                $useMinMax = true;
429
            }
430
            if ($useMinMax) {
431
                return $this;
432
            }
433
            if (null === $comparison) {
434
                $comparison = Criteria::IN;
435
            }
436
        }
437
438
        return $this->addUsingAlias(RecordTableMap::COL_SCORE, $score, $comparison);
439
    }
440
441
    /**
442
     * Filter the query on the nbFinish column
443
     *
444
     * Example usage:
445
     * <code>
446
     * $query->filterByNbfinish(1234); // WHERE nbFinish = 1234
447
     * $query->filterByNbfinish(array(12, 34)); // WHERE nbFinish IN (12, 34)
448
     * $query->filterByNbfinish(array('min' => 12)); // WHERE nbFinish > 12
449
     * </code>
450
     *
451
     * @param     mixed $nbfinish The value to use as filter.
452
     *              Use scalar values for equality.
453
     *              Use array values for in_array() equivalent.
454
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
455
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
456
     *
457
     * @return $this|ChildRecordQuery The current query, for fluid interface
458
     */
459 View Code Duplication
    public function filterByNbfinish($nbfinish = 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...
460
    {
461
        if (is_array($nbfinish)) {
462
            $useMinMax = false;
463
            if (isset($nbfinish['min'])) {
464
                $this->addUsingAlias(RecordTableMap::COL_NBFINISH, $nbfinish['min'], Criteria::GREATER_EQUAL);
465
                $useMinMax = true;
466
            }
467
            if (isset($nbfinish['max'])) {
468
                $this->addUsingAlias(RecordTableMap::COL_NBFINISH, $nbfinish['max'], Criteria::LESS_EQUAL);
469
                $useMinMax = true;
470
            }
471
            if ($useMinMax) {
472
                return $this;
473
            }
474
            if (null === $comparison) {
475
                $comparison = Criteria::IN;
476
            }
477
        }
478
479
        return $this->addUsingAlias(RecordTableMap::COL_NBFINISH, $nbfinish, $comparison);
480
    }
481
482
    /**
483
     * Filter the query on the avgScore column
484
     *
485
     * Example usage:
486
     * <code>
487
     * $query->filterByAvgscore(1234); // WHERE avgScore = 1234
488
     * $query->filterByAvgscore(array(12, 34)); // WHERE avgScore IN (12, 34)
489
     * $query->filterByAvgscore(array('min' => 12)); // WHERE avgScore > 12
490
     * </code>
491
     *
492
     * @param     mixed $avgscore The value to use as filter.
493
     *              Use scalar values for equality.
494
     *              Use array values for in_array() equivalent.
495
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
496
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
497
     *
498
     * @return $this|ChildRecordQuery The current query, for fluid interface
499
     */
500 View Code Duplication
    public function filterByAvgscore($avgscore = 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...
501
    {
502
        if (is_array($avgscore)) {
503
            $useMinMax = false;
504
            if (isset($avgscore['min'])) {
505
                $this->addUsingAlias(RecordTableMap::COL_AVGSCORE, $avgscore['min'], Criteria::GREATER_EQUAL);
506
                $useMinMax = true;
507
            }
508
            if (isset($avgscore['max'])) {
509
                $this->addUsingAlias(RecordTableMap::COL_AVGSCORE, $avgscore['max'], Criteria::LESS_EQUAL);
510
                $useMinMax = true;
511
            }
512
            if ($useMinMax) {
513
                return $this;
514
            }
515
            if (null === $comparison) {
516
                $comparison = Criteria::IN;
517
            }
518
        }
519
520
        return $this->addUsingAlias(RecordTableMap::COL_AVGSCORE, $avgscore, $comparison);
521
    }
522
523
    /**
524
     * Filter the query on the checkpoints column
525
     *
526
     * Example usage:
527
     * <code>
528
     * $query->filterByCheckpoints('fooValue');   // WHERE checkpoints = 'fooValue'
529
     * $query->filterByCheckpoints('%fooValue%', Criteria::LIKE); // WHERE checkpoints LIKE '%fooValue%'
530
     * </code>
531
     *
532
     * @param     string $checkpoints The value to use as filter.
533
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
534
     *
535
     * @return $this|ChildRecordQuery The current query, for fluid interface
536
     */
537 View Code Duplication
    public function filterByCheckpoints($checkpoints = 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...
538
    {
539
        if (null === $comparison) {
540
            if (is_array($checkpoints)) {
541
                $comparison = Criteria::IN;
542
            }
543
        }
544
545
        return $this->addUsingAlias(RecordTableMap::COL_CHECKPOINTS, $checkpoints, $comparison);
546
    }
547
548
    /**
549
     * Filter the query on the player_id column
550
     *
551
     * Example usage:
552
     * <code>
553
     * $query->filterByPlayerId(1234); // WHERE player_id = 1234
554
     * $query->filterByPlayerId(array(12, 34)); // WHERE player_id IN (12, 34)
555
     * $query->filterByPlayerId(array('min' => 12)); // WHERE player_id > 12
556
     * </code>
557
     *
558
     * @see       filterByPlayer()
559
     *
560
     * @param     mixed $playerId The value to use as filter.
561
     *              Use scalar values for equality.
562
     *              Use array values for in_array() equivalent.
563
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
564
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
565
     *
566
     * @return $this|ChildRecordQuery The current query, for fluid interface
567
     */
568 View Code Duplication
    public function filterByPlayerId($playerId = 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...
569
    {
570
        if (is_array($playerId)) {
571
            $useMinMax = false;
572
            if (isset($playerId['min'])) {
573
                $this->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $playerId['min'], Criteria::GREATER_EQUAL);
574
                $useMinMax = true;
575
            }
576
            if (isset($playerId['max'])) {
577
                $this->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $playerId['max'], Criteria::LESS_EQUAL);
578
                $useMinMax = true;
579
            }
580
            if ($useMinMax) {
581
                return $this;
582
            }
583
            if (null === $comparison) {
584
                $comparison = Criteria::IN;
585
            }
586
        }
587
588
        return $this->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $playerId, $comparison);
589
    }
590
591
    /**
592
     * Filter the query on the created_at column
593
     *
594
     * Example usage:
595
     * <code>
596
     * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
597
     * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
598
     * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
599
     * </code>
600
     *
601
     * @param     mixed $createdAt The value to use as filter.
602
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
603
     *              Empty strings are treated as NULL.
604
     *              Use scalar values for equality.
605
     *              Use array values for in_array() equivalent.
606
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
607
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
608
     *
609
     * @return $this|ChildRecordQuery The current query, for fluid interface
610
     */
611 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...
612
    {
613
        if (is_array($createdAt)) {
614
            $useMinMax = false;
615
            if (isset($createdAt['min'])) {
616
                $this->addUsingAlias(RecordTableMap::COL_CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
617
                $useMinMax = true;
618
            }
619
            if (isset($createdAt['max'])) {
620
                $this->addUsingAlias(RecordTableMap::COL_CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
621
                $useMinMax = true;
622
            }
623
            if ($useMinMax) {
624
                return $this;
625
            }
626
            if (null === $comparison) {
627
                $comparison = Criteria::IN;
628
            }
629
        }
630
631
        return $this->addUsingAlias(RecordTableMap::COL_CREATED_AT, $createdAt, $comparison);
632
    }
633
634
    /**
635
     * Filter the query on the updated_at column
636
     *
637
     * Example usage:
638
     * <code>
639
     * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
640
     * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
641
     * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
642
     * </code>
643
     *
644
     * @param     mixed $updatedAt The value to use as filter.
645
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
646
     *              Empty strings are treated as NULL.
647
     *              Use scalar values for equality.
648
     *              Use array values for in_array() equivalent.
649
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
650
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
651
     *
652
     * @return $this|ChildRecordQuery The current query, for fluid interface
653
     */
654 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...
655
    {
656
        if (is_array($updatedAt)) {
657
            $useMinMax = false;
658
            if (isset($updatedAt['min'])) {
659
                $this->addUsingAlias(RecordTableMap::COL_UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
660
                $useMinMax = true;
661
            }
662
            if (isset($updatedAt['max'])) {
663
                $this->addUsingAlias(RecordTableMap::COL_UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
664
                $useMinMax = true;
665
            }
666
            if ($useMinMax) {
667
                return $this;
668
            }
669
            if (null === $comparison) {
670
                $comparison = Criteria::IN;
671
            }
672
        }
673
674
        return $this->addUsingAlias(RecordTableMap::COL_UPDATED_AT, $updatedAt, $comparison);
675
    }
676
677
    /**
678
     * Filter the query by a related \eXpansion\Framework\PlayersBundle\Model\Player object
679
     *
680
     * @param \eXpansion\Framework\PlayersBundle\Model\Player|ObjectCollection $player The related object(s) to use as filter
681
     * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
682
     *
683
     * @throws \Propel\Runtime\Exception\PropelException
684
     *
685
     * @return ChildRecordQuery The current query, for fluid interface
686
     */
687
    public function filterByPlayer($player, $comparison = null)
688
    {
689
        if ($player instanceof \eXpansion\Framework\PlayersBundle\Model\Player) {
690
            return $this
691
                ->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $player->getId(), $comparison);
692
        } elseif ($player instanceof ObjectCollection) {
693
            if (null === $comparison) {
694
                $comparison = Criteria::IN;
695
            }
696
697
            return $this
698
                ->addUsingAlias(RecordTableMap::COL_PLAYER_ID, $player->toKeyValue('PrimaryKey', 'Id'), $comparison);
699
        } else {
700
            throw new PropelException('filterByPlayer() only accepts arguments of type \eXpansion\Framework\PlayersBundle\Model\Player or Collection');
701
        }
702
    }
703
704
    /**
705
     * Adds a JOIN clause to the query using the Player relation
706
     *
707
     * @param     string $relationAlias optional alias for the relation
708
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
709
     *
710
     * @return $this|ChildRecordQuery The current query, for fluid interface
711
     */
712 View Code Duplication
    public function joinPlayer($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
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...
713
    {
714
        $tableMap = $this->getTableMap();
715
        $relationMap = $tableMap->getRelation('Player');
716
717
        // create a ModelJoin object for this join
718
        $join = new ModelJoin();
719
        $join->setJoinType($joinType);
720
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
721
        if ($previousJoin = $this->getPreviousJoin()) {
722
            $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...
723
        }
724
725
        // add the ModelJoin to the current object
726
        if ($relationAlias) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $relationAlias 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...
727
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
728
            $this->addJoinObject($join, $relationAlias);
729
        } else {
730
            $this->addJoinObject($join, 'Player');
731
        }
732
733
        return $this;
734
    }
735
736
    /**
737
     * Use the Player relation Player object
738
     *
739
     * @see useQuery()
740
     *
741
     * @param     string $relationAlias optional alias for the relation,
742
     *                                   to be used as main alias in the secondary query
743
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
744
     *
745
     * @return \eXpansion\Framework\PlayersBundle\Model\PlayerQuery A secondary query class using the current class as primary query
746
     */
747
    public function usePlayerQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
748
    {
749
        return $this
750
            ->joinPlayer($relationAlias, $joinType)
751
            ->useQuery($relationAlias ? $relationAlias : 'Player', '\eXpansion\Framework\PlayersBundle\Model\PlayerQuery');
752
    }
753
754
    /**
755
     * Exclude object from result
756
     *
757
     * @param   ChildRecord $record Object to remove from the list of results
758
     *
759
     * @return $this|ChildRecordQuery The current query, for fluid interface
760
     */
761
    public function prune($record = null)
762
    {
763
        if ($record) {
764
            $this->addUsingAlias(RecordTableMap::COL_ID, $record->getId(), Criteria::NOT_EQUAL);
765
        }
766
767
        return $this;
768
    }
769
770
    /**
771
     * Deletes all rows from the record table.
772
     *
773
     * @param ConnectionInterface $con the connection to use
774
     * @return int The number of affected rows (if supported by underlying database driver).
775
     */
776 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...
777
    {
778
        if (null === $con) {
779
            $con = Propel::getServiceContainer()->getWriteConnection(RecordTableMap::DATABASE_NAME);
780
        }
781
782
        // use transaction because $criteria could contain info
783
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
784
        return $con->transaction(function () use ($con) {
785
            $affectedRows = 0; // initialize var to track total num of affected rows
786
            $affectedRows += parent::doDeleteAll($con);
787
            // Because this db requires some delete cascade/set null emulation, we have to
788
            // clear the cached instance *after* the emulation has happened (since
789
            // instances get re-added by the select statement contained therein).
790
            RecordTableMap::clearInstancePool();
791
            RecordTableMap::clearRelatedInstancePool();
792
793
            return $affectedRows;
794
        });
795
    }
796
797
    /**
798
     * Performs a DELETE on the database based on the current ModelCriteria
799
     *
800
     * @param ConnectionInterface $con the connection to use
801
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
802
     *                         if supported by native driver or if emulated using Propel.
803
     * @throws PropelException Any exceptions caught during processing will be
804
     *                         rethrown wrapped into a PropelException.
805
     */
806 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...
807
    {
808
        if (null === $con) {
809
            $con = Propel::getServiceContainer()->getWriteConnection(RecordTableMap::DATABASE_NAME);
810
        }
811
812
        $criteria = $this;
813
814
        // Set the correct dbName
815
        $criteria->setDbName(RecordTableMap::DATABASE_NAME);
816
817
        // use transaction because $criteria could contain info
818
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
819
        return $con->transaction(function () use ($con, $criteria) {
820
            $affectedRows = 0; // initialize var to track total num of affected rows
821
822
            RecordTableMap::removeInstanceFromPool($criteria);
823
824
            $affectedRows += ModelCriteria::delete($con);
825
            RecordTableMap::clearRelatedInstancePool();
826
827
            return $affectedRows;
828
        });
829
    }
830
831
    // timestampable behavior
832
833
    /**
834
     * Filter by the latest updated
835
     *
836
     * @param      int $nbDays Maximum age of the latest update in days
837
     *
838
     * @return     $this|ChildRecordQuery The current query, for fluid interface
839
     */
840
    public function recentlyUpdated($nbDays = 7)
841
    {
842
        return $this->addUsingAlias(RecordTableMap::COL_UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
843
    }
844
845
    /**
846
     * Order by update date desc
847
     *
848
     * @return     $this|ChildRecordQuery The current query, for fluid interface
849
     */
850
    public function lastUpdatedFirst()
851
    {
852
        return $this->addDescendingOrderByColumn(RecordTableMap::COL_UPDATED_AT);
853
    }
854
855
    /**
856
     * Order by update date asc
857
     *
858
     * @return     $this|ChildRecordQuery The current query, for fluid interface
859
     */
860
    public function firstUpdatedFirst()
861
    {
862
        return $this->addAscendingOrderByColumn(RecordTableMap::COL_UPDATED_AT);
863
    }
864
865
    /**
866
     * Order by create date desc
867
     *
868
     * @return     $this|ChildRecordQuery The current query, for fluid interface
869
     */
870
    public function lastCreatedFirst()
871
    {
872
        return $this->addDescendingOrderByColumn(RecordTableMap::COL_CREATED_AT);
873
    }
874
875
    /**
876
     * Filter by the latest created
877
     *
878
     * @param      int $nbDays Maximum age of in days
879
     *
880
     * @return     $this|ChildRecordQuery The current query, for fluid interface
881
     */
882
    public function recentlyCreated($nbDays = 7)
883
    {
884
        return $this->addUsingAlias(RecordTableMap::COL_CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL);
885
    }
886
887
    /**
888
     * Order by create date asc
889
     *
890
     * @return     $this|ChildRecordQuery The current query, for fluid interface
891
     */
892
    public function firstCreatedFirst()
893
    {
894
        return $this->addAscendingOrderByColumn(RecordTableMap::COL_CREATED_AT);
895
    }
896
897
} // RecordQuery
898