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

TaskQuery::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\Task\Base;
4
5
use \Exception;
6
use \PDO;
7
use Core\Models\Task\Task as ChildTask;
8
use Core\Models\Task\TaskQuery as ChildTaskQuery;
9
use Core\Models\Task\Map\TaskTableMap;
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 'tasks' table.
19
 *
20
 *
21
 *
22
 * @method     ChildTaskQuery orderById($order = Criteria::ASC) Order by the id column
23
 * @method     ChildTaskQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column
24
 * @method     ChildTaskQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column
25
 *
26
 * @method     ChildTaskQuery groupById() Group by the id column
27
 * @method     ChildTaskQuery groupByCreatedAt() Group by the created_at column
28
 * @method     ChildTaskQuery groupByUpdatedAt() Group by the updated_at column
29
 *
30
 * @method     ChildTaskQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
31
 * @method     ChildTaskQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
32
 * @method     ChildTaskQuery innerJoin($relation) Adds a INNER JOIN clause to the query
33
 *
34
 * @method     ChildTaskQuery leftJoinWith($relation) Adds a LEFT JOIN clause and with to the query
35
 * @method     ChildTaskQuery rightJoinWith($relation) Adds a RIGHT JOIN clause and with to the query
36
 * @method     ChildTaskQuery innerJoinWith($relation) Adds a INNER JOIN clause and with to the query
37
 *
38
 * @method     ChildTask findOne(ConnectionInterface $con = null) Return the first ChildTask matching the query
39
 * @method     ChildTask findOneOrCreate(ConnectionInterface $con = null) Return the first ChildTask matching the query, or a new ChildTask object populated from the query conditions when no match is found
40
 *
41
 * @method     ChildTask findOneById(int $id) Return the first ChildTask filtered by the id column
42
 * @method     ChildTask findOneByCreatedAt(string $created_at) Return the first ChildTask filtered by the created_at column
43
 * @method     ChildTask findOneByUpdatedAt(string $updated_at) Return the first ChildTask filtered by the updated_at column *
44
45
 * @method     ChildTask requirePk($key, ConnectionInterface $con = null) Return the ChildTask by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
46
 * @method     ChildTask requireOne(ConnectionInterface $con = null) Return the first ChildTask matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
47
 *
48
 * @method     ChildTask requireOneById(int $id) Return the first ChildTask filtered by the id column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
49
 * @method     ChildTask requireOneByCreatedAt(string $created_at) Return the first ChildTask filtered by the created_at column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
50
 * @method     ChildTask requireOneByUpdatedAt(string $updated_at) Return the first ChildTask filtered by the updated_at column and throws \Propel\Runtime\Exception\EntityNotFoundException when not found
51
 *
52
 * @method     ChildTask[]|ObjectCollection find(ConnectionInterface $con = null) Return ChildTask objects based on current ModelCriteria
53
 * @method     ChildTask[]|ObjectCollection findById(int $id) Return ChildTask objects filtered by the id column
54
 * @method     ChildTask[]|ObjectCollection findByCreatedAt(string $created_at) Return ChildTask objects filtered by the created_at column
55
 * @method     ChildTask[]|ObjectCollection findByUpdatedAt(string $updated_at) Return ChildTask objects filtered by the updated_at column
56
 * @method     ChildTask[]|\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
57
 *
58
 */
59
abstract class TaskQuery extends ModelCriteria
60
{
61
    protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException';
62
63
    /**
64
     * Initializes internal state of \Core\Models\Task\Base\TaskQuery object.
65
     *
66
     * @param     string $dbName The database name
67
     * @param     string $modelName The phpName of a model, e.g. 'Book'
68
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
69
     */
70
    public function __construct($dbName = 'default', $modelName = '\\Core\\Models\\Task\\Task', $modelAlias = null)
71
    {
72
        parent::__construct($dbName, $modelName, $modelAlias);
73
    }
74
75
    /**
76
     * Returns a new ChildTaskQuery object.
77
     *
78
     * @param     string $modelAlias The alias of a model in the query
79
     * @param     Criteria $criteria Optional Criteria to build the query from
80
     *
81
     * @return ChildTaskQuery
82
     */
83 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...
84
    {
85
        if ($criteria instanceof ChildTaskQuery) {
86
            return $criteria;
87
        }
88
        $query = new ChildTaskQuery();
89
        if (null !== $modelAlias) {
90
            $query->setModelAlias($modelAlias);
91
        }
92
        if ($criteria instanceof Criteria) {
93
            $query->mergeWith($criteria);
94
        }
95
96
        return $query;
97
    }
98
99
    /**
100
     * Find object by primary key.
101
     * Propel uses the instance pool to skip the database if the object exists.
102
     * Go fast if the query is untouched.
103
     *
104
     * <code>
105
     * $obj  = $c->findPk(12, $con);
106
     * </code>
107
     *
108
     * @param mixed $key Primary key to use for the query
109
     * @param ConnectionInterface $con an optional connection object
110
     *
111
     * @return ChildTask|array|mixed the result, formatted by the current formatter
112
     */
113 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...
114
    {
115
        if ($key === null) {
116
            return null;
117
        }
118
119
        if ($con === null) {
120
            $con = Propel::getServiceContainer()->getReadConnection(TaskTableMap::DATABASE_NAME);
121
        }
122
123
        $this->basePreSelect($con);
124
125
        if (
126
            $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...
127
            || $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...
128
            || $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...
129
        ) {
130
            return $this->findPkComplex($key, $con);
131
        }
132
133
        if ((null !== ($obj = TaskTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key)))) {
134
            // the object is already in the instance pool
135
            return $obj;
136
        }
137
138
        return $this->findPkSimple($key, $con);
139
    }
140
141
    /**
142
     * Find object by primary key using raw SQL to go fast.
143
     * Bypass doSelect() and the object formatter by using generated code.
144
     *
145
     * @param     mixed $key Primary key to use for the query
146
     * @param     ConnectionInterface $con A connection object
147
     *
148
     * @throws \Propel\Runtime\Exception\PropelException
149
     *
150
     * @return ChildTask A model object, or null if the key is not found
151
     */
152 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...
153
    {
154
        $sql = 'SELECT id, created_at, updated_at FROM tasks WHERE id = :p0';
155
        try {
156
            $stmt = $con->prepare($sql);
157
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
158
            $stmt->execute();
159
        } catch (Exception $e) {
160
            Propel::log($e->getMessage(), Propel::LOG_ERR);
161
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e);
162
        }
163
        $obj = null;
164
        if ($row = $stmt->fetch(\PDO::FETCH_NUM)) {
165
            /** @var ChildTask $obj */
166
            $obj = new ChildTask();
167
            $obj->hydrate($row);
168
            TaskTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key);
169
        }
170
        $stmt->closeCursor();
171
172
        return $obj;
173
    }
174
175
    /**
176
     * Find object by primary key.
177
     *
178
     * @param     mixed $key Primary key to use for the query
179
     * @param     ConnectionInterface $con A connection object
180
     *
181
     * @return ChildTask|array|mixed the result, formatted by the current formatter
182
     */
183 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...
184
    {
185
        // As the query uses a PK condition, no limit(1) is necessary.
186
        $criteria = $this->isKeepQuery() ? clone $this : $this;
187
        $dataFetcher = $criteria
188
            ->filterByPrimaryKey($key)
189
            ->doSelect($con);
190
191
        return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher);
192
    }
193
194
    /**
195
     * Find objects by primary key
196
     * <code>
197
     * $objs = $c->findPks(array(12, 56, 832), $con);
198
     * </code>
199
     * @param     array $keys Primary keys to use for the query
200
     * @param     ConnectionInterface $con an optional connection object
201
     *
202
     * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter
203
     */
204 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...
205
    {
206
        if (null === $con) {
207
            $con = Propel::getServiceContainer()->getReadConnection($this->getDbName());
208
        }
209
        $this->basePreSelect($con);
210
        $criteria = $this->isKeepQuery() ? clone $this : $this;
211
        $dataFetcher = $criteria
212
            ->filterByPrimaryKeys($keys)
213
            ->doSelect($con);
214
215
        return $criteria->getFormatter()->init($criteria)->format($dataFetcher);
216
    }
217
218
    /**
219
     * Filter the query by primary key
220
     *
221
     * @param     mixed $key Primary key to use for the query
222
     *
223
     * @return $this|ChildTaskQuery The current query, for fluid interface
224
     */
225
    public function filterByPrimaryKey($key)
226
    {
227
228
        return $this->addUsingAlias(TaskTableMap::COL_ID, $key, Criteria::EQUAL);
229
    }
230
231
    /**
232
     * Filter the query by a list of primary keys
233
     *
234
     * @param     array $keys The list of primary key to use for the query
235
     *
236
     * @return $this|ChildTaskQuery The current query, for fluid interface
237
     */
238
    public function filterByPrimaryKeys($keys)
239
    {
240
241
        return $this->addUsingAlias(TaskTableMap::COL_ID, $keys, Criteria::IN);
242
    }
243
244
    /**
245
     * Filter the query on the id column
246
     *
247
     * Example usage:
248
     * <code>
249
     * $query->filterById(1234); // WHERE id = 1234
250
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
251
     * $query->filterById(array('min' => 12)); // WHERE id > 12
252
     * </code>
253
     *
254
     * @param     mixed $id The value to use as filter.
255
     *              Use scalar values for equality.
256
     *              Use array values for in_array() equivalent.
257
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
258
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
259
     *
260
     * @return $this|ChildTaskQuery The current query, for fluid interface
261
     */
262 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...
263
    {
264
        if (is_array($id)) {
265
            $useMinMax = false;
266
            if (isset($id['min'])) {
267
                $this->addUsingAlias(TaskTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL);
268
                $useMinMax = true;
269
            }
270
            if (isset($id['max'])) {
271
                $this->addUsingAlias(TaskTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL);
272
                $useMinMax = true;
273
            }
274
            if ($useMinMax) {
275
                return $this;
276
            }
277
            if (null === $comparison) {
278
                $comparison = Criteria::IN;
279
            }
280
        }
281
282
        return $this->addUsingAlias(TaskTableMap::COL_ID, $id, $comparison);
283
    }
284
285
    /**
286
     * Filter the query on the created_at column
287
     *
288
     * Example usage:
289
     * <code>
290
     * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14'
291
     * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14'
292
     * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13'
293
     * </code>
294
     *
295
     * @param     mixed $createdAt The value to use as filter.
296
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
297
     *              Empty strings are treated as NULL.
298
     *              Use scalar values for equality.
299
     *              Use array values for in_array() equivalent.
300
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
301
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
302
     *
303
     * @return $this|ChildTaskQuery The current query, for fluid interface
304
     */
305 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...
306
    {
307
        if (is_array($createdAt)) {
308
            $useMinMax = false;
309
            if (isset($createdAt['min'])) {
310
                $this->addUsingAlias(TaskTableMap::COL_CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL);
311
                $useMinMax = true;
312
            }
313
            if (isset($createdAt['max'])) {
314
                $this->addUsingAlias(TaskTableMap::COL_CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL);
315
                $useMinMax = true;
316
            }
317
            if ($useMinMax) {
318
                return $this;
319
            }
320
            if (null === $comparison) {
321
                $comparison = Criteria::IN;
322
            }
323
        }
324
325
        return $this->addUsingAlias(TaskTableMap::COL_CREATED_AT, $createdAt, $comparison);
326
    }
327
328
    /**
329
     * Filter the query on the updated_at column
330
     *
331
     * Example usage:
332
     * <code>
333
     * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14'
334
     * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14'
335
     * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13'
336
     * </code>
337
     *
338
     * @param     mixed $updatedAt The value to use as filter.
339
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
340
     *              Empty strings are treated as NULL.
341
     *              Use scalar values for equality.
342
     *              Use array values for in_array() equivalent.
343
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
344
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
345
     *
346
     * @return $this|ChildTaskQuery The current query, for fluid interface
347
     */
348 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...
349
    {
350
        if (is_array($updatedAt)) {
351
            $useMinMax = false;
352
            if (isset($updatedAt['min'])) {
353
                $this->addUsingAlias(TaskTableMap::COL_UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL);
354
                $useMinMax = true;
355
            }
356
            if (isset($updatedAt['max'])) {
357
                $this->addUsingAlias(TaskTableMap::COL_UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL);
358
                $useMinMax = true;
359
            }
360
            if ($useMinMax) {
361
                return $this;
362
            }
363
            if (null === $comparison) {
364
                $comparison = Criteria::IN;
365
            }
366
        }
367
368
        return $this->addUsingAlias(TaskTableMap::COL_UPDATED_AT, $updatedAt, $comparison);
369
    }
370
371
    /**
372
     * Exclude object from result
373
     *
374
     * @param   ChildTask $task Object to remove from the list of results
375
     *
376
     * @return $this|ChildTaskQuery The current query, for fluid interface
377
     */
378
    public function prune($task = null)
379
    {
380
        if ($task) {
381
            $this->addUsingAlias(TaskTableMap::COL_ID, $task->getId(), Criteria::NOT_EQUAL);
382
        }
383
384
        return $this;
385
    }
386
387
    /**
388
     * Deletes all rows from the tasks table.
389
     *
390
     * @param ConnectionInterface $con the connection to use
391
     * @return int The number of affected rows (if supported by underlying database driver).
392
     */
393 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...
394
    {
395
        if (null === $con) {
396
            $con = Propel::getServiceContainer()->getWriteConnection(TaskTableMap::DATABASE_NAME);
397
        }
398
399
        // use transaction because $criteria could contain info
400
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
401
        return $con->transaction(function () use ($con) {
402
            $affectedRows = 0; // initialize var to track total num of affected rows
403
            $affectedRows += parent::doDeleteAll($con);
404
            // Because this db requires some delete cascade/set null emulation, we have to
405
            // clear the cached instance *after* the emulation has happened (since
406
            // instances get re-added by the select statement contained therein).
407
            TaskTableMap::clearInstancePool();
408
            TaskTableMap::clearRelatedInstancePool();
409
410
            return $affectedRows;
411
        });
412
    }
413
414
    /**
415
     * Performs a DELETE on the database based on the current ModelCriteria
416
     *
417
     * @param ConnectionInterface $con the connection to use
418
     * @return int             The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
419
     *                         if supported by native driver or if emulated using Propel.
420
     * @throws PropelException Any exceptions caught during processing will be
421
     *                         rethrown wrapped into a PropelException.
422
     */
423 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...
424
    {
425
        if (null === $con) {
426
            $con = Propel::getServiceContainer()->getWriteConnection(TaskTableMap::DATABASE_NAME);
427
        }
428
429
        $criteria = $this;
430
431
        // Set the correct dbName
432
        $criteria->setDbName(TaskTableMap::DATABASE_NAME);
433
434
        // use transaction because $criteria could contain info
435
        // for more than one table or we could emulating ON DELETE CASCADE, etc.
436
        return $con->transaction(function () use ($con, $criteria) {
437
            $affectedRows = 0; // initialize var to track total num of affected rows
438
439
            TaskTableMap::removeInstanceFromPool($criteria);
440
441
            $affectedRows += ModelCriteria::delete($con);
442
            TaskTableMap::clearRelatedInstancePool();
443
444
            return $affectedRows;
445
        });
446
    }
447
448
} // TaskQuery
449