1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Database\Base; |
4
|
|
|
|
5
|
|
|
use \DateTime; |
6
|
|
|
use \Exception; |
7
|
|
|
use \PDO; |
8
|
|
|
use Jalle19\StatusManager\Database\Channel as ChildChannel; |
9
|
|
|
use Jalle19\StatusManager\Database\ChannelQuery as ChildChannelQuery; |
10
|
|
|
use Jalle19\StatusManager\Database\Input as ChildInput; |
11
|
|
|
use Jalle19\StatusManager\Database\InputQuery as ChildInputQuery; |
12
|
|
|
use Jalle19\StatusManager\Database\Instance as ChildInstance; |
13
|
|
|
use Jalle19\StatusManager\Database\InstanceQuery as ChildInstanceQuery; |
14
|
|
|
use Jalle19\StatusManager\Database\SubscriptionQuery as ChildSubscriptionQuery; |
15
|
|
|
use Jalle19\StatusManager\Database\User as ChildUser; |
16
|
|
|
use Jalle19\StatusManager\Database\UserQuery as ChildUserQuery; |
17
|
|
|
use Jalle19\StatusManager\Database\Map\SubscriptionTableMap; |
18
|
|
|
use Propel\Runtime\Propel; |
19
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
20
|
|
|
use Propel\Runtime\ActiveQuery\ModelCriteria; |
21
|
|
|
use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
22
|
|
|
use Propel\Runtime\Collection\Collection; |
23
|
|
|
use Propel\Runtime\Connection\ConnectionInterface; |
24
|
|
|
use Propel\Runtime\Exception\BadMethodCallException; |
25
|
|
|
use Propel\Runtime\Exception\LogicException; |
26
|
|
|
use Propel\Runtime\Exception\PropelException; |
27
|
|
|
use Propel\Runtime\Map\TableMap; |
28
|
|
|
use Propel\Runtime\Parser\AbstractParser; |
29
|
|
|
use Propel\Runtime\Util\PropelDateTime; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Base class that represents a row from the 'subscription' table. |
33
|
|
|
* |
34
|
|
|
* |
35
|
|
|
* |
36
|
|
|
* @package propel.generator.Jalle19.StatusManager.Database.Base |
37
|
|
|
*/ |
38
|
|
|
abstract class Subscription implements ActiveRecordInterface |
39
|
|
|
{ |
40
|
|
|
/** |
41
|
|
|
* TableMap class name |
42
|
|
|
*/ |
43
|
|
|
const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\SubscriptionTableMap'; |
44
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* attribute to determine if this object has previously been saved. |
48
|
|
|
* @var boolean |
49
|
|
|
*/ |
50
|
|
|
protected $new = true; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* attribute to determine whether this object has been deleted. |
54
|
|
|
* @var boolean |
55
|
|
|
*/ |
56
|
|
|
protected $deleted = false; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The columns that have been modified in current object. |
60
|
|
|
* Tracking modified columns allows us to only update modified columns. |
61
|
|
|
* @var array |
62
|
|
|
*/ |
63
|
|
|
protected $modifiedColumns = array(); |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The (virtual) columns that are added at runtime |
67
|
|
|
* The formatters can add supplementary columns based on a resultset |
68
|
|
|
* @var array |
69
|
|
|
*/ |
70
|
|
|
protected $virtualColumns = array(); |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* The value for the id field. |
74
|
|
|
* |
75
|
|
|
* @var int |
76
|
|
|
*/ |
77
|
|
|
protected $id; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* The value for the instance_name field. |
81
|
|
|
* |
82
|
|
|
* @var string |
83
|
|
|
*/ |
84
|
|
|
protected $instance_name; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* The value for the input_uuid field. |
88
|
|
|
* |
89
|
|
|
* @var string |
90
|
|
|
*/ |
91
|
|
|
protected $input_uuid; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* The value for the user_id field. |
95
|
|
|
* |
96
|
|
|
* @var int |
97
|
|
|
*/ |
98
|
|
|
protected $user_id; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* The value for the channel_id field. |
102
|
|
|
* |
103
|
|
|
* @var int |
104
|
|
|
*/ |
105
|
|
|
protected $channel_id; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* The value for the subscription_id field. |
109
|
|
|
* |
110
|
|
|
* @var int |
111
|
|
|
*/ |
112
|
|
|
protected $subscription_id; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* The value for the started field. |
116
|
|
|
* |
117
|
|
|
* @var \DateTime |
118
|
|
|
*/ |
119
|
|
|
protected $started; |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* The value for the stopped field. |
123
|
|
|
* |
124
|
|
|
* @var \DateTime |
125
|
|
|
*/ |
126
|
|
|
protected $stopped; |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* The value for the title field. |
130
|
|
|
* |
131
|
|
|
* @var string |
132
|
|
|
*/ |
133
|
|
|
protected $title; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* The value for the service field. |
137
|
|
|
* |
138
|
|
|
* @var string |
139
|
|
|
*/ |
140
|
|
|
protected $service; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @var ChildInstance |
144
|
|
|
*/ |
145
|
|
|
protected $aInstance; |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @var ChildInput |
149
|
|
|
*/ |
150
|
|
|
protected $aInput; |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @var ChildUser |
154
|
|
|
*/ |
155
|
|
|
protected $aUser; |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @var ChildChannel |
159
|
|
|
*/ |
160
|
|
|
protected $aChannel; |
161
|
|
|
|
162
|
|
|
/** |
163
|
|
|
* Flag to prevent endless save loop, if this object is referenced |
164
|
|
|
* by another object which falls in this transaction. |
165
|
|
|
* |
166
|
|
|
* @var boolean |
167
|
|
|
*/ |
168
|
|
|
protected $alreadyInSave = false; |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* Initializes internal state of Jalle19\StatusManager\Database\Base\Subscription object. |
172
|
|
|
*/ |
173
|
|
|
public function __construct() |
174
|
|
|
{ |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Returns whether the object has been modified. |
179
|
|
|
* |
180
|
|
|
* @return boolean True if the object has been modified. |
181
|
|
|
*/ |
182
|
|
|
public function isModified() |
183
|
|
|
{ |
184
|
|
|
return !!$this->modifiedColumns; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Has specified column been modified? |
189
|
|
|
* |
190
|
|
|
* @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
191
|
|
|
* @return boolean True if $col has been modified. |
192
|
|
|
*/ |
193
|
|
|
public function isColumnModified($col) |
194
|
|
|
{ |
195
|
|
|
return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
|
|
|
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* Get the columns that have been modified in this object. |
200
|
|
|
* @return array A unique list of the modified column names for this object. |
201
|
|
|
*/ |
202
|
|
|
public function getModifiedColumns() |
203
|
|
|
{ |
204
|
|
|
return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Returns whether the object has ever been saved. This will |
209
|
|
|
* be false, if the object was retrieved from storage or was created |
210
|
|
|
* and then saved. |
211
|
|
|
* |
212
|
|
|
* @return boolean true, if the object has never been persisted. |
213
|
|
|
*/ |
214
|
|
|
public function isNew() |
215
|
|
|
{ |
216
|
|
|
return $this->new; |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Setter for the isNew attribute. This method will be called |
221
|
|
|
* by Propel-generated children and objects. |
222
|
|
|
* |
223
|
|
|
* @param boolean $b the state of the object. |
224
|
|
|
*/ |
225
|
|
|
public function setNew($b) |
226
|
|
|
{ |
227
|
|
|
$this->new = (boolean) $b; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Whether this object has been deleted. |
232
|
|
|
* @return boolean The deleted state of this object. |
233
|
|
|
*/ |
234
|
|
|
public function isDeleted() |
235
|
|
|
{ |
236
|
|
|
return $this->deleted; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Specify whether this object has been deleted. |
241
|
|
|
* @param boolean $b The deleted state of this object. |
242
|
|
|
* @return void |
243
|
|
|
*/ |
244
|
|
|
public function setDeleted($b) |
245
|
|
|
{ |
246
|
|
|
$this->deleted = (boolean) $b; |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* Sets the modified state for the object to be false. |
251
|
|
|
* @param string $col If supplied, only the specified column is reset. |
252
|
|
|
* @return void |
253
|
|
|
*/ |
254
|
|
View Code Duplication |
public function resetModified($col = null) |
|
|
|
|
255
|
|
|
{ |
256
|
|
|
if (null !== $col) { |
257
|
|
|
if (isset($this->modifiedColumns[$col])) { |
258
|
|
|
unset($this->modifiedColumns[$col]); |
259
|
|
|
} |
260
|
|
|
} else { |
261
|
|
|
$this->modifiedColumns = array(); |
262
|
|
|
} |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Compares this with another <code>Subscription</code> instance. If |
267
|
|
|
* <code>obj</code> is an instance of <code>Subscription</code>, delegates to |
268
|
|
|
* <code>equals(Subscription)</code>. Otherwise, returns <code>false</code>. |
269
|
|
|
* |
270
|
|
|
* @param mixed $obj The object to compare to. |
271
|
|
|
* @return boolean Whether equal to the object specified. |
272
|
|
|
*/ |
273
|
|
View Code Duplication |
public function equals($obj) |
|
|
|
|
274
|
|
|
{ |
275
|
|
|
if (!$obj instanceof static) { |
276
|
|
|
return false; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
if ($this === $obj) { |
280
|
|
|
return true; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
284
|
|
|
return false; |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* Get the associative array of the virtual columns in this object |
292
|
|
|
* |
293
|
|
|
* @return array |
294
|
|
|
*/ |
295
|
|
|
public function getVirtualColumns() |
296
|
|
|
{ |
297
|
|
|
return $this->virtualColumns; |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* Checks the existence of a virtual column in this object |
302
|
|
|
* |
303
|
|
|
* @param string $name The virtual column name |
304
|
|
|
* @return boolean |
305
|
|
|
*/ |
306
|
|
|
public function hasVirtualColumn($name) |
307
|
|
|
{ |
308
|
|
|
return array_key_exists($name, $this->virtualColumns); |
309
|
|
|
} |
310
|
|
|
|
311
|
|
|
/** |
312
|
|
|
* Get the value of a virtual column in this object |
313
|
|
|
* |
314
|
|
|
* @param string $name The virtual column name |
315
|
|
|
* @return mixed |
316
|
|
|
* |
317
|
|
|
* @throws PropelException |
318
|
|
|
*/ |
319
|
|
View Code Duplication |
public function getVirtualColumn($name) |
|
|
|
|
320
|
|
|
{ |
321
|
|
|
if (!$this->hasVirtualColumn($name)) { |
322
|
|
|
throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
return $this->virtualColumns[$name]; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Set the value of a virtual column in this object |
330
|
|
|
* |
331
|
|
|
* @param string $name The virtual column name |
332
|
|
|
* @param mixed $value The value to give to the virtual column |
333
|
|
|
* |
334
|
|
|
* @return $this|Subscription The current object, for fluid interface |
335
|
|
|
*/ |
336
|
|
|
public function setVirtualColumn($name, $value) |
337
|
|
|
{ |
338
|
|
|
$this->virtualColumns[$name] = $value; |
339
|
|
|
|
340
|
|
|
return $this; |
341
|
|
|
} |
342
|
|
|
|
343
|
|
|
/** |
344
|
|
|
* Logs a message using Propel::log(). |
345
|
|
|
* |
346
|
|
|
* @param string $msg |
347
|
|
|
* @param int $priority One of the Propel::LOG_* logging levels |
348
|
|
|
* @return boolean |
349
|
|
|
*/ |
350
|
|
|
protected function log($msg, $priority = Propel::LOG_INFO) |
351
|
|
|
{ |
352
|
|
|
return Propel::log(get_class($this) . ': ' . $msg, $priority); |
353
|
|
|
} |
354
|
|
|
|
355
|
|
|
/** |
356
|
|
|
* Export the current object properties to a string, using a given parser format |
357
|
|
|
* <code> |
358
|
|
|
* $book = BookQuery::create()->findPk(9012); |
359
|
|
|
* echo $book->exportTo('JSON'); |
360
|
|
|
* => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
361
|
|
|
* </code> |
362
|
|
|
* |
363
|
|
|
* @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
364
|
|
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
365
|
|
|
* @return string The exported data |
366
|
|
|
*/ |
367
|
|
View Code Duplication |
public function exportTo($parser, $includeLazyLoadColumns = true) |
|
|
|
|
368
|
|
|
{ |
369
|
|
|
if (!$parser instanceof AbstractParser) { |
370
|
|
|
$parser = AbstractParser::getParser($parser); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
|
|
|
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* Clean up internal collections prior to serializing |
378
|
|
|
* Avoids recursive loops that turn into segmentation faults when serializing |
379
|
|
|
*/ |
380
|
|
View Code Duplication |
public function __sleep() |
|
|
|
|
381
|
|
|
{ |
382
|
|
|
$this->clearAllReferences(); |
383
|
|
|
|
384
|
|
|
$cls = new \ReflectionClass($this); |
385
|
|
|
$propertyNames = []; |
386
|
|
|
$serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
387
|
|
|
|
388
|
|
|
foreach($serializableProperties as $property) { |
389
|
|
|
$propertyNames[] = $property->getName(); |
390
|
|
|
} |
391
|
|
|
|
392
|
|
|
return $propertyNames; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Get the [id] column value. |
397
|
|
|
* |
398
|
|
|
* @return int |
399
|
|
|
*/ |
400
|
|
|
public function getId() |
401
|
|
|
{ |
402
|
|
|
return $this->id; |
403
|
|
|
} |
404
|
|
|
|
405
|
|
|
/** |
406
|
|
|
* Get the [instance_name] column value. |
407
|
|
|
* |
408
|
|
|
* @return string |
409
|
|
|
*/ |
410
|
|
|
public function getInstanceName() |
411
|
|
|
{ |
412
|
|
|
return $this->instance_name; |
413
|
|
|
} |
414
|
|
|
|
415
|
|
|
/** |
416
|
|
|
* Get the [input_uuid] column value. |
417
|
|
|
* |
418
|
|
|
* @return string |
419
|
|
|
*/ |
420
|
|
|
public function getInputUuid() |
421
|
|
|
{ |
422
|
|
|
return $this->input_uuid; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* Get the [user_id] column value. |
427
|
|
|
* |
428
|
|
|
* @return int |
429
|
|
|
*/ |
430
|
|
|
public function getUserId() |
431
|
|
|
{ |
432
|
|
|
return $this->user_id; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Get the [channel_id] column value. |
437
|
|
|
* |
438
|
|
|
* @return int |
439
|
|
|
*/ |
440
|
|
|
public function getChannelId() |
441
|
|
|
{ |
442
|
|
|
return $this->channel_id; |
443
|
|
|
} |
444
|
|
|
|
445
|
|
|
/** |
446
|
|
|
* Get the [subscription_id] column value. |
447
|
|
|
* |
448
|
|
|
* @return int |
449
|
|
|
*/ |
450
|
|
|
public function getSubscriptionId() |
451
|
|
|
{ |
452
|
|
|
return $this->subscription_id; |
453
|
|
|
} |
454
|
|
|
|
455
|
|
|
/** |
456
|
|
|
* Get the [optionally formatted] temporal [started] column value. |
457
|
|
|
* |
458
|
|
|
* |
459
|
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style). |
460
|
|
|
* If format is NULL, then the raw DateTime object will be returned. |
461
|
|
|
* |
462
|
|
|
* @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
463
|
|
|
* |
464
|
|
|
* @throws PropelException - if unable to parse/validate the date/time value. |
465
|
|
|
*/ |
466
|
|
View Code Duplication |
public function getStarted($format = NULL) |
|
|
|
|
467
|
|
|
{ |
468
|
|
|
if ($format === null) { |
469
|
|
|
return $this->started; |
470
|
|
|
} else { |
471
|
|
|
return $this->started instanceof \DateTime ? $this->started->format($format) : null; |
472
|
|
|
} |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
/** |
476
|
|
|
* Get the [optionally formatted] temporal [stopped] column value. |
477
|
|
|
* |
478
|
|
|
* |
479
|
|
|
* @param string $format The date/time format string (either date()-style or strftime()-style). |
480
|
|
|
* If format is NULL, then the raw DateTime object will be returned. |
481
|
|
|
* |
482
|
|
|
* @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
483
|
|
|
* |
484
|
|
|
* @throws PropelException - if unable to parse/validate the date/time value. |
485
|
|
|
*/ |
486
|
|
|
public function getStopped($format = NULL) |
487
|
|
|
{ |
488
|
|
|
if ($format === null) { |
489
|
|
|
return $this->stopped; |
490
|
|
|
} else { |
491
|
|
|
return $this->stopped instanceof \DateTime ? $this->stopped->format($format) : null; |
492
|
|
|
} |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* Get the [title] column value. |
497
|
|
|
* |
498
|
|
|
* @return string |
499
|
|
|
*/ |
500
|
|
|
public function getTitle() |
501
|
|
|
{ |
502
|
|
|
return $this->title; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* Get the [service] column value. |
507
|
|
|
* |
508
|
|
|
* @return string |
509
|
|
|
*/ |
510
|
|
|
public function getService() |
511
|
|
|
{ |
512
|
|
|
return $this->service; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* Set the value of [id] column. |
517
|
|
|
* |
518
|
|
|
* @param int $v new value |
519
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
520
|
|
|
*/ |
521
|
|
View Code Duplication |
public function setId($v) |
|
|
|
|
522
|
|
|
{ |
523
|
|
|
if ($v !== null) { |
524
|
|
|
$v = (int) $v; |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
if ($this->id !== $v) { |
528
|
|
|
$this->id = $v; |
529
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_ID] = true; |
530
|
|
|
} |
531
|
|
|
|
532
|
|
|
return $this; |
533
|
|
|
} // setId() |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* Set the value of [instance_name] column. |
537
|
|
|
* |
538
|
|
|
* @param string $v new value |
539
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
540
|
|
|
*/ |
541
|
|
View Code Duplication |
public function setInstanceName($v) |
|
|
|
|
542
|
|
|
{ |
543
|
|
|
if ($v !== null) { |
544
|
|
|
$v = (string) $v; |
545
|
|
|
} |
546
|
|
|
|
547
|
|
|
if ($this->instance_name !== $v) { |
548
|
|
|
$this->instance_name = $v; |
549
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_INSTANCE_NAME] = true; |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
553
|
|
|
$this->aInstance = null; |
554
|
|
|
} |
555
|
|
|
|
556
|
|
|
return $this; |
557
|
|
|
} // setInstanceName() |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* Set the value of [input_uuid] column. |
561
|
|
|
* |
562
|
|
|
* @param string $v new value |
563
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
564
|
|
|
*/ |
565
|
|
View Code Duplication |
public function setInputUuid($v) |
|
|
|
|
566
|
|
|
{ |
567
|
|
|
if ($v !== null) { |
568
|
|
|
$v = (string) $v; |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
if ($this->input_uuid !== $v) { |
572
|
|
|
$this->input_uuid = $v; |
573
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_INPUT_UUID] = true; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
if ($this->aInput !== null && $this->aInput->getUuid() !== $v) { |
577
|
|
|
$this->aInput = null; |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
return $this; |
581
|
|
|
} // setInputUuid() |
582
|
|
|
|
583
|
|
|
/** |
584
|
|
|
* Set the value of [user_id] column. |
585
|
|
|
* |
586
|
|
|
* @param int $v new value |
587
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
588
|
|
|
*/ |
589
|
|
View Code Duplication |
public function setUserId($v) |
|
|
|
|
590
|
|
|
{ |
591
|
|
|
if ($v !== null) { |
592
|
|
|
$v = (int) $v; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
if ($this->user_id !== $v) { |
596
|
|
|
$this->user_id = $v; |
597
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_USER_ID] = true; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
if ($this->aUser !== null && $this->aUser->getId() !== $v) { |
601
|
|
|
$this->aUser = null; |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
return $this; |
605
|
|
|
} // setUserId() |
606
|
|
|
|
607
|
|
|
/** |
608
|
|
|
* Set the value of [channel_id] column. |
609
|
|
|
* |
610
|
|
|
* @param int $v new value |
611
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
612
|
|
|
*/ |
613
|
|
View Code Duplication |
public function setChannelId($v) |
|
|
|
|
614
|
|
|
{ |
615
|
|
|
if ($v !== null) { |
616
|
|
|
$v = (int) $v; |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
if ($this->channel_id !== $v) { |
620
|
|
|
$this->channel_id = $v; |
621
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_CHANNEL_ID] = true; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
if ($this->aChannel !== null && $this->aChannel->getId() !== $v) { |
625
|
|
|
$this->aChannel = null; |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
return $this; |
629
|
|
|
} // setChannelId() |
630
|
|
|
|
631
|
|
|
/** |
632
|
|
|
* Set the value of [subscription_id] column. |
633
|
|
|
* |
634
|
|
|
* @param int $v new value |
635
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
636
|
|
|
*/ |
637
|
|
View Code Duplication |
public function setSubscriptionId($v) |
|
|
|
|
638
|
|
|
{ |
639
|
|
|
if ($v !== null) { |
640
|
|
|
$v = (int) $v; |
641
|
|
|
} |
642
|
|
|
|
643
|
|
|
if ($this->subscription_id !== $v) { |
644
|
|
|
$this->subscription_id = $v; |
645
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_SUBSCRIPTION_ID] = true; |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
return $this; |
649
|
|
|
} // setSubscriptionId() |
650
|
|
|
|
651
|
|
|
/** |
652
|
|
|
* Sets the value of [started] column to a normalized version of the date/time value specified. |
653
|
|
|
* |
654
|
|
|
* @param mixed $v string, integer (timestamp), or \DateTime value. |
655
|
|
|
* Empty strings are treated as NULL. |
656
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
657
|
|
|
*/ |
658
|
|
View Code Duplication |
public function setStarted($v) |
|
|
|
|
659
|
|
|
{ |
660
|
|
|
$dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
661
|
|
|
if ($this->started !== null || $dt !== null) { |
662
|
|
|
if ($this->started === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->started->format("Y-m-d H:i:s")) { |
663
|
|
|
$this->started = $dt === null ? null : clone $dt; |
664
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_STARTED] = true; |
665
|
|
|
} |
666
|
|
|
} // if either are not null |
667
|
|
|
|
668
|
|
|
return $this; |
669
|
|
|
} // setStarted() |
670
|
|
|
|
671
|
|
|
/** |
672
|
|
|
* Sets the value of [stopped] column to a normalized version of the date/time value specified. |
673
|
|
|
* |
674
|
|
|
* @param mixed $v string, integer (timestamp), or \DateTime value. |
675
|
|
|
* Empty strings are treated as NULL. |
676
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
677
|
|
|
*/ |
678
|
|
View Code Duplication |
public function setStopped($v) |
|
|
|
|
679
|
|
|
{ |
680
|
|
|
$dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
681
|
|
|
if ($this->stopped !== null || $dt !== null) { |
682
|
|
|
if ($this->stopped === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->stopped->format("Y-m-d H:i:s")) { |
683
|
|
|
$this->stopped = $dt === null ? null : clone $dt; |
684
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_STOPPED] = true; |
685
|
|
|
} |
686
|
|
|
} // if either are not null |
687
|
|
|
|
688
|
|
|
return $this; |
689
|
|
|
} // setStopped() |
690
|
|
|
|
691
|
|
|
/** |
692
|
|
|
* Set the value of [title] column. |
693
|
|
|
* |
694
|
|
|
* @param string $v new value |
695
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
696
|
|
|
*/ |
697
|
|
View Code Duplication |
public function setTitle($v) |
|
|
|
|
698
|
|
|
{ |
699
|
|
|
if ($v !== null) { |
700
|
|
|
$v = (string) $v; |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
if ($this->title !== $v) { |
704
|
|
|
$this->title = $v; |
705
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_TITLE] = true; |
706
|
|
|
} |
707
|
|
|
|
708
|
|
|
return $this; |
709
|
|
|
} // setTitle() |
710
|
|
|
|
711
|
|
|
/** |
712
|
|
|
* Set the value of [service] column. |
713
|
|
|
* |
714
|
|
|
* @param string $v new value |
715
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
716
|
|
|
*/ |
717
|
|
View Code Duplication |
public function setService($v) |
|
|
|
|
718
|
|
|
{ |
719
|
|
|
if ($v !== null) { |
720
|
|
|
$v = (string) $v; |
721
|
|
|
} |
722
|
|
|
|
723
|
|
|
if ($this->service !== $v) { |
724
|
|
|
$this->service = $v; |
725
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_SERVICE] = true; |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
return $this; |
729
|
|
|
} // setService() |
730
|
|
|
|
731
|
|
|
/** |
732
|
|
|
* Indicates whether the columns in this object are only set to default values. |
733
|
|
|
* |
734
|
|
|
* This method can be used in conjunction with isModified() to indicate whether an object is both |
735
|
|
|
* modified _and_ has some values set which are non-default. |
736
|
|
|
* |
737
|
|
|
* @return boolean Whether the columns in this object are only been set with default values. |
738
|
|
|
*/ |
739
|
|
|
public function hasOnlyDefaultValues() |
740
|
|
|
{ |
741
|
|
|
// otherwise, everything was equal, so return TRUE |
742
|
|
|
return true; |
743
|
|
|
} // hasOnlyDefaultValues() |
744
|
|
|
|
745
|
|
|
/** |
746
|
|
|
* Hydrates (populates) the object variables with values from the database resultset. |
747
|
|
|
* |
748
|
|
|
* An offset (0-based "start column") is specified so that objects can be hydrated |
749
|
|
|
* with a subset of the columns in the resultset rows. This is needed, for example, |
750
|
|
|
* for results of JOIN queries where the resultset row includes columns from two or |
751
|
|
|
* more tables. |
752
|
|
|
* |
753
|
|
|
* @param array $row The row returned by DataFetcher->fetch(). |
754
|
|
|
* @param int $startcol 0-based offset column which indicates which restultset column to start with. |
755
|
|
|
* @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
756
|
|
|
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
757
|
|
|
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
758
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
759
|
|
|
* |
760
|
|
|
* @return int next starting column |
761
|
|
|
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
762
|
|
|
*/ |
763
|
|
|
public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
764
|
|
|
{ |
765
|
|
|
try { |
766
|
|
|
|
767
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : SubscriptionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
768
|
|
|
$this->id = (null !== $col) ? (int) $col : null; |
769
|
|
|
|
770
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : SubscriptionTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
771
|
|
|
$this->instance_name = (null !== $col) ? (string) $col : null; |
772
|
|
|
|
773
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : SubscriptionTableMap::translateFieldName('InputUuid', TableMap::TYPE_PHPNAME, $indexType)]; |
774
|
|
|
$this->input_uuid = (null !== $col) ? (string) $col : null; |
775
|
|
|
|
776
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : SubscriptionTableMap::translateFieldName('UserId', TableMap::TYPE_PHPNAME, $indexType)]; |
777
|
|
|
$this->user_id = (null !== $col) ? (int) $col : null; |
778
|
|
|
|
779
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : SubscriptionTableMap::translateFieldName('ChannelId', TableMap::TYPE_PHPNAME, $indexType)]; |
780
|
|
|
$this->channel_id = (null !== $col) ? (int) $col : null; |
781
|
|
|
|
782
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : SubscriptionTableMap::translateFieldName('SubscriptionId', TableMap::TYPE_PHPNAME, $indexType)]; |
783
|
|
|
$this->subscription_id = (null !== $col) ? (int) $col : null; |
784
|
|
|
|
785
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : SubscriptionTableMap::translateFieldName('Started', TableMap::TYPE_PHPNAME, $indexType)]; |
786
|
|
|
$this->started = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
787
|
|
|
|
788
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : SubscriptionTableMap::translateFieldName('Stopped', TableMap::TYPE_PHPNAME, $indexType)]; |
789
|
|
|
$this->stopped = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
790
|
|
|
|
791
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : SubscriptionTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; |
792
|
|
|
$this->title = (null !== $col) ? (string) $col : null; |
793
|
|
|
|
794
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : SubscriptionTableMap::translateFieldName('Service', TableMap::TYPE_PHPNAME, $indexType)]; |
795
|
|
|
$this->service = (null !== $col) ? (string) $col : null; |
796
|
|
|
$this->resetModified(); |
797
|
|
|
|
798
|
|
|
$this->setNew(false); |
799
|
|
|
|
800
|
|
|
if ($rehydrate) { |
801
|
|
|
$this->ensureConsistency(); |
802
|
|
|
} |
803
|
|
|
|
804
|
|
|
return $startcol + 10; // 10 = SubscriptionTableMap::NUM_HYDRATE_COLUMNS. |
805
|
|
|
|
806
|
|
|
} catch (Exception $e) { |
807
|
|
|
throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Subscription'), 0, $e); |
808
|
|
|
} |
809
|
|
|
} |
810
|
|
|
|
811
|
|
|
/** |
812
|
|
|
* Checks and repairs the internal consistency of the object. |
813
|
|
|
* |
814
|
|
|
* This method is executed after an already-instantiated object is re-hydrated |
815
|
|
|
* from the database. It exists to check any foreign keys to make sure that |
816
|
|
|
* the objects related to the current object are correct based on foreign key. |
817
|
|
|
* |
818
|
|
|
* You can override this method in the stub class, but you should always invoke |
819
|
|
|
* the base method from the overridden method (i.e. parent::ensureConsistency()), |
820
|
|
|
* in case your model changes. |
821
|
|
|
* |
822
|
|
|
* @throws PropelException |
823
|
|
|
*/ |
824
|
|
|
public function ensureConsistency() |
825
|
|
|
{ |
826
|
|
View Code Duplication |
if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
|
|
|
827
|
|
|
$this->aInstance = null; |
828
|
|
|
} |
829
|
|
|
if ($this->aInput !== null && $this->input_uuid !== $this->aInput->getUuid()) { |
830
|
|
|
$this->aInput = null; |
831
|
|
|
} |
832
|
|
View Code Duplication |
if ($this->aUser !== null && $this->user_id !== $this->aUser->getId()) { |
|
|
|
|
833
|
|
|
$this->aUser = null; |
834
|
|
|
} |
835
|
|
|
if ($this->aChannel !== null && $this->channel_id !== $this->aChannel->getId()) { |
836
|
|
|
$this->aChannel = null; |
837
|
|
|
} |
838
|
|
|
} // ensureConsistency |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
842
|
|
|
* |
843
|
|
|
* This will only work if the object has been saved and has a valid primary key set. |
844
|
|
|
* |
845
|
|
|
* @param boolean $deep (optional) Whether to also de-associated any related objects. |
846
|
|
|
* @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
847
|
|
|
* @return void |
848
|
|
|
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
849
|
|
|
*/ |
850
|
|
View Code Duplication |
public function reload($deep = false, ConnectionInterface $con = null) |
|
|
|
|
851
|
|
|
{ |
852
|
|
|
if ($this->isDeleted()) { |
853
|
|
|
throw new PropelException("Cannot reload a deleted object."); |
854
|
|
|
} |
855
|
|
|
|
856
|
|
|
if ($this->isNew()) { |
857
|
|
|
throw new PropelException("Cannot reload an unsaved object."); |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
if ($con === null) { |
861
|
|
|
$con = Propel::getServiceContainer()->getReadConnection(SubscriptionTableMap::DATABASE_NAME); |
862
|
|
|
} |
863
|
|
|
|
864
|
|
|
// We don't need to alter the object instance pool; we're just modifying this instance |
865
|
|
|
// already in the pool. |
866
|
|
|
|
867
|
|
|
$dataFetcher = ChildSubscriptionQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
|
|
|
868
|
|
|
$row = $dataFetcher->fetch(); |
869
|
|
|
$dataFetcher->close(); |
870
|
|
|
if (!$row) { |
871
|
|
|
throw new PropelException('Cannot find matching row in the database to reload object values.'); |
872
|
|
|
} |
873
|
|
|
$this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
874
|
|
|
|
875
|
|
|
if ($deep) { // also de-associate any related objects? |
876
|
|
|
|
877
|
|
|
$this->aInstance = null; |
878
|
|
|
$this->aInput = null; |
879
|
|
|
$this->aUser = null; |
880
|
|
|
$this->aChannel = null; |
881
|
|
|
} // if (deep) |
|
|
|
|
882
|
|
|
} |
883
|
|
|
|
884
|
|
|
/** |
885
|
|
|
* Removes this object from datastore and sets delete attribute. |
886
|
|
|
* |
887
|
|
|
* @param ConnectionInterface $con |
888
|
|
|
* @return void |
889
|
|
|
* @throws PropelException |
890
|
|
|
* @see Subscription::setDeleted() |
891
|
|
|
* @see Subscription::isDeleted() |
892
|
|
|
*/ |
893
|
|
View Code Duplication |
public function delete(ConnectionInterface $con = null) |
|
|
|
|
894
|
|
|
{ |
895
|
|
|
if ($this->isDeleted()) { |
896
|
|
|
throw new PropelException("This object has already been deleted."); |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
if ($con === null) { |
900
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
901
|
|
|
} |
902
|
|
|
|
903
|
|
|
$con->transaction(function () use ($con) { |
904
|
|
|
$deleteQuery = ChildSubscriptionQuery::create() |
905
|
|
|
->filterByPrimaryKey($this->getPrimaryKey()); |
906
|
|
|
$ret = $this->preDelete($con); |
907
|
|
|
if ($ret) { |
908
|
|
|
$deleteQuery->delete($con); |
909
|
|
|
$this->postDelete($con); |
910
|
|
|
$this->setDeleted(true); |
911
|
|
|
} |
912
|
|
|
}); |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
/** |
916
|
|
|
* Persists this object to the database. |
917
|
|
|
* |
918
|
|
|
* If the object is new, it inserts it; otherwise an update is performed. |
919
|
|
|
* All modified related objects will also be persisted in the doSave() |
920
|
|
|
* method. This method wraps all precipitate database operations in a |
921
|
|
|
* single transaction. |
922
|
|
|
* |
923
|
|
|
* @param ConnectionInterface $con |
924
|
|
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
925
|
|
|
* @throws PropelException |
926
|
|
|
* @see doSave() |
927
|
|
|
*/ |
928
|
|
View Code Duplication |
public function save(ConnectionInterface $con = null) |
|
|
|
|
929
|
|
|
{ |
930
|
|
|
if ($this->isDeleted()) { |
931
|
|
|
throw new PropelException("You cannot save an object that has been deleted."); |
932
|
|
|
} |
933
|
|
|
|
934
|
|
|
if ($con === null) { |
935
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
936
|
|
|
} |
937
|
|
|
|
938
|
|
|
return $con->transaction(function () use ($con) { |
939
|
|
|
$isInsert = $this->isNew(); |
940
|
|
|
$ret = $this->preSave($con); |
941
|
|
|
if ($isInsert) { |
942
|
|
|
$ret = $ret && $this->preInsert($con); |
943
|
|
|
} else { |
944
|
|
|
$ret = $ret && $this->preUpdate($con); |
945
|
|
|
} |
946
|
|
|
if ($ret) { |
947
|
|
|
$affectedRows = $this->doSave($con); |
948
|
|
|
if ($isInsert) { |
949
|
|
|
$this->postInsert($con); |
950
|
|
|
} else { |
951
|
|
|
$this->postUpdate($con); |
952
|
|
|
} |
953
|
|
|
$this->postSave($con); |
954
|
|
|
SubscriptionTableMap::addInstanceToPool($this); |
955
|
|
|
} else { |
956
|
|
|
$affectedRows = 0; |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
return $affectedRows; |
960
|
|
|
}); |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
/** |
964
|
|
|
* Performs the work of inserting or updating the row in the database. |
965
|
|
|
* |
966
|
|
|
* If the object is new, it inserts it; otherwise an update is performed. |
967
|
|
|
* All related objects are also updated in this method. |
968
|
|
|
* |
969
|
|
|
* @param ConnectionInterface $con |
970
|
|
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
971
|
|
|
* @throws PropelException |
972
|
|
|
* @see save() |
973
|
|
|
*/ |
974
|
|
|
protected function doSave(ConnectionInterface $con) |
975
|
|
|
{ |
976
|
|
|
$affectedRows = 0; // initialize var to track total num of affected rows |
977
|
|
|
if (!$this->alreadyInSave) { |
978
|
|
|
$this->alreadyInSave = true; |
979
|
|
|
|
980
|
|
|
// We call the save method on the following object(s) if they |
981
|
|
|
// were passed to this object by their corresponding set |
982
|
|
|
// method. This object relates to these object(s) by a |
983
|
|
|
// foreign key reference. |
984
|
|
|
|
985
|
|
View Code Duplication |
if ($this->aInstance !== null) { |
|
|
|
|
986
|
|
|
if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
987
|
|
|
$affectedRows += $this->aInstance->save($con); |
988
|
|
|
} |
989
|
|
|
$this->setInstance($this->aInstance); |
990
|
|
|
} |
991
|
|
|
|
992
|
|
View Code Duplication |
if ($this->aInput !== null) { |
|
|
|
|
993
|
|
|
if ($this->aInput->isModified() || $this->aInput->isNew()) { |
994
|
|
|
$affectedRows += $this->aInput->save($con); |
995
|
|
|
} |
996
|
|
|
$this->setInput($this->aInput); |
997
|
|
|
} |
998
|
|
|
|
999
|
|
View Code Duplication |
if ($this->aUser !== null) { |
|
|
|
|
1000
|
|
|
if ($this->aUser->isModified() || $this->aUser->isNew()) { |
1001
|
|
|
$affectedRows += $this->aUser->save($con); |
1002
|
|
|
} |
1003
|
|
|
$this->setUser($this->aUser); |
1004
|
|
|
} |
1005
|
|
|
|
1006
|
|
View Code Duplication |
if ($this->aChannel !== null) { |
|
|
|
|
1007
|
|
|
if ($this->aChannel->isModified() || $this->aChannel->isNew()) { |
1008
|
|
|
$affectedRows += $this->aChannel->save($con); |
1009
|
|
|
} |
1010
|
|
|
$this->setChannel($this->aChannel); |
1011
|
|
|
} |
1012
|
|
|
|
1013
|
|
View Code Duplication |
if ($this->isNew() || $this->isModified()) { |
|
|
|
|
1014
|
|
|
// persist changes |
1015
|
|
|
if ($this->isNew()) { |
1016
|
|
|
$this->doInsert($con); |
1017
|
|
|
$affectedRows += 1; |
1018
|
|
|
} else { |
1019
|
|
|
$affectedRows += $this->doUpdate($con); |
1020
|
|
|
} |
1021
|
|
|
$this->resetModified(); |
1022
|
|
|
} |
1023
|
|
|
|
1024
|
|
|
$this->alreadyInSave = false; |
1025
|
|
|
|
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
return $affectedRows; |
1029
|
|
|
} // doSave() |
1030
|
|
|
|
1031
|
|
|
/** |
1032
|
|
|
* Insert the row in the database. |
1033
|
|
|
* |
1034
|
|
|
* @param ConnectionInterface $con |
1035
|
|
|
* |
1036
|
|
|
* @throws PropelException |
1037
|
|
|
* @see doSave() |
1038
|
|
|
*/ |
1039
|
|
|
protected function doInsert(ConnectionInterface $con) |
1040
|
|
|
{ |
1041
|
|
|
$modifiedColumns = array(); |
1042
|
|
|
$index = 0; |
1043
|
|
|
|
1044
|
|
|
$this->modifiedColumns[SubscriptionTableMap::COL_ID] = true; |
1045
|
|
|
if (null !== $this->id) { |
1046
|
|
|
throw new PropelException('Cannot insert a value for auto-increment primary key (' . SubscriptionTableMap::COL_ID . ')'); |
1047
|
|
|
} |
1048
|
|
|
|
1049
|
|
|
// check the columns in natural order for more readable SQL queries |
1050
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_ID)) { |
1051
|
|
|
$modifiedColumns[':p' . $index++] = 'id'; |
1052
|
|
|
} |
1053
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_INSTANCE_NAME)) { |
1054
|
|
|
$modifiedColumns[':p' . $index++] = 'instance_name'; |
1055
|
|
|
} |
1056
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_INPUT_UUID)) { |
1057
|
|
|
$modifiedColumns[':p' . $index++] = 'input_uuid'; |
1058
|
|
|
} |
1059
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_USER_ID)) { |
1060
|
|
|
$modifiedColumns[':p' . $index++] = 'user_id'; |
1061
|
|
|
} |
1062
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_CHANNEL_ID)) { |
1063
|
|
|
$modifiedColumns[':p' . $index++] = 'channel_id'; |
1064
|
|
|
} |
1065
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_SUBSCRIPTION_ID)) { |
1066
|
|
|
$modifiedColumns[':p' . $index++] = 'subscription_id'; |
1067
|
|
|
} |
1068
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_STARTED)) { |
1069
|
|
|
$modifiedColumns[':p' . $index++] = 'started'; |
1070
|
|
|
} |
1071
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_STOPPED)) { |
1072
|
|
|
$modifiedColumns[':p' . $index++] = 'stopped'; |
1073
|
|
|
} |
1074
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_TITLE)) { |
1075
|
|
|
$modifiedColumns[':p' . $index++] = 'title'; |
1076
|
|
|
} |
1077
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_SERVICE)) { |
1078
|
|
|
$modifiedColumns[':p' . $index++] = 'service'; |
1079
|
|
|
} |
1080
|
|
|
|
1081
|
|
|
$sql = sprintf( |
1082
|
|
|
'INSERT INTO subscription (%s) VALUES (%s)', |
1083
|
|
|
implode(', ', $modifiedColumns), |
1084
|
|
|
implode(', ', array_keys($modifiedColumns)) |
1085
|
|
|
); |
1086
|
|
|
|
1087
|
|
|
try { |
1088
|
|
|
$stmt = $con->prepare($sql); |
1089
|
|
|
foreach ($modifiedColumns as $identifier => $columnName) { |
1090
|
|
|
switch ($columnName) { |
1091
|
|
|
case 'id': |
1092
|
|
|
$stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
1093
|
|
|
break; |
1094
|
|
|
case 'instance_name': |
1095
|
|
|
$stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
1096
|
|
|
break; |
1097
|
|
|
case 'input_uuid': |
1098
|
|
|
$stmt->bindValue($identifier, $this->input_uuid, PDO::PARAM_STR); |
1099
|
|
|
break; |
1100
|
|
|
case 'user_id': |
1101
|
|
|
$stmt->bindValue($identifier, $this->user_id, PDO::PARAM_INT); |
1102
|
|
|
break; |
1103
|
|
|
case 'channel_id': |
1104
|
|
|
$stmt->bindValue($identifier, $this->channel_id, PDO::PARAM_INT); |
1105
|
|
|
break; |
1106
|
|
|
case 'subscription_id': |
1107
|
|
|
$stmt->bindValue($identifier, $this->subscription_id, PDO::PARAM_INT); |
1108
|
|
|
break; |
1109
|
|
View Code Duplication |
case 'started': |
|
|
|
|
1110
|
|
|
$stmt->bindValue($identifier, $this->started ? $this->started->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
1111
|
|
|
break; |
1112
|
|
|
case 'stopped': |
1113
|
|
|
$stmt->bindValue($identifier, $this->stopped ? $this->stopped->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
1114
|
|
|
break; |
1115
|
|
|
case 'title': |
1116
|
|
|
$stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); |
1117
|
|
|
break; |
1118
|
|
|
case 'service': |
1119
|
|
|
$stmt->bindValue($identifier, $this->service, PDO::PARAM_STR); |
1120
|
|
|
break; |
1121
|
|
|
} |
1122
|
|
|
} |
1123
|
|
|
$stmt->execute(); |
1124
|
|
|
} catch (Exception $e) { |
1125
|
|
|
Propel::log($e->getMessage(), Propel::LOG_ERR); |
1126
|
|
|
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
1127
|
|
|
} |
1128
|
|
|
|
1129
|
|
|
try { |
1130
|
|
|
$pk = $con->lastInsertId(); |
1131
|
|
|
} catch (Exception $e) { |
1132
|
|
|
throw new PropelException('Unable to get autoincrement id.', 0, $e); |
1133
|
|
|
} |
1134
|
|
|
$this->setId($pk); |
1135
|
|
|
|
1136
|
|
|
$this->setNew(false); |
1137
|
|
|
} |
1138
|
|
|
|
1139
|
|
|
/** |
1140
|
|
|
* Update the row in the database. |
1141
|
|
|
* |
1142
|
|
|
* @param ConnectionInterface $con |
1143
|
|
|
* |
1144
|
|
|
* @return Integer Number of updated rows |
1145
|
|
|
* @see doSave() |
1146
|
|
|
*/ |
1147
|
|
|
protected function doUpdate(ConnectionInterface $con) |
1148
|
|
|
{ |
1149
|
|
|
$selectCriteria = $this->buildPkeyCriteria(); |
1150
|
|
|
$valuesCriteria = $this->buildCriteria(); |
1151
|
|
|
|
1152
|
|
|
return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
|
|
|
1153
|
|
|
} |
1154
|
|
|
|
1155
|
|
|
/** |
1156
|
|
|
* Retrieves a field from the object by name passed in as a string. |
1157
|
|
|
* |
1158
|
|
|
* @param string $name name |
1159
|
|
|
* @param string $type The type of fieldname the $name is of: |
1160
|
|
|
* one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
1161
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1162
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
1163
|
|
|
* @return mixed Value of field. |
1164
|
|
|
*/ |
1165
|
|
View Code Duplication |
public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
|
|
|
1166
|
|
|
{ |
1167
|
|
|
$pos = SubscriptionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
1168
|
|
|
$field = $this->getByPosition($pos); |
1169
|
|
|
|
1170
|
|
|
return $field; |
1171
|
|
|
} |
1172
|
|
|
|
1173
|
|
|
/** |
1174
|
|
|
* Retrieves a field from the object by Position as specified in the xml schema. |
1175
|
|
|
* Zero-based. |
1176
|
|
|
* |
1177
|
|
|
* @param int $pos position in xml schema |
1178
|
|
|
* @return mixed Value of field at $pos |
1179
|
|
|
*/ |
1180
|
|
|
public function getByPosition($pos) |
1181
|
|
|
{ |
1182
|
|
|
switch ($pos) { |
1183
|
|
|
case 0: |
1184
|
|
|
return $this->getId(); |
1185
|
|
|
break; |
|
|
|
|
1186
|
|
|
case 1: |
1187
|
|
|
return $this->getInstanceName(); |
1188
|
|
|
break; |
|
|
|
|
1189
|
|
|
case 2: |
1190
|
|
|
return $this->getInputUuid(); |
1191
|
|
|
break; |
|
|
|
|
1192
|
|
|
case 3: |
1193
|
|
|
return $this->getUserId(); |
1194
|
|
|
break; |
|
|
|
|
1195
|
|
|
case 4: |
1196
|
|
|
return $this->getChannelId(); |
1197
|
|
|
break; |
|
|
|
|
1198
|
|
|
case 5: |
1199
|
|
|
return $this->getSubscriptionId(); |
1200
|
|
|
break; |
|
|
|
|
1201
|
|
|
case 6: |
1202
|
|
|
return $this->getStarted(); |
1203
|
|
|
break; |
|
|
|
|
1204
|
|
|
case 7: |
1205
|
|
|
return $this->getStopped(); |
1206
|
|
|
break; |
|
|
|
|
1207
|
|
|
case 8: |
1208
|
|
|
return $this->getTitle(); |
1209
|
|
|
break; |
|
|
|
|
1210
|
|
|
case 9: |
1211
|
|
|
return $this->getService(); |
1212
|
|
|
break; |
|
|
|
|
1213
|
|
|
default: |
1214
|
|
|
return null; |
1215
|
|
|
break; |
|
|
|
|
1216
|
|
|
} // switch() |
1217
|
|
|
} |
1218
|
|
|
|
1219
|
|
|
/** |
1220
|
|
|
* Exports the object as an array. |
1221
|
|
|
* |
1222
|
|
|
* You can specify the key type of the array by passing one of the class |
1223
|
|
|
* type constants. |
1224
|
|
|
* |
1225
|
|
|
* @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
1226
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1227
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
1228
|
|
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
1229
|
|
|
* @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
1230
|
|
|
* @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
1231
|
|
|
* |
1232
|
|
|
* @return array an associative array containing the field names (as keys) and field values |
1233
|
|
|
*/ |
1234
|
|
|
public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
1235
|
|
|
{ |
1236
|
|
|
|
1237
|
|
|
if (isset($alreadyDumpedObjects['Subscription'][$this->hashCode()])) { |
1238
|
|
|
return '*RECURSION*'; |
1239
|
|
|
} |
1240
|
|
|
$alreadyDumpedObjects['Subscription'][$this->hashCode()] = true; |
1241
|
|
|
$keys = SubscriptionTableMap::getFieldNames($keyType); |
1242
|
|
|
$result = array( |
1243
|
|
|
$keys[0] => $this->getId(), |
1244
|
|
|
$keys[1] => $this->getInstanceName(), |
1245
|
|
|
$keys[2] => $this->getInputUuid(), |
1246
|
|
|
$keys[3] => $this->getUserId(), |
1247
|
|
|
$keys[4] => $this->getChannelId(), |
1248
|
|
|
$keys[5] => $this->getSubscriptionId(), |
1249
|
|
|
$keys[6] => $this->getStarted(), |
1250
|
|
|
$keys[7] => $this->getStopped(), |
1251
|
|
|
$keys[8] => $this->getTitle(), |
1252
|
|
|
$keys[9] => $this->getService(), |
1253
|
|
|
); |
1254
|
|
|
if ($result[$keys[6]] instanceof \DateTime) { |
1255
|
|
|
$result[$keys[6]] = $result[$keys[6]]->format('c'); |
1256
|
|
|
} |
1257
|
|
|
|
1258
|
|
|
if ($result[$keys[7]] instanceof \DateTime) { |
1259
|
|
|
$result[$keys[7]] = $result[$keys[7]]->format('c'); |
1260
|
|
|
} |
1261
|
|
|
|
1262
|
|
|
$virtualColumns = $this->virtualColumns; |
1263
|
|
|
foreach ($virtualColumns as $key => $virtualColumn) { |
1264
|
|
|
$result[$key] = $virtualColumn; |
1265
|
|
|
} |
1266
|
|
|
|
1267
|
|
|
if ($includeForeignObjects) { |
1268
|
|
|
if (null !== $this->aInstance) { |
1269
|
|
|
|
1270
|
|
|
switch ($keyType) { |
1271
|
|
|
case TableMap::TYPE_CAMELNAME: |
1272
|
|
|
$key = 'instance'; |
1273
|
|
|
break; |
1274
|
|
|
case TableMap::TYPE_FIELDNAME: |
1275
|
|
|
$key = 'instance'; |
1276
|
|
|
break; |
1277
|
|
|
default: |
1278
|
|
|
$key = 'Instance'; |
1279
|
|
|
} |
1280
|
|
|
|
1281
|
|
|
$result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
1282
|
|
|
} |
1283
|
|
|
if (null !== $this->aInput) { |
1284
|
|
|
|
1285
|
|
|
switch ($keyType) { |
1286
|
|
|
case TableMap::TYPE_CAMELNAME: |
1287
|
|
|
$key = 'input'; |
1288
|
|
|
break; |
1289
|
|
|
case TableMap::TYPE_FIELDNAME: |
1290
|
|
|
$key = 'input'; |
1291
|
|
|
break; |
1292
|
|
|
default: |
1293
|
|
|
$key = 'Input'; |
1294
|
|
|
} |
1295
|
|
|
|
1296
|
|
|
$result[$key] = $this->aInput->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
1297
|
|
|
} |
1298
|
|
|
if (null !== $this->aUser) { |
1299
|
|
|
|
1300
|
|
|
switch ($keyType) { |
1301
|
|
|
case TableMap::TYPE_CAMELNAME: |
1302
|
|
|
$key = 'user'; |
1303
|
|
|
break; |
1304
|
|
|
case TableMap::TYPE_FIELDNAME: |
1305
|
|
|
$key = 'user'; |
1306
|
|
|
break; |
1307
|
|
|
default: |
1308
|
|
|
$key = 'User'; |
1309
|
|
|
} |
1310
|
|
|
|
1311
|
|
|
$result[$key] = $this->aUser->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
1312
|
|
|
} |
1313
|
|
|
if (null !== $this->aChannel) { |
1314
|
|
|
|
1315
|
|
|
switch ($keyType) { |
1316
|
|
|
case TableMap::TYPE_CAMELNAME: |
1317
|
|
|
$key = 'channel'; |
1318
|
|
|
break; |
1319
|
|
|
case TableMap::TYPE_FIELDNAME: |
1320
|
|
|
$key = 'channel'; |
1321
|
|
|
break; |
1322
|
|
|
default: |
1323
|
|
|
$key = 'Channel'; |
1324
|
|
|
} |
1325
|
|
|
|
1326
|
|
|
$result[$key] = $this->aChannel->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
1327
|
|
|
} |
1328
|
|
|
} |
1329
|
|
|
|
1330
|
|
|
return $result; |
1331
|
|
|
} |
1332
|
|
|
|
1333
|
|
|
/** |
1334
|
|
|
* Sets a field from the object by name passed in as a string. |
1335
|
|
|
* |
1336
|
|
|
* @param string $name |
1337
|
|
|
* @param mixed $value field value |
1338
|
|
|
* @param string $type The type of fieldname the $name is of: |
1339
|
|
|
* one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
1340
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1341
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
1342
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription |
1343
|
|
|
*/ |
1344
|
|
|
public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
1345
|
|
|
{ |
1346
|
|
|
$pos = SubscriptionTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
1347
|
|
|
|
1348
|
|
|
return $this->setByPosition($pos, $value); |
1349
|
|
|
} |
1350
|
|
|
|
1351
|
|
|
/** |
1352
|
|
|
* Sets a field from the object by Position as specified in the xml schema. |
1353
|
|
|
* Zero-based. |
1354
|
|
|
* |
1355
|
|
|
* @param int $pos position in xml schema |
1356
|
|
|
* @param mixed $value field value |
1357
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription |
1358
|
|
|
*/ |
1359
|
|
|
public function setByPosition($pos, $value) |
1360
|
|
|
{ |
1361
|
|
|
switch ($pos) { |
1362
|
|
|
case 0: |
1363
|
|
|
$this->setId($value); |
1364
|
|
|
break; |
1365
|
|
|
case 1: |
1366
|
|
|
$this->setInstanceName($value); |
1367
|
|
|
break; |
1368
|
|
|
case 2: |
1369
|
|
|
$this->setInputUuid($value); |
1370
|
|
|
break; |
1371
|
|
|
case 3: |
1372
|
|
|
$this->setUserId($value); |
1373
|
|
|
break; |
1374
|
|
|
case 4: |
1375
|
|
|
$this->setChannelId($value); |
1376
|
|
|
break; |
1377
|
|
|
case 5: |
1378
|
|
|
$this->setSubscriptionId($value); |
1379
|
|
|
break; |
1380
|
|
|
case 6: |
1381
|
|
|
$this->setStarted($value); |
1382
|
|
|
break; |
1383
|
|
|
case 7: |
1384
|
|
|
$this->setStopped($value); |
1385
|
|
|
break; |
1386
|
|
|
case 8: |
1387
|
|
|
$this->setTitle($value); |
1388
|
|
|
break; |
1389
|
|
|
case 9: |
1390
|
|
|
$this->setService($value); |
1391
|
|
|
break; |
1392
|
|
|
} // switch() |
1393
|
|
|
|
1394
|
|
|
return $this; |
1395
|
|
|
} |
1396
|
|
|
|
1397
|
|
|
/** |
1398
|
|
|
* Populates the object using an array. |
1399
|
|
|
* |
1400
|
|
|
* This is particularly useful when populating an object from one of the |
1401
|
|
|
* request arrays (e.g. $_POST). This method goes through the column |
1402
|
|
|
* names, checking to see whether a matching key exists in populated |
1403
|
|
|
* array. If so the setByName() method is called for that column. |
1404
|
|
|
* |
1405
|
|
|
* You can specify the key type of the array by additionally passing one |
1406
|
|
|
* of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
1407
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1408
|
|
|
* The default key type is the column's TableMap::TYPE_PHPNAME. |
1409
|
|
|
* |
1410
|
|
|
* @param array $arr An array to populate the object from. |
1411
|
|
|
* @param string $keyType The type of keys the array uses. |
1412
|
|
|
* @return void |
1413
|
|
|
*/ |
1414
|
|
|
public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
1415
|
|
|
{ |
1416
|
|
|
$keys = SubscriptionTableMap::getFieldNames($keyType); |
1417
|
|
|
|
1418
|
|
|
if (array_key_exists($keys[0], $arr)) { |
1419
|
|
|
$this->setId($arr[$keys[0]]); |
1420
|
|
|
} |
1421
|
|
|
if (array_key_exists($keys[1], $arr)) { |
1422
|
|
|
$this->setInstanceName($arr[$keys[1]]); |
1423
|
|
|
} |
1424
|
|
|
if (array_key_exists($keys[2], $arr)) { |
1425
|
|
|
$this->setInputUuid($arr[$keys[2]]); |
1426
|
|
|
} |
1427
|
|
|
if (array_key_exists($keys[3], $arr)) { |
1428
|
|
|
$this->setUserId($arr[$keys[3]]); |
1429
|
|
|
} |
1430
|
|
|
if (array_key_exists($keys[4], $arr)) { |
1431
|
|
|
$this->setChannelId($arr[$keys[4]]); |
1432
|
|
|
} |
1433
|
|
|
if (array_key_exists($keys[5], $arr)) { |
1434
|
|
|
$this->setSubscriptionId($arr[$keys[5]]); |
1435
|
|
|
} |
1436
|
|
|
if (array_key_exists($keys[6], $arr)) { |
1437
|
|
|
$this->setStarted($arr[$keys[6]]); |
1438
|
|
|
} |
1439
|
|
|
if (array_key_exists($keys[7], $arr)) { |
1440
|
|
|
$this->setStopped($arr[$keys[7]]); |
1441
|
|
|
} |
1442
|
|
|
if (array_key_exists($keys[8], $arr)) { |
1443
|
|
|
$this->setTitle($arr[$keys[8]]); |
1444
|
|
|
} |
1445
|
|
|
if (array_key_exists($keys[9], $arr)) { |
1446
|
|
|
$this->setService($arr[$keys[9]]); |
1447
|
|
|
} |
1448
|
|
|
} |
1449
|
|
|
|
1450
|
|
|
/** |
1451
|
|
|
* Populate the current object from a string, using a given parser format |
1452
|
|
|
* <code> |
1453
|
|
|
* $book = new Book(); |
1454
|
|
|
* $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
1455
|
|
|
* </code> |
1456
|
|
|
* |
1457
|
|
|
* You can specify the key type of the array by additionally passing one |
1458
|
|
|
* of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
1459
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
1460
|
|
|
* The default key type is the column's TableMap::TYPE_PHPNAME. |
1461
|
|
|
* |
1462
|
|
|
* @param mixed $parser A AbstractParser instance, |
1463
|
|
|
* or a format name ('XML', 'YAML', 'JSON', 'CSV') |
1464
|
|
|
* @param string $data The source data to import from |
1465
|
|
|
* @param string $keyType The type of keys the array uses. |
1466
|
|
|
* |
1467
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object, for fluid interface |
1468
|
|
|
*/ |
1469
|
|
View Code Duplication |
public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
|
|
|
1470
|
|
|
{ |
1471
|
|
|
if (!$parser instanceof AbstractParser) { |
1472
|
|
|
$parser = AbstractParser::getParser($parser); |
1473
|
|
|
} |
1474
|
|
|
|
1475
|
|
|
$this->fromArray($parser->toArray($data), $keyType); |
1476
|
|
|
|
1477
|
|
|
return $this; |
1478
|
|
|
} |
1479
|
|
|
|
1480
|
|
|
/** |
1481
|
|
|
* Build a Criteria object containing the values of all modified columns in this object. |
1482
|
|
|
* |
1483
|
|
|
* @return Criteria The Criteria object containing all modified values. |
1484
|
|
|
*/ |
1485
|
|
|
public function buildCriteria() |
1486
|
|
|
{ |
1487
|
|
|
$criteria = new Criteria(SubscriptionTableMap::DATABASE_NAME); |
1488
|
|
|
|
1489
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_ID)) { |
1490
|
|
|
$criteria->add(SubscriptionTableMap::COL_ID, $this->id); |
1491
|
|
|
} |
1492
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_INSTANCE_NAME)) { |
1493
|
|
|
$criteria->add(SubscriptionTableMap::COL_INSTANCE_NAME, $this->instance_name); |
1494
|
|
|
} |
1495
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_INPUT_UUID)) { |
1496
|
|
|
$criteria->add(SubscriptionTableMap::COL_INPUT_UUID, $this->input_uuid); |
1497
|
|
|
} |
1498
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_USER_ID)) { |
1499
|
|
|
$criteria->add(SubscriptionTableMap::COL_USER_ID, $this->user_id); |
1500
|
|
|
} |
1501
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_CHANNEL_ID)) { |
1502
|
|
|
$criteria->add(SubscriptionTableMap::COL_CHANNEL_ID, $this->channel_id); |
1503
|
|
|
} |
1504
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_SUBSCRIPTION_ID)) { |
1505
|
|
|
$criteria->add(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $this->subscription_id); |
1506
|
|
|
} |
1507
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_STARTED)) { |
1508
|
|
|
$criteria->add(SubscriptionTableMap::COL_STARTED, $this->started); |
1509
|
|
|
} |
1510
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_STOPPED)) { |
1511
|
|
|
$criteria->add(SubscriptionTableMap::COL_STOPPED, $this->stopped); |
1512
|
|
|
} |
1513
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_TITLE)) { |
1514
|
|
|
$criteria->add(SubscriptionTableMap::COL_TITLE, $this->title); |
1515
|
|
|
} |
1516
|
|
|
if ($this->isColumnModified(SubscriptionTableMap::COL_SERVICE)) { |
1517
|
|
|
$criteria->add(SubscriptionTableMap::COL_SERVICE, $this->service); |
1518
|
|
|
} |
1519
|
|
|
|
1520
|
|
|
return $criteria; |
1521
|
|
|
} |
1522
|
|
|
|
1523
|
|
|
/** |
1524
|
|
|
* Builds a Criteria object containing the primary key for this object. |
1525
|
|
|
* |
1526
|
|
|
* Unlike buildCriteria() this method includes the primary key values regardless |
1527
|
|
|
* of whether or not they have been modified. |
1528
|
|
|
* |
1529
|
|
|
* @throws LogicException if no primary key is defined |
1530
|
|
|
* |
1531
|
|
|
* @return Criteria The Criteria object containing value(s) for primary key(s). |
1532
|
|
|
*/ |
1533
|
|
|
public function buildPkeyCriteria() |
1534
|
|
|
{ |
1535
|
|
|
$criteria = ChildSubscriptionQuery::create(); |
1536
|
|
|
$criteria->add(SubscriptionTableMap::COL_ID, $this->id); |
1537
|
|
|
|
1538
|
|
|
return $criteria; |
1539
|
|
|
} |
1540
|
|
|
|
1541
|
|
|
/** |
1542
|
|
|
* If the primary key is not null, return the hashcode of the |
1543
|
|
|
* primary key. Otherwise, return the hash code of the object. |
1544
|
|
|
* |
1545
|
|
|
* @return int Hashcode |
1546
|
|
|
*/ |
1547
|
|
View Code Duplication |
public function hashCode() |
|
|
|
|
1548
|
|
|
{ |
1549
|
|
|
$validPk = null !== $this->getId(); |
1550
|
|
|
|
1551
|
|
|
$validPrimaryKeyFKs = 0; |
1552
|
|
|
$primaryKeyFKs = []; |
1553
|
|
|
|
1554
|
|
|
if ($validPk) { |
1555
|
|
|
return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
1556
|
|
|
} elseif ($validPrimaryKeyFKs) { |
1557
|
|
|
return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
1558
|
|
|
} |
1559
|
|
|
|
1560
|
|
|
return spl_object_hash($this); |
1561
|
|
|
} |
1562
|
|
|
|
1563
|
|
|
/** |
1564
|
|
|
* Returns the primary key for this object (row). |
1565
|
|
|
* @return int |
1566
|
|
|
*/ |
1567
|
|
|
public function getPrimaryKey() |
1568
|
|
|
{ |
1569
|
|
|
return $this->getId(); |
1570
|
|
|
} |
1571
|
|
|
|
1572
|
|
|
/** |
1573
|
|
|
* Generic method to set the primary key (id column). |
1574
|
|
|
* |
1575
|
|
|
* @param int $key Primary key. |
1576
|
|
|
* @return void |
1577
|
|
|
*/ |
1578
|
|
|
public function setPrimaryKey($key) |
1579
|
|
|
{ |
1580
|
|
|
$this->setId($key); |
1581
|
|
|
} |
1582
|
|
|
|
1583
|
|
|
/** |
1584
|
|
|
* Returns true if the primary key for this object is null. |
1585
|
|
|
* @return boolean |
1586
|
|
|
*/ |
1587
|
|
|
public function isPrimaryKeyNull() |
1588
|
|
|
{ |
1589
|
|
|
return null === $this->getId(); |
1590
|
|
|
} |
1591
|
|
|
|
1592
|
|
|
/** |
1593
|
|
|
* Sets contents of passed object to values from current object. |
1594
|
|
|
* |
1595
|
|
|
* If desired, this method can also make copies of all associated (fkey referrers) |
1596
|
|
|
* objects. |
1597
|
|
|
* |
1598
|
|
|
* @param object $copyObj An object of \Jalle19\StatusManager\Database\Subscription (or compatible) type. |
1599
|
|
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
1600
|
|
|
* @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
1601
|
|
|
* @throws PropelException |
1602
|
|
|
*/ |
1603
|
|
|
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
|
|
|
1604
|
|
|
{ |
1605
|
|
|
$copyObj->setInstanceName($this->getInstanceName()); |
1606
|
|
|
$copyObj->setInputUuid($this->getInputUuid()); |
1607
|
|
|
$copyObj->setUserId($this->getUserId()); |
1608
|
|
|
$copyObj->setChannelId($this->getChannelId()); |
1609
|
|
|
$copyObj->setSubscriptionId($this->getSubscriptionId()); |
1610
|
|
|
$copyObj->setStarted($this->getStarted()); |
1611
|
|
|
$copyObj->setStopped($this->getStopped()); |
1612
|
|
|
$copyObj->setTitle($this->getTitle()); |
1613
|
|
|
$copyObj->setService($this->getService()); |
1614
|
|
|
if ($makeNew) { |
1615
|
|
|
$copyObj->setNew(true); |
1616
|
|
|
$copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
1617
|
|
|
} |
1618
|
|
|
} |
1619
|
|
|
|
1620
|
|
|
/** |
1621
|
|
|
* Makes a copy of this object that will be inserted as a new row in table when saved. |
1622
|
|
|
* It creates a new object filling in the simple attributes, but skipping any primary |
1623
|
|
|
* keys that are defined for the table. |
1624
|
|
|
* |
1625
|
|
|
* If desired, this method can also make copies of all associated (fkey referrers) |
1626
|
|
|
* objects. |
1627
|
|
|
* |
1628
|
|
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
1629
|
|
|
* @return \Jalle19\StatusManager\Database\Subscription Clone of current object. |
1630
|
|
|
* @throws PropelException |
1631
|
|
|
*/ |
1632
|
|
View Code Duplication |
public function copy($deepCopy = false) |
|
|
|
|
1633
|
|
|
{ |
1634
|
|
|
// we use get_class(), because this might be a subclass |
1635
|
|
|
$clazz = get_class($this); |
1636
|
|
|
$copyObj = new $clazz(); |
1637
|
|
|
$this->copyInto($copyObj, $deepCopy); |
1638
|
|
|
|
1639
|
|
|
return $copyObj; |
1640
|
|
|
} |
1641
|
|
|
|
1642
|
|
|
/** |
1643
|
|
|
* Declares an association between this object and a ChildInstance object. |
1644
|
|
|
* |
1645
|
|
|
* @param ChildInstance $v |
1646
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
1647
|
|
|
* @throws PropelException |
1648
|
|
|
*/ |
1649
|
|
View Code Duplication |
public function setInstance(ChildInstance $v = null) |
|
|
|
|
1650
|
|
|
{ |
1651
|
|
|
if ($v === null) { |
1652
|
|
|
$this->setInstanceName(NULL); |
1653
|
|
|
} else { |
1654
|
|
|
$this->setInstanceName($v->getName()); |
1655
|
|
|
} |
1656
|
|
|
|
1657
|
|
|
$this->aInstance = $v; |
1658
|
|
|
|
1659
|
|
|
// Add binding for other direction of this n:n relationship. |
1660
|
|
|
// If this object has already been added to the ChildInstance object, it will not be re-added. |
1661
|
|
|
if ($v !== null) { |
1662
|
|
|
$v->addSubscription($this); |
|
|
|
|
1663
|
|
|
} |
1664
|
|
|
|
1665
|
|
|
|
1666
|
|
|
return $this; |
1667
|
|
|
} |
1668
|
|
|
|
1669
|
|
|
|
1670
|
|
|
/** |
1671
|
|
|
* Get the associated ChildInstance object |
1672
|
|
|
* |
1673
|
|
|
* @param ConnectionInterface $con Optional Connection object. |
1674
|
|
|
* @return ChildInstance The associated ChildInstance object. |
1675
|
|
|
* @throws PropelException |
1676
|
|
|
*/ |
1677
|
|
View Code Duplication |
public function getInstance(ConnectionInterface $con = null) |
|
|
|
|
1678
|
|
|
{ |
1679
|
|
|
if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
1680
|
|
|
$this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
1681
|
|
|
/* The following can be used additionally to |
1682
|
|
|
guarantee the related object contains a reference |
1683
|
|
|
to this object. This level of coupling may, however, be |
1684
|
|
|
undesirable since it could result in an only partially populated collection |
1685
|
|
|
in the referenced object. |
1686
|
|
|
$this->aInstance->addSubscriptions($this); |
1687
|
|
|
*/ |
1688
|
|
|
} |
1689
|
|
|
|
1690
|
|
|
return $this->aInstance; |
1691
|
|
|
} |
1692
|
|
|
|
1693
|
|
|
/** |
1694
|
|
|
* Declares an association between this object and a ChildInput object. |
1695
|
|
|
* |
1696
|
|
|
* @param ChildInput $v |
1697
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
1698
|
|
|
* @throws PropelException |
1699
|
|
|
*/ |
1700
|
|
|
public function setInput(ChildInput $v = null) |
1701
|
|
|
{ |
1702
|
|
|
if ($v === null) { |
1703
|
|
|
$this->setInputUuid(NULL); |
1704
|
|
|
} else { |
1705
|
|
|
$this->setInputUuid($v->getUuid()); |
1706
|
|
|
} |
1707
|
|
|
|
1708
|
|
|
$this->aInput = $v; |
1709
|
|
|
|
1710
|
|
|
// Add binding for other direction of this n:n relationship. |
1711
|
|
|
// If this object has already been added to the ChildInput object, it will not be re-added. |
1712
|
|
|
if ($v !== null) { |
1713
|
|
|
$v->addSubscription($this); |
|
|
|
|
1714
|
|
|
} |
1715
|
|
|
|
1716
|
|
|
|
1717
|
|
|
return $this; |
1718
|
|
|
} |
1719
|
|
|
|
1720
|
|
|
|
1721
|
|
|
/** |
1722
|
|
|
* Get the associated ChildInput object |
1723
|
|
|
* |
1724
|
|
|
* @param ConnectionInterface $con Optional Connection object. |
1725
|
|
|
* @return ChildInput The associated ChildInput object. |
1726
|
|
|
* @throws PropelException |
1727
|
|
|
*/ |
1728
|
|
|
public function getInput(ConnectionInterface $con = null) |
1729
|
|
|
{ |
1730
|
|
|
if ($this->aInput === null && (($this->input_uuid !== "" && $this->input_uuid !== null))) { |
1731
|
|
|
$this->aInput = ChildInputQuery::create()->findPk($this->input_uuid, $con); |
1732
|
|
|
/* The following can be used additionally to |
1733
|
|
|
guarantee the related object contains a reference |
1734
|
|
|
to this object. This level of coupling may, however, be |
1735
|
|
|
undesirable since it could result in an only partially populated collection |
1736
|
|
|
in the referenced object. |
1737
|
|
|
$this->aInput->addSubscriptions($this); |
1738
|
|
|
*/ |
1739
|
|
|
} |
1740
|
|
|
|
1741
|
|
|
return $this->aInput; |
1742
|
|
|
} |
1743
|
|
|
|
1744
|
|
|
/** |
1745
|
|
|
* Declares an association between this object and a ChildUser object. |
1746
|
|
|
* |
1747
|
|
|
* @param ChildUser $v |
1748
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
1749
|
|
|
* @throws PropelException |
1750
|
|
|
*/ |
1751
|
|
View Code Duplication |
public function setUser(ChildUser $v = null) |
|
|
|
|
1752
|
|
|
{ |
1753
|
|
|
if ($v === null) { |
1754
|
|
|
$this->setUserId(NULL); |
1755
|
|
|
} else { |
1756
|
|
|
$this->setUserId($v->getId()); |
1757
|
|
|
} |
1758
|
|
|
|
1759
|
|
|
$this->aUser = $v; |
1760
|
|
|
|
1761
|
|
|
// Add binding for other direction of this n:n relationship. |
1762
|
|
|
// If this object has already been added to the ChildUser object, it will not be re-added. |
1763
|
|
|
if ($v !== null) { |
1764
|
|
|
$v->addSubscription($this); |
|
|
|
|
1765
|
|
|
} |
1766
|
|
|
|
1767
|
|
|
|
1768
|
|
|
return $this; |
1769
|
|
|
} |
1770
|
|
|
|
1771
|
|
|
|
1772
|
|
|
/** |
1773
|
|
|
* Get the associated ChildUser object |
1774
|
|
|
* |
1775
|
|
|
* @param ConnectionInterface $con Optional Connection object. |
1776
|
|
|
* @return ChildUser The associated ChildUser object. |
1777
|
|
|
* @throws PropelException |
1778
|
|
|
*/ |
1779
|
|
View Code Duplication |
public function getUser(ConnectionInterface $con = null) |
|
|
|
|
1780
|
|
|
{ |
1781
|
|
|
if ($this->aUser === null && ($this->user_id !== null)) { |
1782
|
|
|
$this->aUser = ChildUserQuery::create()->findPk($this->user_id, $con); |
1783
|
|
|
/* The following can be used additionally to |
1784
|
|
|
guarantee the related object contains a reference |
1785
|
|
|
to this object. This level of coupling may, however, be |
1786
|
|
|
undesirable since it could result in an only partially populated collection |
1787
|
|
|
in the referenced object. |
1788
|
|
|
$this->aUser->addSubscriptions($this); |
1789
|
|
|
*/ |
1790
|
|
|
} |
1791
|
|
|
|
1792
|
|
|
return $this->aUser; |
1793
|
|
|
} |
1794
|
|
|
|
1795
|
|
|
/** |
1796
|
|
|
* Declares an association between this object and a ChildChannel object. |
1797
|
|
|
* |
1798
|
|
|
* @param ChildChannel $v |
1799
|
|
|
* @return $this|\Jalle19\StatusManager\Database\Subscription The current object (for fluent API support) |
1800
|
|
|
* @throws PropelException |
1801
|
|
|
*/ |
1802
|
|
View Code Duplication |
public function setChannel(ChildChannel $v = null) |
|
|
|
|
1803
|
|
|
{ |
1804
|
|
|
if ($v === null) { |
1805
|
|
|
$this->setChannelId(NULL); |
1806
|
|
|
} else { |
1807
|
|
|
$this->setChannelId($v->getId()); |
1808
|
|
|
} |
1809
|
|
|
|
1810
|
|
|
$this->aChannel = $v; |
1811
|
|
|
|
1812
|
|
|
// Add binding for other direction of this n:n relationship. |
1813
|
|
|
// If this object has already been added to the ChildChannel object, it will not be re-added. |
1814
|
|
|
if ($v !== null) { |
1815
|
|
|
$v->addSubscription($this); |
|
|
|
|
1816
|
|
|
} |
1817
|
|
|
|
1818
|
|
|
|
1819
|
|
|
return $this; |
1820
|
|
|
} |
1821
|
|
|
|
1822
|
|
|
|
1823
|
|
|
/** |
1824
|
|
|
* Get the associated ChildChannel object |
1825
|
|
|
* |
1826
|
|
|
* @param ConnectionInterface $con Optional Connection object. |
1827
|
|
|
* @return ChildChannel The associated ChildChannel object. |
1828
|
|
|
* @throws PropelException |
1829
|
|
|
*/ |
1830
|
|
|
public function getChannel(ConnectionInterface $con = null) |
1831
|
|
|
{ |
1832
|
|
|
if ($this->aChannel === null && ($this->channel_id !== null)) { |
1833
|
|
|
$this->aChannel = ChildChannelQuery::create()->findPk($this->channel_id, $con); |
1834
|
|
|
/* The following can be used additionally to |
1835
|
|
|
guarantee the related object contains a reference |
1836
|
|
|
to this object. This level of coupling may, however, be |
1837
|
|
|
undesirable since it could result in an only partially populated collection |
1838
|
|
|
in the referenced object. |
1839
|
|
|
$this->aChannel->addSubscriptions($this); |
1840
|
|
|
*/ |
1841
|
|
|
} |
1842
|
|
|
|
1843
|
|
|
return $this->aChannel; |
1844
|
|
|
} |
1845
|
|
|
|
1846
|
|
|
/** |
1847
|
|
|
* Clears the current object, sets all attributes to their default values and removes |
1848
|
|
|
* outgoing references as well as back-references (from other objects to this one. Results probably in a database |
1849
|
|
|
* change of those foreign objects when you call `save` there). |
1850
|
|
|
*/ |
1851
|
|
|
public function clear() |
1852
|
|
|
{ |
1853
|
|
|
if (null !== $this->aInstance) { |
1854
|
|
|
$this->aInstance->removeSubscription($this); |
|
|
|
|
1855
|
|
|
} |
1856
|
|
|
if (null !== $this->aInput) { |
1857
|
|
|
$this->aInput->removeSubscription($this); |
|
|
|
|
1858
|
|
|
} |
1859
|
|
|
if (null !== $this->aUser) { |
1860
|
|
|
$this->aUser->removeSubscription($this); |
|
|
|
|
1861
|
|
|
} |
1862
|
|
|
if (null !== $this->aChannel) { |
1863
|
|
|
$this->aChannel->removeSubscription($this); |
|
|
|
|
1864
|
|
|
} |
1865
|
|
|
$this->id = null; |
1866
|
|
|
$this->instance_name = null; |
1867
|
|
|
$this->input_uuid = null; |
1868
|
|
|
$this->user_id = null; |
1869
|
|
|
$this->channel_id = null; |
1870
|
|
|
$this->subscription_id = null; |
1871
|
|
|
$this->started = null; |
1872
|
|
|
$this->stopped = null; |
1873
|
|
|
$this->title = null; |
1874
|
|
|
$this->service = null; |
1875
|
|
|
$this->alreadyInSave = false; |
1876
|
|
|
$this->clearAllReferences(); |
1877
|
|
|
$this->resetModified(); |
1878
|
|
|
$this->setNew(true); |
1879
|
|
|
$this->setDeleted(false); |
1880
|
|
|
} |
1881
|
|
|
|
1882
|
|
|
/** |
1883
|
|
|
* Resets all references and back-references to other model objects or collections of model objects. |
1884
|
|
|
* |
1885
|
|
|
* This method is used to reset all php object references (not the actual reference in the database). |
1886
|
|
|
* Necessary for object serialisation. |
1887
|
|
|
* |
1888
|
|
|
* @param boolean $deep Whether to also clear the references on all referrer objects. |
1889
|
|
|
*/ |
1890
|
|
|
public function clearAllReferences($deep = false) |
1891
|
|
|
{ |
1892
|
|
|
if ($deep) { |
|
|
|
|
1893
|
|
|
} // if ($deep) |
|
|
|
|
1894
|
|
|
|
1895
|
|
|
$this->aInstance = null; |
1896
|
|
|
$this->aInput = null; |
1897
|
|
|
$this->aUser = null; |
1898
|
|
|
$this->aChannel = null; |
1899
|
|
|
} |
1900
|
|
|
|
1901
|
|
|
/** |
1902
|
|
|
* Return the string representation of this object |
1903
|
|
|
* |
1904
|
|
|
* @return string |
1905
|
|
|
*/ |
1906
|
|
|
public function __toString() |
1907
|
|
|
{ |
1908
|
|
|
return (string) $this->exportTo(SubscriptionTableMap::DEFAULT_STRING_FORMAT); |
1909
|
|
|
} |
1910
|
|
|
|
1911
|
|
|
/** |
1912
|
|
|
* Code to be run before persisting the object |
1913
|
|
|
* @param ConnectionInterface $con |
1914
|
|
|
* @return boolean |
1915
|
|
|
*/ |
1916
|
|
|
public function preSave(ConnectionInterface $con = null) |
|
|
|
|
1917
|
|
|
{ |
1918
|
|
|
return true; |
1919
|
|
|
} |
1920
|
|
|
|
1921
|
|
|
/** |
1922
|
|
|
* Code to be run after persisting the object |
1923
|
|
|
* @param ConnectionInterface $con |
1924
|
|
|
*/ |
1925
|
|
|
public function postSave(ConnectionInterface $con = null) |
|
|
|
|
1926
|
|
|
{ |
1927
|
|
|
|
1928
|
|
|
} |
1929
|
|
|
|
1930
|
|
|
/** |
1931
|
|
|
* Code to be run before inserting to database |
1932
|
|
|
* @param ConnectionInterface $con |
1933
|
|
|
* @return boolean |
1934
|
|
|
*/ |
1935
|
|
|
public function preInsert(ConnectionInterface $con = null) |
|
|
|
|
1936
|
|
|
{ |
1937
|
|
|
return true; |
1938
|
|
|
} |
1939
|
|
|
|
1940
|
|
|
/** |
1941
|
|
|
* Code to be run after inserting to database |
1942
|
|
|
* @param ConnectionInterface $con |
1943
|
|
|
*/ |
1944
|
|
|
public function postInsert(ConnectionInterface $con = null) |
|
|
|
|
1945
|
|
|
{ |
1946
|
|
|
|
1947
|
|
|
} |
1948
|
|
|
|
1949
|
|
|
/** |
1950
|
|
|
* Code to be run before updating the object in database |
1951
|
|
|
* @param ConnectionInterface $con |
1952
|
|
|
* @return boolean |
1953
|
|
|
*/ |
1954
|
|
|
public function preUpdate(ConnectionInterface $con = null) |
|
|
|
|
1955
|
|
|
{ |
1956
|
|
|
return true; |
1957
|
|
|
} |
1958
|
|
|
|
1959
|
|
|
/** |
1960
|
|
|
* Code to be run after updating the object in database |
1961
|
|
|
* @param ConnectionInterface $con |
1962
|
|
|
*/ |
1963
|
|
|
public function postUpdate(ConnectionInterface $con = null) |
|
|
|
|
1964
|
|
|
{ |
1965
|
|
|
|
1966
|
|
|
} |
1967
|
|
|
|
1968
|
|
|
/** |
1969
|
|
|
* Code to be run before deleting the object in database |
1970
|
|
|
* @param ConnectionInterface $con |
1971
|
|
|
* @return boolean |
1972
|
|
|
*/ |
1973
|
|
|
public function preDelete(ConnectionInterface $con = null) |
|
|
|
|
1974
|
|
|
{ |
1975
|
|
|
return true; |
1976
|
|
|
} |
1977
|
|
|
|
1978
|
|
|
/** |
1979
|
|
|
* Code to be run after deleting the object in database |
1980
|
|
|
* @param ConnectionInterface $con |
1981
|
|
|
*/ |
1982
|
|
|
public function postDelete(ConnectionInterface $con = null) |
|
|
|
|
1983
|
|
|
{ |
1984
|
|
|
|
1985
|
|
|
} |
1986
|
|
|
|
1987
|
|
|
|
1988
|
|
|
/** |
1989
|
|
|
* Derived method to catches calls to undefined methods. |
1990
|
|
|
* |
1991
|
|
|
* Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
1992
|
|
|
* Allows to define default __call() behavior if you overwrite __call() |
1993
|
|
|
* |
1994
|
|
|
* @param string $name |
1995
|
|
|
* @param mixed $params |
1996
|
|
|
* |
1997
|
|
|
* @return array|string |
1998
|
|
|
*/ |
1999
|
|
View Code Duplication |
public function __call($name, $params) |
|
|
|
|
2000
|
|
|
{ |
2001
|
|
|
if (0 === strpos($name, 'get')) { |
2002
|
|
|
$virtualColumn = substr($name, 3); |
2003
|
|
|
if ($this->hasVirtualColumn($virtualColumn)) { |
2004
|
|
|
return $this->getVirtualColumn($virtualColumn); |
2005
|
|
|
} |
2006
|
|
|
|
2007
|
|
|
$virtualColumn = lcfirst($virtualColumn); |
2008
|
|
|
if ($this->hasVirtualColumn($virtualColumn)) { |
2009
|
|
|
return $this->getVirtualColumn($virtualColumn); |
2010
|
|
|
} |
2011
|
|
|
} |
2012
|
|
|
|
2013
|
|
|
if (0 === strpos($name, 'from')) { |
2014
|
|
|
$format = substr($name, 4); |
2015
|
|
|
|
2016
|
|
|
return $this->importFrom($format, reset($params)); |
|
|
|
|
2017
|
|
|
} |
2018
|
|
|
|
2019
|
|
|
if (0 === strpos($name, 'to')) { |
2020
|
|
|
$format = substr($name, 2); |
2021
|
|
|
$includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
2022
|
|
|
|
2023
|
|
|
return $this->exportTo($format, $includeLazyLoadColumns); |
2024
|
|
|
} |
2025
|
|
|
|
2026
|
|
|
throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
2027
|
|
|
} |
2028
|
|
|
|
2029
|
|
|
} |
2030
|
|
|
|
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.