1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Database\Map; |
4
|
|
|
|
5
|
|
|
use Jalle19\StatusManager\Database\Input; |
6
|
|
|
use Jalle19\StatusManager\Database\InputQuery; |
7
|
|
|
use Propel\Runtime\Propel; |
8
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
9
|
|
|
use Propel\Runtime\ActiveQuery\InstancePoolTrait; |
10
|
|
|
use Propel\Runtime\Connection\ConnectionInterface; |
11
|
|
|
use Propel\Runtime\DataFetcher\DataFetcherInterface; |
12
|
|
|
use Propel\Runtime\Exception\PropelException; |
13
|
|
|
use Propel\Runtime\Map\RelationMap; |
14
|
|
|
use Propel\Runtime\Map\TableMap; |
15
|
|
|
use Propel\Runtime\Map\TableMapTrait; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* This class defines the structure of the 'input' table. |
20
|
|
|
* |
21
|
|
|
* |
22
|
|
|
* |
23
|
|
|
* This map class is used by Propel to do runtime db structure discovery. |
24
|
|
|
* For example, the createSelectSql() method checks the type of a given column used in an |
25
|
|
|
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive |
26
|
|
|
* (i.e. if it's a text column type). |
27
|
|
|
* |
28
|
|
|
*/ |
29
|
|
|
class InputTableMap extends TableMap |
30
|
|
|
{ |
31
|
|
|
use InstancePoolTrait; |
32
|
|
|
use TableMapTrait; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The (dot-path) name of this class |
36
|
|
|
*/ |
37
|
|
|
const CLASS_NAME = 'Jalle19.StatusManager.Database.Map.InputTableMap'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The default database name for this class |
41
|
|
|
*/ |
42
|
|
|
const DATABASE_NAME = 'tvheadend_status_manager'; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* The table name for this class |
46
|
|
|
*/ |
47
|
|
|
const TABLE_NAME = 'input'; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* The related Propel class for this table |
51
|
|
|
*/ |
52
|
|
|
const OM_CLASS = '\\Jalle19\\StatusManager\\Database\\Input'; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* A class that can be returned by this tableMap |
56
|
|
|
*/ |
57
|
|
|
const CLASS_DEFAULT = 'Jalle19.StatusManager.Database.Input'; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* The total number of columns |
61
|
|
|
*/ |
62
|
|
|
const NUM_COLUMNS = 7; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* The number of lazy-loaded columns |
66
|
|
|
*/ |
67
|
|
|
const NUM_LAZY_LOAD_COLUMNS = 0; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) |
71
|
|
|
*/ |
72
|
|
|
const NUM_HYDRATE_COLUMNS = 7; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* the column name for the uuid field |
76
|
|
|
*/ |
77
|
|
|
const COL_UUID = 'input.uuid'; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* the column name for the instance_name field |
81
|
|
|
*/ |
82
|
|
|
const COL_INSTANCE_NAME = 'input.instance_name'; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* the column name for the started field |
86
|
|
|
*/ |
87
|
|
|
const COL_STARTED = 'input.started'; |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* the column name for the input field |
91
|
|
|
*/ |
92
|
|
|
const COL_INPUT = 'input.input'; |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* the column name for the network field |
96
|
|
|
*/ |
97
|
|
|
const COL_NETWORK = 'input.network'; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* the column name for the mux field |
101
|
|
|
*/ |
102
|
|
|
const COL_MUX = 'input.mux'; |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* the column name for the weight field |
106
|
|
|
*/ |
107
|
|
|
const COL_WEIGHT = 'input.weight'; |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* The default string format for model objects of the related table |
111
|
|
|
*/ |
112
|
|
|
const DEFAULT_STRING_FORMAT = 'YAML'; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* holds an array of fieldnames |
116
|
|
|
* |
117
|
|
|
* first dimension keys are the type constants |
118
|
|
|
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' |
119
|
|
|
*/ |
120
|
|
|
protected static $fieldNames = array ( |
121
|
|
|
self::TYPE_PHPNAME => array('Uuid', 'InstanceName', 'Started', 'Input', 'Network', 'Mux', 'Weight', ), |
122
|
|
|
self::TYPE_CAMELNAME => array('uuid', 'instanceName', 'started', 'input', 'network', 'mux', 'weight', ), |
123
|
|
|
self::TYPE_COLNAME => array(InputTableMap::COL_UUID, InputTableMap::COL_INSTANCE_NAME, InputTableMap::COL_STARTED, InputTableMap::COL_INPUT, InputTableMap::COL_NETWORK, InputTableMap::COL_MUX, InputTableMap::COL_WEIGHT, ), |
124
|
|
|
self::TYPE_FIELDNAME => array('uuid', 'instance_name', 'started', 'input', 'network', 'mux', 'weight', ), |
125
|
|
|
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) |
126
|
|
|
); |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* holds an array of keys for quick access to the fieldnames array |
130
|
|
|
* |
131
|
|
|
* first dimension keys are the type constants |
132
|
|
|
* e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 |
133
|
|
|
*/ |
134
|
|
|
protected static $fieldKeys = array ( |
135
|
|
|
self::TYPE_PHPNAME => array('Uuid' => 0, 'InstanceName' => 1, 'Started' => 2, 'Input' => 3, 'Network' => 4, 'Mux' => 5, 'Weight' => 6, ), |
136
|
|
|
self::TYPE_CAMELNAME => array('uuid' => 0, 'instanceName' => 1, 'started' => 2, 'input' => 3, 'network' => 4, 'mux' => 5, 'weight' => 6, ), |
137
|
|
|
self::TYPE_COLNAME => array(InputTableMap::COL_UUID => 0, InputTableMap::COL_INSTANCE_NAME => 1, InputTableMap::COL_STARTED => 2, InputTableMap::COL_INPUT => 3, InputTableMap::COL_NETWORK => 4, InputTableMap::COL_MUX => 5, InputTableMap::COL_WEIGHT => 6, ), |
138
|
|
|
self::TYPE_FIELDNAME => array('uuid' => 0, 'instance_name' => 1, 'started' => 2, 'input' => 3, 'network' => 4, 'mux' => 5, 'weight' => 6, ), |
139
|
|
|
self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) |
140
|
|
|
); |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* Initialize the table attributes and columns |
144
|
|
|
* Relations are not initialized by this method since they are lazy loaded |
145
|
|
|
* |
146
|
|
|
* @return void |
147
|
|
|
* @throws PropelException |
148
|
|
|
*/ |
149
|
|
|
public function initialize() |
150
|
|
|
{ |
151
|
|
|
// attributes |
152
|
|
|
$this->setName('input'); |
153
|
|
|
$this->setPhpName('Input'); |
154
|
|
|
$this->setIdentifierQuoting(false); |
155
|
|
|
$this->setClassName('\\Jalle19\\StatusManager\\Database\\Input'); |
156
|
|
|
$this->setPackage('Jalle19.StatusManager.Database'); |
157
|
|
|
$this->setUseIdGenerator(false); |
158
|
|
|
// columns |
159
|
|
|
$this->addPrimaryKey('uuid', 'Uuid', 'VARCHAR', true, 255, null); |
160
|
|
|
$this->addForeignKey('instance_name', 'InstanceName', 'VARCHAR', 'instance', 'name', true, 255, null); |
161
|
|
|
$this->addColumn('started', 'Started', 'TIMESTAMP', true, null, null); |
162
|
|
|
$this->addColumn('input', 'Input', 'VARCHAR', true, 255, null); |
163
|
|
|
$this->addColumn('network', 'Network', 'VARCHAR', true, 255, null); |
164
|
|
|
$this->addColumn('mux', 'Mux', 'VARCHAR', true, 255, null); |
165
|
|
|
$this->addColumn('weight', 'Weight', 'INTEGER', true, null, null); |
166
|
|
|
} // initialize() |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* Build the RelationMap objects for this table relationships |
170
|
|
|
*/ |
171
|
|
View Code Duplication |
public function buildRelations() |
|
|
|
|
172
|
|
|
{ |
173
|
|
|
$this->addRelation('Instance', '\\Jalle19\\StatusManager\\Database\\Instance', RelationMap::MANY_TO_ONE, array ( |
174
|
|
|
0 => |
175
|
|
|
array ( |
176
|
|
|
0 => ':instance_name', |
177
|
|
|
1 => ':name', |
178
|
|
|
), |
179
|
|
|
), null, null, null, false); |
180
|
|
|
$this->addRelation('Subscription', '\\Jalle19\\StatusManager\\Database\\Subscription', RelationMap::ONE_TO_MANY, array ( |
181
|
|
|
0 => |
182
|
|
|
array ( |
183
|
|
|
0 => ':input_uuid', |
184
|
|
|
1 => ':uuid', |
185
|
|
|
), |
186
|
|
|
), null, null, 'Subscriptions', false); |
187
|
|
|
} // buildRelations() |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. |
191
|
|
|
* |
192
|
|
|
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
193
|
|
|
* a multi-column primary key, a serialize()d version of the primary key will be returned. |
194
|
|
|
* |
195
|
|
|
* @param array $row resultset row. |
196
|
|
|
* @param int $offset The 0-based offset for reading from the resultset row. |
197
|
|
|
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
198
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
199
|
|
|
* |
200
|
|
|
* @return string The primary key hash of the row |
201
|
|
|
*/ |
202
|
|
View Code Duplication |
public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
|
|
|
203
|
|
|
{ |
204
|
|
|
// If the PK cannot be derived from the row, return NULL. |
205
|
|
|
if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)] === null) { |
206
|
|
|
return null; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
return null === $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)] || is_scalar($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)]) || is_callable([$row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)], '__toString']) ? (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)] : $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)]; |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Retrieves the primary key from the DB resultset row |
214
|
|
|
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with |
215
|
|
|
* a multi-column primary key, an array of the primary key columns will be returned. |
216
|
|
|
* |
217
|
|
|
* @param array $row resultset row. |
218
|
|
|
* @param int $offset The 0-based offset for reading from the resultset row. |
219
|
|
|
* @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
220
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM |
221
|
|
|
* |
222
|
|
|
* @return mixed The primary key of the row |
223
|
|
|
*/ |
224
|
|
View Code Duplication |
public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
|
|
|
225
|
|
|
{ |
226
|
|
|
return (string) $row[ |
227
|
|
|
$indexType == TableMap::TYPE_NUM |
228
|
|
|
? 0 + $offset |
229
|
|
|
: self::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType) |
230
|
|
|
]; |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* The class that the tableMap will make instances of. |
235
|
|
|
* |
236
|
|
|
* If $withPrefix is true, the returned path |
237
|
|
|
* uses a dot-path notation which is translated into a path |
238
|
|
|
* relative to a location on the PHP include_path. |
239
|
|
|
* (e.g. path.to.MyClass -> 'path/to/MyClass.php') |
240
|
|
|
* |
241
|
|
|
* @param boolean $withPrefix Whether or not to return the path with the class name |
242
|
|
|
* @return string path.to.ClassName |
243
|
|
|
*/ |
244
|
|
|
public static function getOMClass($withPrefix = true) |
245
|
|
|
{ |
246
|
|
|
return $withPrefix ? InputTableMap::CLASS_DEFAULT : InputTableMap::OM_CLASS; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* Populates an object of the default type or an object that inherit from the default. |
251
|
|
|
* |
252
|
|
|
* @param array $row row returned by DataFetcher->fetch(). |
253
|
|
|
* @param int $offset The 0-based offset for reading from the resultset row. |
254
|
|
|
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
255
|
|
|
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
256
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
257
|
|
|
* |
258
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
259
|
|
|
* rethrown wrapped into a PropelException. |
260
|
|
|
* @return array (Input object, last column rank) |
261
|
|
|
*/ |
262
|
|
View Code Duplication |
public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) |
|
|
|
|
263
|
|
|
{ |
264
|
|
|
$key = InputTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); |
265
|
|
|
if (null !== ($obj = InputTableMap::getInstanceFromPool($key))) { |
266
|
|
|
// We no longer rehydrate the object, since this can cause data loss. |
267
|
|
|
// See http://www.propelorm.org/ticket/509 |
268
|
|
|
// $obj->hydrate($row, $offset, true); // rehydrate |
|
|
|
|
269
|
|
|
$col = $offset + InputTableMap::NUM_HYDRATE_COLUMNS; |
270
|
|
|
} else { |
271
|
|
|
$cls = InputTableMap::OM_CLASS; |
272
|
|
|
/** @var Input $obj */ |
273
|
|
|
$obj = new $cls(); |
274
|
|
|
$col = $obj->hydrate($row, $offset, false, $indexType); |
275
|
|
|
InputTableMap::addInstanceToPool($obj, $key); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
return array($obj, $col); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* The returned array will contain objects of the default type or |
283
|
|
|
* objects that inherit from the default. |
284
|
|
|
* |
285
|
|
|
* @param DataFetcherInterface $dataFetcher |
286
|
|
|
* @return array |
287
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
288
|
|
|
* rethrown wrapped into a PropelException. |
289
|
|
|
*/ |
290
|
|
View Code Duplication |
public static function populateObjects(DataFetcherInterface $dataFetcher) |
|
|
|
|
291
|
|
|
{ |
292
|
|
|
$results = array(); |
293
|
|
|
|
294
|
|
|
// set the class once to avoid overhead in the loop |
295
|
|
|
$cls = static::getOMClass(false); |
296
|
|
|
// populate the object(s) |
297
|
|
|
while ($row = $dataFetcher->fetch()) { |
298
|
|
|
$key = InputTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); |
299
|
|
|
if (null !== ($obj = InputTableMap::getInstanceFromPool($key))) { |
300
|
|
|
// We no longer rehydrate the object, since this can cause data loss. |
301
|
|
|
// See http://www.propelorm.org/ticket/509 |
302
|
|
|
// $obj->hydrate($row, 0, true); // rehydrate |
|
|
|
|
303
|
|
|
$results[] = $obj; |
304
|
|
|
} else { |
305
|
|
|
/** @var Input $obj */ |
306
|
|
|
$obj = new $cls(); |
307
|
|
|
$obj->hydrate($row); |
308
|
|
|
$results[] = $obj; |
309
|
|
|
InputTableMap::addInstanceToPool($obj, $key); |
310
|
|
|
} // if key exists |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
return $results; |
314
|
|
|
} |
315
|
|
|
/** |
316
|
|
|
* Add all the columns needed to create a new object. |
317
|
|
|
* |
318
|
|
|
* Note: any columns that were marked with lazyLoad="true" in the |
319
|
|
|
* XML schema will not be added to the select list and only loaded |
320
|
|
|
* on demand. |
321
|
|
|
* |
322
|
|
|
* @param Criteria $criteria object containing the columns to add. |
323
|
|
|
* @param string $alias optional table alias |
324
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
325
|
|
|
* rethrown wrapped into a PropelException. |
326
|
|
|
*/ |
327
|
|
|
public static function addSelectColumns(Criteria $criteria, $alias = null) |
328
|
|
|
{ |
329
|
|
|
if (null === $alias) { |
330
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_UUID); |
331
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_INSTANCE_NAME); |
332
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_STARTED); |
333
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_INPUT); |
334
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_NETWORK); |
335
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_MUX); |
336
|
|
|
$criteria->addSelectColumn(InputTableMap::COL_WEIGHT); |
337
|
|
View Code Duplication |
} else { |
|
|
|
|
338
|
|
|
$criteria->addSelectColumn($alias . '.uuid'); |
339
|
|
|
$criteria->addSelectColumn($alias . '.instance_name'); |
340
|
|
|
$criteria->addSelectColumn($alias . '.started'); |
341
|
|
|
$criteria->addSelectColumn($alias . '.input'); |
342
|
|
|
$criteria->addSelectColumn($alias . '.network'); |
343
|
|
|
$criteria->addSelectColumn($alias . '.mux'); |
344
|
|
|
$criteria->addSelectColumn($alias . '.weight'); |
345
|
|
|
} |
346
|
|
|
} |
347
|
|
|
|
348
|
|
|
/** |
349
|
|
|
* Returns the TableMap related to this object. |
350
|
|
|
* This method is not needed for general use but a specific application could have a need. |
351
|
|
|
* @return TableMap |
352
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
353
|
|
|
* rethrown wrapped into a PropelException. |
354
|
|
|
*/ |
355
|
|
|
public static function getTableMap() |
356
|
|
|
{ |
357
|
|
|
return Propel::getServiceContainer()->getDatabaseMap(InputTableMap::DATABASE_NAME)->getTable(InputTableMap::TABLE_NAME); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* Add a TableMap instance to the database for this tableMap class. |
362
|
|
|
*/ |
363
|
|
|
public static function buildTableMap() |
364
|
|
|
{ |
365
|
|
|
$dbMap = Propel::getServiceContainer()->getDatabaseMap(InputTableMap::DATABASE_NAME); |
366
|
|
|
if (!$dbMap->hasTable(InputTableMap::TABLE_NAME)) { |
367
|
|
|
$dbMap->addTableObject(new InputTableMap()); |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Performs a DELETE on the database, given a Input or Criteria object OR a primary key value. |
373
|
|
|
* |
374
|
|
|
* @param mixed $values Criteria or Input object or primary key or array of primary keys |
375
|
|
|
* which is used to create the DELETE statement |
376
|
|
|
* @param ConnectionInterface $con the connection to use |
377
|
|
|
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
378
|
|
|
* if supported by native driver or if emulated using Propel. |
379
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
380
|
|
|
* rethrown wrapped into a PropelException. |
381
|
|
|
*/ |
382
|
|
|
public static function doDelete($values, ConnectionInterface $con = null) |
383
|
|
|
{ |
384
|
|
|
if (null === $con) { |
385
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
386
|
|
|
} |
387
|
|
|
|
388
|
|
|
if ($values instanceof Criteria) { |
389
|
|
|
// rename for clarity |
390
|
|
|
$criteria = $values; |
391
|
|
|
} elseif ($values instanceof \Jalle19\StatusManager\Database\Input) { // it's a model object |
392
|
|
|
// create criteria based on pk values |
393
|
|
|
$criteria = $values->buildPkeyCriteria(); |
394
|
|
|
} else { // it's a primary key, or an array of pks |
395
|
|
|
$criteria = new Criteria(InputTableMap::DATABASE_NAME); |
396
|
|
|
$criteria->add(InputTableMap::COL_UUID, (array) $values, Criteria::IN); |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
$query = InputQuery::create()->mergeWith($criteria); |
400
|
|
|
|
401
|
|
|
if ($values instanceof Criteria) { |
402
|
|
|
InputTableMap::clearInstancePool(); |
403
|
|
|
} elseif (!is_object($values)) { // it's a primary key, or an array of pks |
404
|
|
|
foreach ((array) $values as $singleval) { |
405
|
|
|
InputTableMap::removeInstanceFromPool($singleval); |
406
|
|
|
} |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
return $query->delete($con); |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
/** |
413
|
|
|
* Deletes all rows from the input table. |
414
|
|
|
* |
415
|
|
|
* @param ConnectionInterface $con the connection to use |
416
|
|
|
* @return int The number of affected rows (if supported by underlying database driver). |
417
|
|
|
*/ |
418
|
|
|
public static function doDeleteAll(ConnectionInterface $con = null) |
419
|
|
|
{ |
420
|
|
|
return InputQuery::create()->doDeleteAll($con); |
421
|
|
|
} |
422
|
|
|
|
423
|
|
|
/** |
424
|
|
|
* Performs an INSERT on the database, given a Input or Criteria object. |
425
|
|
|
* |
426
|
|
|
* @param mixed $criteria Criteria or Input object containing data that is used to create the INSERT statement. |
427
|
|
|
* @param ConnectionInterface $con the ConnectionInterface connection to use |
428
|
|
|
* @return mixed The new primary key. |
429
|
|
|
* @throws PropelException Any exceptions caught during processing will be |
430
|
|
|
* rethrown wrapped into a PropelException. |
431
|
|
|
*/ |
432
|
|
View Code Duplication |
public static function doInsert($criteria, ConnectionInterface $con = null) |
|
|
|
|
433
|
|
|
{ |
434
|
|
|
if (null === $con) { |
435
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
if ($criteria instanceof Criteria) { |
439
|
|
|
$criteria = clone $criteria; // rename for clarity |
440
|
|
|
} else { |
441
|
|
|
$criteria = $criteria->buildCriteria(); // build Criteria from Input object |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
|
445
|
|
|
// Set the correct dbName |
446
|
|
|
$query = InputQuery::create()->mergeWith($criteria); |
447
|
|
|
|
448
|
|
|
// use transaction because $criteria could contain info |
449
|
|
|
// for more than one table (I guess, conceivably) |
450
|
|
|
return $con->transaction(function () use ($con, $query) { |
451
|
|
|
return $query->doInsert($con); |
452
|
|
|
}); |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
} // InputTableMap |
456
|
|
|
// This is the static code needed to register the TableMap for this table with the main Propel class. |
457
|
|
|
// |
458
|
|
|
InputTableMap::buildTableMap(); |
459
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.