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