1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace mod_link\models\Base; |
4
|
|
|
|
5
|
|
|
use \Exception; |
6
|
|
|
use \PDO; |
7
|
|
|
use Base\PropelBaseModelClass; |
8
|
|
|
use Propel\Runtime\Propel; |
9
|
|
|
use Propel\Runtime\ActiveQuery\Criteria; |
10
|
|
|
use Propel\Runtime\ActiveQuery\ModelCriteria; |
11
|
|
|
use Propel\Runtime\ActiveRecord\ActiveRecordInterface; |
12
|
|
|
use Propel\Runtime\Collection\Collection; |
13
|
|
|
use Propel\Runtime\Connection\ConnectionInterface; |
14
|
|
|
use Propel\Runtime\Exception\BadMethodCallException; |
15
|
|
|
use Propel\Runtime\Exception\LogicException; |
16
|
|
|
use Propel\Runtime\Exception\PropelException; |
17
|
|
|
use Propel\Runtime\Map\TableMap; |
18
|
|
|
use Propel\Runtime\Parser\AbstractParser; |
19
|
|
|
use mod_link\models\PageLink as ChildPageLink; |
20
|
|
|
use mod_link\models\PageLinkProductsQuery as ChildPageLinkProductsQuery; |
21
|
|
|
use mod_link\models\PageLinkQuery as ChildPageLinkQuery; |
22
|
|
|
use mod_link\models\Map\PageLinkProductsTableMap; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Base class that represents a row from the 'page_link_products' table. |
26
|
|
|
* |
27
|
|
|
* |
28
|
|
|
* |
29
|
|
|
* @package propel.generator.mod_link.models.Base |
|
|
|
|
30
|
|
|
*/ |
|
|
|
|
31
|
|
|
abstract class PageLinkProducts extends PropelBaseModelClass implements ActiveRecordInterface |
32
|
|
|
{ |
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* TableMap class name |
35
|
|
|
*/ |
36
|
|
|
const TABLE_MAP = '\\mod_link\\models\\Map\\PageLinkProductsTableMap'; |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* attribute to determine if this object has previously been saved. |
41
|
|
|
* @var boolean |
42
|
|
|
*/ |
43
|
|
|
protected $new = true; |
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* attribute to determine whether this object has been deleted. |
47
|
|
|
* @var boolean |
48
|
|
|
*/ |
49
|
|
|
protected $deleted = false; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The columns that have been modified in current object. |
53
|
|
|
* Tracking modified columns allows us to only update modified columns. |
54
|
|
|
* @var array |
55
|
|
|
*/ |
56
|
|
|
protected $modifiedColumns = array(); |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* The (virtual) columns that are added at runtime |
60
|
|
|
* The formatters can add supplementary columns based on a resultset |
61
|
|
|
* @var array |
62
|
|
|
*/ |
63
|
|
|
protected $virtualColumns = array(); |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* The value for the link_id field. |
67
|
|
|
* |
68
|
|
|
* @var int |
69
|
|
|
*/ |
70
|
|
|
protected $link_id; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* The value for the product_id field. |
74
|
|
|
* |
75
|
|
|
* @var int |
76
|
|
|
*/ |
77
|
|
|
protected $product_id; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @var ChildPageLink |
81
|
|
|
*/ |
82
|
|
|
protected $aPageLink; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Flag to prevent endless save loop, if this object is referenced |
86
|
|
|
* by another object which falls in this transaction. |
87
|
|
|
* |
88
|
|
|
* @var boolean |
89
|
|
|
*/ |
90
|
|
|
protected $alreadyInSave = false; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Initializes internal state of mod_link\models\Base\PageLinkProducts object. |
94
|
|
|
*/ |
95
|
|
|
public function __construct() |
96
|
|
|
{ |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Returns whether the object has been modified. |
101
|
|
|
* |
102
|
|
|
* @return boolean True if the object has been modified. |
103
|
|
|
*/ |
104
|
|
|
public function isModified() |
105
|
|
|
{ |
106
|
|
|
return !!$this->modifiedColumns; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Has specified column been modified? |
111
|
|
|
* |
112
|
|
|
* @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
|
|
|
113
|
|
|
* @return boolean True if $col has been modified. |
114
|
|
|
*/ |
115
|
|
|
public function isColumnModified($col) |
116
|
|
|
{ |
117
|
|
|
return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get the columns that have been modified in this object. |
122
|
|
|
* @return array A unique list of the modified column names for this object. |
123
|
|
|
*/ |
124
|
|
|
public function getModifiedColumns() |
125
|
|
|
{ |
126
|
|
|
return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Returns whether the object has ever been saved. This will |
131
|
|
|
* be false, if the object was retrieved from storage or was created |
132
|
|
|
* and then saved. |
133
|
|
|
* |
134
|
|
|
* @return boolean true, if the object has never been persisted. |
135
|
|
|
*/ |
136
|
|
|
public function isNew() |
137
|
|
|
{ |
138
|
|
|
return $this->new; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* Setter for the isNew attribute. This method will be called |
143
|
|
|
* by Propel-generated children and objects. |
144
|
|
|
* |
145
|
|
|
* @param boolean $b the state of the object. |
146
|
|
|
*/ |
147
|
|
|
public function setNew($b) |
148
|
|
|
{ |
149
|
|
|
$this->new = (boolean) $b; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Whether this object has been deleted. |
154
|
|
|
* @return boolean The deleted state of this object. |
155
|
|
|
*/ |
156
|
|
|
public function isDeleted() |
157
|
|
|
{ |
158
|
|
|
return $this->deleted; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Specify whether this object has been deleted. |
163
|
|
|
* @param boolean $b The deleted state of this object. |
164
|
|
|
* @return void |
|
|
|
|
165
|
|
|
*/ |
166
|
|
|
public function setDeleted($b) |
167
|
|
|
{ |
168
|
|
|
$this->deleted = (boolean) $b; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
/** |
172
|
|
|
* Sets the modified state for the object to be false. |
173
|
|
|
* @param string $col If supplied, only the specified column is reset. |
174
|
|
|
* @return void |
|
|
|
|
175
|
|
|
*/ |
176
|
|
View Code Duplication |
public function resetModified($col = null) |
177
|
|
|
{ |
178
|
|
|
if (null !== $col) { |
179
|
|
|
if (isset($this->modifiedColumns[$col])) { |
180
|
|
|
unset($this->modifiedColumns[$col]); |
181
|
|
|
} |
182
|
|
|
} else { |
183
|
|
|
$this->modifiedColumns = array(); |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Compares this with another <code>PageLinkProducts</code> instance. If |
189
|
|
|
* <code>obj</code> is an instance of <code>PageLinkProducts</code>, delegates to |
190
|
|
|
* <code>equals(PageLinkProducts)</code>. Otherwise, returns <code>false</code>. |
191
|
|
|
* |
192
|
|
|
* @param mixed $obj The object to compare to. |
|
|
|
|
193
|
|
|
* @return boolean Whether equal to the object specified. |
194
|
|
|
*/ |
195
|
|
|
public function equals($obj) |
196
|
|
|
{ |
197
|
|
|
if (!$obj instanceof static) { |
198
|
|
|
return false; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
if ($this === $obj) { |
202
|
|
|
return true; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
206
|
|
|
return false; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* Get the associative array of the virtual columns in this object |
214
|
|
|
* |
215
|
|
|
* @return array |
216
|
|
|
*/ |
217
|
|
|
public function getVirtualColumns() |
218
|
|
|
{ |
219
|
|
|
return $this->virtualColumns; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Checks the existence of a virtual column in this object |
224
|
|
|
* |
225
|
|
|
* @param string $name The virtual column name |
|
|
|
|
226
|
|
|
* @return boolean |
227
|
|
|
*/ |
228
|
|
|
public function hasVirtualColumn($name) |
229
|
|
|
{ |
230
|
|
|
return array_key_exists($name, $this->virtualColumns); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Get the value of a virtual column in this object |
235
|
|
|
* |
236
|
|
|
* @param string $name The virtual column name |
237
|
|
|
* @return mixed |
238
|
|
|
* |
239
|
|
|
* @throws PropelException |
|
|
|
|
240
|
|
|
*/ |
241
|
|
|
public function getVirtualColumn($name) |
242
|
|
|
{ |
243
|
|
|
if (!$this->hasVirtualColumn($name)) { |
244
|
|
|
throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return $this->virtualColumns[$name]; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Set the value of a virtual column in this object |
252
|
|
|
* |
253
|
|
|
* @param string $name The virtual column name |
254
|
|
|
* @param mixed $value The value to give to the virtual column |
|
|
|
|
255
|
|
|
* |
256
|
|
|
* @return $this|PageLinkProducts The current object, for fluid interface |
|
|
|
|
257
|
|
|
*/ |
258
|
|
|
public function setVirtualColumn($name, $value) |
259
|
|
|
{ |
260
|
|
|
$this->virtualColumns[$name] = $value; |
261
|
|
|
|
262
|
|
|
return $this; |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
/** |
266
|
|
|
* Logs a message using Propel::log(). |
267
|
|
|
* |
268
|
|
|
* @param string $msg |
|
|
|
|
269
|
|
|
* @param int $priority One of the Propel::LOG_* logging levels |
|
|
|
|
270
|
|
|
* @return boolean |
|
|
|
|
271
|
|
|
*/ |
272
|
|
|
protected function log($msg, $priority = Propel::LOG_INFO) |
273
|
|
|
{ |
274
|
|
|
return Propel::log(get_class($this) . ': ' . $msg, $priority); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Export the current object properties to a string, using a given parser format |
279
|
|
|
* <code> |
280
|
|
|
* $book = BookQuery::create()->findPk(9012); |
281
|
|
|
* echo $book->exportTo('JSON'); |
282
|
|
|
* => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
283
|
|
|
* </code> |
284
|
|
|
* |
285
|
|
|
* @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
|
|
|
286
|
|
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
287
|
|
|
* @return string The exported data |
288
|
|
|
*/ |
289
|
|
View Code Duplication |
public function exportTo($parser, $includeLazyLoadColumns = true) |
290
|
|
|
{ |
291
|
|
|
if (!$parser instanceof AbstractParser) { |
292
|
|
|
$parser = AbstractParser::getParser($parser); |
293
|
|
|
} |
294
|
|
|
|
295
|
|
|
return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
|
|
|
296
|
|
|
} |
297
|
|
|
|
298
|
|
|
/** |
299
|
|
|
* Clean up internal collections prior to serializing |
300
|
|
|
* Avoids recursive loops that turn into segmentation faults when serializing |
301
|
|
|
*/ |
302
|
|
View Code Duplication |
public function __sleep() |
303
|
|
|
{ |
304
|
|
|
$this->clearAllReferences(); |
305
|
|
|
|
306
|
|
|
$cls = new \ReflectionClass($this); |
307
|
|
|
$propertyNames = []; |
308
|
|
|
$serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
309
|
|
|
|
310
|
|
|
foreach($serializableProperties as $property) { |
|
|
|
|
311
|
|
|
$propertyNames[] = $property->getName(); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
return $propertyNames; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* Get the [link_id] column value. |
319
|
|
|
* |
320
|
|
|
* @return int |
321
|
|
|
*/ |
322
|
|
|
public function getLinkId() |
323
|
|
|
{ |
324
|
|
|
return $this->link_id; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Get the [product_id] column value. |
329
|
|
|
* |
330
|
|
|
* @return int |
331
|
|
|
*/ |
332
|
|
|
public function getProductId() |
333
|
|
|
{ |
334
|
|
|
return $this->product_id; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Set the value of [link_id] column. |
339
|
|
|
* |
340
|
|
|
* @param int $v new value |
341
|
|
|
* @return $this|\mod_link\models\PageLinkProducts The current object (for fluent API support) |
|
|
|
|
342
|
|
|
*/ |
343
|
|
View Code Duplication |
public function setLinkId($v) |
344
|
|
|
{ |
345
|
|
|
if ($v !== null) { |
346
|
|
|
$v = (int) $v; |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
if ($this->link_id !== $v) { |
350
|
|
|
$this->link_id = $v; |
351
|
|
|
$this->modifiedColumns[PageLinkProductsTableMap::COL_LINK_ID] = true; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
if ($this->aPageLink !== null && $this->aPageLink->getId() !== $v) { |
355
|
|
|
$this->aPageLink = null; |
356
|
|
|
} |
357
|
|
|
|
358
|
|
|
return $this; |
359
|
|
|
} // setLinkId() |
360
|
|
|
|
361
|
|
|
/** |
362
|
|
|
* Set the value of [product_id] column. |
363
|
|
|
* |
364
|
|
|
* @param int $v new value |
365
|
|
|
* @return $this|\mod_link\models\PageLinkProducts The current object (for fluent API support) |
|
|
|
|
366
|
|
|
*/ |
367
|
|
View Code Duplication |
public function setProductId($v) |
368
|
|
|
{ |
369
|
|
|
if ($v !== null) { |
370
|
|
|
$v = (int) $v; |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
if ($this->product_id !== $v) { |
374
|
|
|
$this->product_id = $v; |
375
|
|
|
$this->modifiedColumns[PageLinkProductsTableMap::COL_PRODUCT_ID] = true; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
return $this; |
379
|
|
|
} // setProductId() |
380
|
|
|
|
381
|
|
|
/** |
382
|
|
|
* Indicates whether the columns in this object are only set to default values. |
383
|
|
|
* |
384
|
|
|
* This method can be used in conjunction with isModified() to indicate whether an object is both |
385
|
|
|
* modified _and_ has some values set which are non-default. |
386
|
|
|
* |
387
|
|
|
* @return boolean Whether the columns in this object are only been set with default values. |
388
|
|
|
*/ |
389
|
|
|
public function hasOnlyDefaultValues() |
390
|
|
|
{ |
391
|
|
|
// otherwise, everything was equal, so return TRUE |
392
|
|
|
return true; |
393
|
|
|
} // hasOnlyDefaultValues() |
394
|
|
|
|
395
|
|
|
/** |
396
|
|
|
* Hydrates (populates) the object variables with values from the database resultset. |
397
|
|
|
* |
398
|
|
|
* An offset (0-based "start column") is specified so that objects can be hydrated |
399
|
|
|
* with a subset of the columns in the resultset rows. This is needed, for example, |
400
|
|
|
* for results of JOIN queries where the resultset row includes columns from two or |
401
|
|
|
* more tables. |
402
|
|
|
* |
403
|
|
|
* @param array $row The row returned by DataFetcher->fetch(). |
|
|
|
|
404
|
|
|
* @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
|
|
|
405
|
|
|
* @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
406
|
|
|
* @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
|
|
|
407
|
|
|
One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
408
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
409
|
|
|
* |
410
|
|
|
* @return int next starting column |
411
|
|
|
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
|
|
|
412
|
|
|
*/ |
413
|
|
View Code Duplication |
public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
414
|
|
|
{ |
415
|
|
|
try { |
416
|
|
|
|
417
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : PageLinkProductsTableMap::translateFieldName('LinkId', TableMap::TYPE_PHPNAME, $indexType)]; |
418
|
|
|
$this->link_id = (null !== $col) ? (int) $col : null; |
419
|
|
|
|
420
|
|
|
$col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : PageLinkProductsTableMap::translateFieldName('ProductId', TableMap::TYPE_PHPNAME, $indexType)]; |
421
|
|
|
$this->product_id = (null !== $col) ? (int) $col : null; |
422
|
|
|
$this->resetModified(); |
423
|
|
|
|
424
|
|
|
$this->setNew(false); |
425
|
|
|
|
426
|
|
|
if ($rehydrate) { |
427
|
|
|
$this->ensureConsistency(); |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
return $startcol + 2; // 2 = PageLinkProductsTableMap::NUM_HYDRATE_COLUMNS. |
431
|
|
|
|
432
|
|
|
} catch (Exception $e) { |
433
|
|
|
throw new PropelException(sprintf('Error populating %s object', '\\mod_link\\models\\PageLinkProducts'), 0, $e); |
434
|
|
|
} |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* Checks and repairs the internal consistency of the object. |
439
|
|
|
* |
440
|
|
|
* This method is executed after an already-instantiated object is re-hydrated |
441
|
|
|
* from the database. It exists to check any foreign keys to make sure that |
442
|
|
|
* the objects related to the current object are correct based on foreign key. |
443
|
|
|
* |
444
|
|
|
* You can override this method in the stub class, but you should always invoke |
445
|
|
|
* the base method from the overridden method (i.e. parent::ensureConsistency()), |
446
|
|
|
* in case your model changes. |
447
|
|
|
* |
448
|
|
|
* @throws PropelException |
|
|
|
|
449
|
|
|
*/ |
450
|
|
|
public function ensureConsistency() |
451
|
|
|
{ |
452
|
|
View Code Duplication |
if ($this->aPageLink !== null && $this->link_id !== $this->aPageLink->getId()) { |
453
|
|
|
$this->aPageLink = null; |
454
|
|
|
} |
455
|
|
|
} // ensureConsistency |
456
|
|
|
|
457
|
|
|
/** |
458
|
|
|
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
459
|
|
|
* |
460
|
|
|
* This will only work if the object has been saved and has a valid primary key set. |
461
|
|
|
* |
462
|
|
|
* @param boolean $deep (optional) Whether to also de-associated any related objects. |
463
|
|
|
* @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
464
|
|
|
* @return void |
|
|
|
|
465
|
|
|
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
|
|
|
466
|
|
|
*/ |
467
|
|
|
public function reload($deep = false, ConnectionInterface $con = null) |
468
|
|
|
{ |
469
|
|
|
if ($this->isDeleted()) { |
470
|
|
|
throw new PropelException("Cannot reload a deleted object."); |
471
|
|
|
} |
472
|
|
|
|
473
|
|
|
if ($this->isNew()) { |
474
|
|
|
throw new PropelException("Cannot reload an unsaved object."); |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
if ($con === null) { |
478
|
|
|
$con = Propel::getServiceContainer()->getReadConnection(PageLinkProductsTableMap::DATABASE_NAME); |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
// We don't need to alter the object instance pool; we're just modifying this instance |
482
|
|
|
// already in the pool. |
483
|
|
|
|
484
|
|
|
$dataFetcher = ChildPageLinkProductsQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
485
|
|
|
$row = $dataFetcher->fetch(); |
486
|
|
|
$dataFetcher->close(); |
487
|
|
|
if (!$row) { |
488
|
|
|
throw new PropelException('Cannot find matching row in the database to reload object values.'); |
489
|
|
|
} |
490
|
|
|
$this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
491
|
|
|
|
492
|
|
|
if ($deep) { // also de-associate any related objects? |
|
|
|
|
493
|
|
|
|
494
|
|
|
$this->aPageLink = null; |
495
|
|
|
} // if (deep) |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
/** |
499
|
|
|
* Removes this object from datastore and sets delete attribute. |
500
|
|
|
* |
501
|
|
|
* @param ConnectionInterface $con |
502
|
|
|
* @return void |
|
|
|
|
503
|
|
|
* @throws PropelException |
|
|
|
|
504
|
|
|
* @see PageLinkProducts::setDeleted() |
505
|
|
|
* @see PageLinkProducts::isDeleted() |
506
|
|
|
*/ |
507
|
|
View Code Duplication |
public function delete(ConnectionInterface $con = null) |
508
|
|
|
{ |
509
|
|
|
if ($this->isDeleted()) { |
510
|
|
|
throw new PropelException("This object has already been deleted."); |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
if ($con === null) { |
514
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(PageLinkProductsTableMap::DATABASE_NAME); |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
$con->transaction(function () use ($con) { |
518
|
|
|
$deleteQuery = ChildPageLinkProductsQuery::create() |
519
|
|
|
->filterByPrimaryKey($this->getPrimaryKey()); |
520
|
|
|
$ret = $this->preDelete($con); |
521
|
|
|
if ($ret) { |
522
|
|
|
$deleteQuery->delete($con); |
523
|
|
|
$this->postDelete($con); |
524
|
|
|
$this->setDeleted(true); |
525
|
|
|
} |
526
|
|
|
}); |
527
|
|
|
} |
528
|
|
|
|
529
|
|
|
/** |
530
|
|
|
* Persists this object to the database. |
531
|
|
|
* |
532
|
|
|
* If the object is new, it inserts it; otherwise an update is performed. |
533
|
|
|
* All modified related objects will also be persisted in the doSave() |
534
|
|
|
* method. This method wraps all precipitate database operations in a |
535
|
|
|
* single transaction. |
536
|
|
|
* |
537
|
|
|
* @param ConnectionInterface $con |
538
|
|
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
539
|
|
|
* @throws PropelException |
|
|
|
|
540
|
|
|
* @see doSave() |
541
|
|
|
*/ |
542
|
|
View Code Duplication |
public function save(ConnectionInterface $con = null) |
543
|
|
|
{ |
544
|
|
|
if ($this->isDeleted()) { |
545
|
|
|
throw new PropelException("You cannot save an object that has been deleted."); |
546
|
|
|
} |
547
|
|
|
|
548
|
|
|
if ($con === null) { |
549
|
|
|
$con = Propel::getServiceContainer()->getWriteConnection(PageLinkProductsTableMap::DATABASE_NAME); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
return $con->transaction(function () use ($con) { |
553
|
|
|
$ret = $this->preSave($con); |
554
|
|
|
$isInsert = $this->isNew(); |
555
|
|
|
if ($isInsert) { |
556
|
|
|
$ret = $ret && $this->preInsert($con); |
557
|
|
|
} else { |
558
|
|
|
$ret = $ret && $this->preUpdate($con); |
559
|
|
|
} |
560
|
|
|
if ($ret) { |
561
|
|
|
$affectedRows = $this->doSave($con); |
562
|
|
|
if ($isInsert) { |
563
|
|
|
$this->postInsert($con); |
564
|
|
|
} else { |
565
|
|
|
$this->postUpdate($con); |
566
|
|
|
} |
567
|
|
|
$this->postSave($con); |
568
|
|
|
PageLinkProductsTableMap::addInstanceToPool($this); |
569
|
|
|
} else { |
570
|
|
|
$affectedRows = 0; |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
return $affectedRows; |
574
|
|
|
}); |
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* Performs the work of inserting or updating the row in the database. |
579
|
|
|
* |
580
|
|
|
* If the object is new, it inserts it; otherwise an update is performed. |
581
|
|
|
* All related objects are also updated in this method. |
582
|
|
|
* |
583
|
|
|
* @param ConnectionInterface $con |
584
|
|
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
585
|
|
|
* @throws PropelException |
|
|
|
|
586
|
|
|
* @see save() |
587
|
|
|
*/ |
588
|
|
View Code Duplication |
protected function doSave(ConnectionInterface $con) |
589
|
|
|
{ |
590
|
|
|
$affectedRows = 0; // initialize var to track total num of affected rows |
591
|
|
|
if (!$this->alreadyInSave) { |
592
|
|
|
$this->alreadyInSave = true; |
593
|
|
|
|
594
|
|
|
// We call the save method on the following object(s) if they |
595
|
|
|
// were passed to this object by their corresponding set |
596
|
|
|
// method. This object relates to these object(s) by a |
597
|
|
|
// foreign key reference. |
598
|
|
|
|
599
|
|
|
if ($this->aPageLink !== null) { |
600
|
|
|
if ($this->aPageLink->isModified() || $this->aPageLink->isNew()) { |
601
|
|
|
$affectedRows += $this->aPageLink->save($con); |
602
|
|
|
} |
603
|
|
|
$this->setPageLink($this->aPageLink); |
604
|
|
|
} |
605
|
|
|
|
606
|
|
|
if ($this->isNew() || $this->isModified()) { |
607
|
|
|
// persist changes |
608
|
|
|
if ($this->isNew()) { |
609
|
|
|
$this->doInsert($con); |
610
|
|
|
$affectedRows += 1; |
611
|
|
|
} else { |
612
|
|
|
$affectedRows += $this->doUpdate($con); |
613
|
|
|
} |
614
|
|
|
$this->resetModified(); |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
$this->alreadyInSave = false; |
618
|
|
|
|
619
|
|
|
} |
620
|
|
|
|
621
|
|
|
return $affectedRows; |
622
|
|
|
} // doSave() |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* Insert the row in the database. |
626
|
|
|
* |
627
|
|
|
* @param ConnectionInterface $con |
628
|
|
|
* |
629
|
|
|
* @throws PropelException |
|
|
|
|
630
|
|
|
* @see doSave() |
631
|
|
|
*/ |
632
|
|
View Code Duplication |
protected function doInsert(ConnectionInterface $con) |
633
|
|
|
{ |
634
|
|
|
$modifiedColumns = array(); |
635
|
|
|
$index = 0; |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
638
|
|
|
// check the columns in natural order for more readable SQL queries |
639
|
|
|
if ($this->isColumnModified(PageLinkProductsTableMap::COL_LINK_ID)) { |
640
|
|
|
$modifiedColumns[':p' . $index++] = 'link_id'; |
641
|
|
|
} |
642
|
|
|
if ($this->isColumnModified(PageLinkProductsTableMap::COL_PRODUCT_ID)) { |
643
|
|
|
$modifiedColumns[':p' . $index++] = 'product_id'; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
$sql = sprintf( |
647
|
|
|
'INSERT INTO page_link_products (%s) VALUES (%s)', |
648
|
|
|
implode(', ', $modifiedColumns), |
649
|
|
|
implode(', ', array_keys($modifiedColumns)) |
650
|
|
|
); |
651
|
|
|
|
652
|
|
|
try { |
653
|
|
|
$stmt = $con->prepare($sql); |
654
|
|
|
foreach ($modifiedColumns as $identifier => $columnName) { |
655
|
|
|
switch ($columnName) { |
656
|
|
|
case 'link_id': |
657
|
|
|
$stmt->bindValue($identifier, $this->link_id, PDO::PARAM_INT); |
658
|
|
|
break; |
|
|
|
|
659
|
|
|
case 'product_id': |
660
|
|
|
$stmt->bindValue($identifier, $this->product_id, PDO::PARAM_INT); |
661
|
|
|
break; |
662
|
|
|
} |
663
|
|
|
} |
664
|
|
|
$stmt->execute(); |
665
|
|
|
} catch (Exception $e) { |
666
|
|
|
Propel::log($e->getMessage(), Propel::LOG_ERR); |
667
|
|
|
throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
668
|
|
|
} |
669
|
|
|
|
670
|
|
|
$this->setNew(false); |
671
|
|
|
} |
672
|
|
|
|
673
|
|
|
/** |
674
|
|
|
* Update the row in the database. |
675
|
|
|
* |
676
|
|
|
* @param ConnectionInterface $con |
677
|
|
|
* |
678
|
|
|
* @return Integer Number of updated rows |
679
|
|
|
* @see doSave() |
680
|
|
|
*/ |
681
|
|
|
protected function doUpdate(ConnectionInterface $con) |
682
|
|
|
{ |
683
|
|
|
$selectCriteria = $this->buildPkeyCriteria(); |
684
|
|
|
$valuesCriteria = $this->buildCriteria(); |
685
|
|
|
|
686
|
|
|
return $selectCriteria->doUpdate($valuesCriteria, $con); |
687
|
|
|
} |
688
|
|
|
|
689
|
|
|
/** |
690
|
|
|
* Retrieves a field from the object by name passed in as a string. |
691
|
|
|
* |
692
|
|
|
* @param string $name name |
693
|
|
|
* @param string $type The type of fieldname the $name is of: |
694
|
|
|
* one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
695
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
696
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
697
|
|
|
* @return mixed Value of field. |
|
|
|
|
698
|
|
|
*/ |
699
|
|
|
public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
700
|
|
|
{ |
701
|
|
|
$pos = PageLinkProductsTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
702
|
|
|
$field = $this->getByPosition($pos); |
703
|
|
|
|
704
|
|
|
return $field; |
705
|
|
|
} |
706
|
|
|
|
707
|
|
|
/** |
708
|
|
|
* Retrieves a field from the object by Position as specified in the xml schema. |
709
|
|
|
* Zero-based. |
710
|
|
|
* |
711
|
|
|
* @param int $pos position in xml schema |
712
|
|
|
* @return mixed Value of field at $pos |
|
|
|
|
713
|
|
|
*/ |
714
|
|
View Code Duplication |
public function getByPosition($pos) |
715
|
|
|
{ |
716
|
|
|
switch ($pos) { |
717
|
|
|
case 0: |
718
|
|
|
return $this->getLinkId(); |
|
|
|
|
719
|
|
|
break; |
|
|
|
|
720
|
|
|
case 1: |
721
|
|
|
return $this->getProductId(); |
|
|
|
|
722
|
|
|
break; |
|
|
|
|
723
|
|
|
default: |
724
|
|
|
return null; |
725
|
|
|
break; |
|
|
|
|
726
|
|
|
} // switch() |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
/** |
730
|
|
|
* Exports the object as an array. |
731
|
|
|
* |
732
|
|
|
* You can specify the key type of the array by passing one of the class |
733
|
|
|
* type constants. |
734
|
|
|
* |
735
|
|
|
* @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
|
|
|
736
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
737
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
738
|
|
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
739
|
|
|
* @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
740
|
|
|
* @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
741
|
|
|
* |
742
|
|
|
* @return array an associative array containing the field names (as keys) and field values |
|
|
|
|
743
|
|
|
*/ |
744
|
|
View Code Duplication |
public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
745
|
|
|
{ |
746
|
|
|
|
747
|
|
|
if (isset($alreadyDumpedObjects['PageLinkProducts'][$this->hashCode()])) { |
748
|
|
|
return '*RECURSION*'; |
749
|
|
|
} |
750
|
|
|
$alreadyDumpedObjects['PageLinkProducts'][$this->hashCode()] = true; |
751
|
|
|
$keys = PageLinkProductsTableMap::getFieldNames($keyType); |
752
|
|
|
$result = array( |
753
|
|
|
$keys[0] => $this->getLinkId(), |
754
|
|
|
$keys[1] => $this->getProductId(), |
755
|
|
|
); |
756
|
|
|
$virtualColumns = $this->virtualColumns; |
757
|
|
|
foreach ($virtualColumns as $key => $virtualColumn) { |
758
|
|
|
$result[$key] = $virtualColumn; |
759
|
|
|
} |
760
|
|
|
|
761
|
|
|
if ($includeForeignObjects) { |
762
|
|
|
if (null !== $this->aPageLink) { |
763
|
|
|
|
764
|
|
|
switch ($keyType) { |
765
|
|
|
case TableMap::TYPE_CAMELNAME: |
766
|
|
|
$key = 'pageLink'; |
767
|
|
|
break; |
|
|
|
|
768
|
|
|
case TableMap::TYPE_FIELDNAME: |
769
|
|
|
$key = 'page_link'; |
770
|
|
|
break; |
|
|
|
|
771
|
|
|
default: |
772
|
|
|
$key = 'PageLink'; |
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
$result[$key] = $this->aPageLink->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
|
|
|
776
|
|
|
} |
777
|
|
|
} |
778
|
|
|
|
779
|
|
|
return $result; |
780
|
|
|
} |
781
|
|
|
|
782
|
|
|
/** |
783
|
|
|
* Sets a field from the object by name passed in as a string. |
784
|
|
|
* |
785
|
|
|
* @param string $name |
786
|
|
|
* @param mixed $value field value |
|
|
|
|
787
|
|
|
* @param string $type The type of fieldname the $name is of: |
788
|
|
|
* one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
789
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
790
|
|
|
* Defaults to TableMap::TYPE_PHPNAME. |
791
|
|
|
* @return $this|\mod_link\models\PageLinkProducts |
|
|
|
|
792
|
|
|
*/ |
793
|
|
|
public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
794
|
|
|
{ |
795
|
|
|
$pos = PageLinkProductsTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
796
|
|
|
|
797
|
|
|
return $this->setByPosition($pos, $value); |
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
/** |
801
|
|
|
* Sets a field from the object by Position as specified in the xml schema. |
802
|
|
|
* Zero-based. |
803
|
|
|
* |
804
|
|
|
* @param int $pos position in xml schema |
805
|
|
|
* @param mixed $value field value |
806
|
|
|
* @return $this|\mod_link\models\PageLinkProducts |
|
|
|
|
807
|
|
|
*/ |
808
|
|
View Code Duplication |
public function setByPosition($pos, $value) |
809
|
|
|
{ |
810
|
|
|
switch ($pos) { |
811
|
|
|
case 0: |
812
|
|
|
$this->setLinkId($value); |
813
|
|
|
break; |
|
|
|
|
814
|
|
|
case 1: |
815
|
|
|
$this->setProductId($value); |
816
|
|
|
break; |
817
|
|
|
} // switch() |
818
|
|
|
|
819
|
|
|
return $this; |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
/** |
823
|
|
|
* Populates the object using an array. |
824
|
|
|
* |
825
|
|
|
* This is particularly useful when populating an object from one of the |
826
|
|
|
* request arrays (e.g. $_POST). This method goes through the column |
827
|
|
|
* names, checking to see whether a matching key exists in populated |
828
|
|
|
* array. If so the setByName() method is called for that column. |
829
|
|
|
* |
830
|
|
|
* You can specify the key type of the array by additionally passing one |
831
|
|
|
* of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
832
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
833
|
|
|
* The default key type is the column's TableMap::TYPE_PHPNAME. |
834
|
|
|
* |
835
|
|
|
* @param array $arr An array to populate the object from. |
|
|
|
|
836
|
|
|
* @param string $keyType The type of keys the array uses. |
837
|
|
|
* @return void |
|
|
|
|
838
|
|
|
*/ |
839
|
|
View Code Duplication |
public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
840
|
|
|
{ |
841
|
|
|
$keys = PageLinkProductsTableMap::getFieldNames($keyType); |
842
|
|
|
|
843
|
|
|
if (array_key_exists($keys[0], $arr)) { |
844
|
|
|
$this->setLinkId($arr[$keys[0]]); |
845
|
|
|
} |
846
|
|
|
if (array_key_exists($keys[1], $arr)) { |
847
|
|
|
$this->setProductId($arr[$keys[1]]); |
848
|
|
|
} |
849
|
|
|
} |
850
|
|
|
|
851
|
|
|
/** |
852
|
|
|
* Populate the current object from a string, using a given parser format |
|
|
|
|
853
|
|
|
* <code> |
|
|
|
|
854
|
|
|
* $book = new Book(); |
|
|
|
|
855
|
|
|
* $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
|
|
|
856
|
|
|
* </code> |
|
|
|
|
857
|
|
|
* |
|
|
|
|
858
|
|
|
* You can specify the key type of the array by additionally passing one |
|
|
|
|
859
|
|
|
* of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
|
|
|
860
|
|
|
* TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
|
|
|
861
|
|
|
* The default key type is the column's TableMap::TYPE_PHPNAME. |
|
|
|
|
862
|
|
|
* |
|
|
|
|
863
|
|
|
* @param mixed $parser A AbstractParser instance, |
|
|
|
|
864
|
|
|
* or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
|
|
|
865
|
|
|
* @param string $data The source data to import from |
|
|
|
|
866
|
|
|
* @param string $keyType The type of keys the array uses. |
|
|
|
|
867
|
|
|
* |
|
|
|
|
868
|
|
|
* @return $this|\mod_link\models\PageLinkProducts The current object, for fluid interface |
|
|
|
|
869
|
|
|
*/ |
|
|
|
|
870
|
|
View Code Duplication |
public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
871
|
|
|
{ |
872
|
|
|
if (!$parser instanceof AbstractParser) { |
873
|
|
|
$parser = AbstractParser::getParser($parser); |
874
|
|
|
} |
875
|
|
|
|
876
|
|
|
$this->fromArray($parser->toArray($data), $keyType); |
877
|
|
|
|
878
|
|
|
return $this; |
879
|
|
|
} |
880
|
|
|
|
881
|
|
|
/** |
882
|
|
|
* Build a Criteria object containing the values of all modified columns in this object. |
883
|
|
|
* |
884
|
|
|
* @return Criteria The Criteria object containing all modified values. |
885
|
|
|
*/ |
886
|
|
View Code Duplication |
public function buildCriteria() |
887
|
|
|
{ |
888
|
|
|
$criteria = new Criteria(PageLinkProductsTableMap::DATABASE_NAME); |
889
|
|
|
|
890
|
|
|
if ($this->isColumnModified(PageLinkProductsTableMap::COL_LINK_ID)) { |
891
|
|
|
$criteria->add(PageLinkProductsTableMap::COL_LINK_ID, $this->link_id); |
892
|
|
|
} |
893
|
|
|
if ($this->isColumnModified(PageLinkProductsTableMap::COL_PRODUCT_ID)) { |
894
|
|
|
$criteria->add(PageLinkProductsTableMap::COL_PRODUCT_ID, $this->product_id); |
895
|
|
|
} |
896
|
|
|
|
897
|
|
|
return $criteria; |
898
|
|
|
} |
899
|
|
|
|
900
|
|
|
/** |
901
|
|
|
* Builds a Criteria object containing the primary key for this object. |
902
|
|
|
* |
903
|
|
|
* Unlike buildCriteria() this method includes the primary key values regardless |
904
|
|
|
* of whether or not they have been modified. |
905
|
|
|
* |
906
|
|
|
* @throws LogicException if no primary key is defined |
|
|
|
|
907
|
|
|
* |
908
|
|
|
* @return Criteria The Criteria object containing value(s) for primary key(s). |
909
|
|
|
*/ |
910
|
|
|
public function buildPkeyCriteria() |
911
|
|
|
{ |
912
|
|
|
$criteria = ChildPageLinkProductsQuery::create(); |
913
|
|
|
$criteria->add(PageLinkProductsTableMap::COL_LINK_ID, $this->link_id); |
914
|
|
|
$criteria->add(PageLinkProductsTableMap::COL_PRODUCT_ID, $this->product_id); |
915
|
|
|
|
916
|
|
|
return $criteria; |
917
|
|
|
} |
918
|
|
|
|
919
|
|
|
/** |
920
|
|
|
* If the primary key is not null, return the hashcode of the |
921
|
|
|
* primary key. Otherwise, return the hash code of the object. |
922
|
|
|
* |
923
|
|
|
* @return int Hashcode |
|
|
|
|
924
|
|
|
*/ |
925
|
|
View Code Duplication |
public function hashCode() |
926
|
|
|
{ |
927
|
|
|
$validPk = null !== $this->getLinkId() && |
928
|
|
|
null !== $this->getProductId(); |
929
|
|
|
|
930
|
|
|
$validPrimaryKeyFKs = 1; |
931
|
|
|
$primaryKeyFKs = []; |
932
|
|
|
|
933
|
|
|
//relation page_link_products_fk_5a23ad to table page_link |
934
|
|
|
if ($this->aPageLink && $hash = spl_object_hash($this->aPageLink)) { |
935
|
|
|
$primaryKeyFKs[] = $hash; |
936
|
|
|
} else { |
937
|
|
|
$validPrimaryKeyFKs = false; |
938
|
|
|
} |
939
|
|
|
|
940
|
|
|
if ($validPk) { |
941
|
|
|
return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
942
|
|
|
} elseif ($validPrimaryKeyFKs) { |
943
|
|
|
return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
return spl_object_hash($this); |
947
|
|
|
} |
948
|
|
|
|
949
|
|
|
/** |
950
|
|
|
* Returns the composite primary key for this object. |
951
|
|
|
* The array elements will be in same order as specified in XML. |
952
|
|
|
* @return array |
|
|
|
|
953
|
|
|
*/ |
954
|
|
View Code Duplication |
public function getPrimaryKey() |
955
|
|
|
{ |
956
|
|
|
$pks = array(); |
957
|
|
|
$pks[0] = $this->getLinkId(); |
958
|
|
|
$pks[1] = $this->getProductId(); |
959
|
|
|
|
960
|
|
|
return $pks; |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
/** |
964
|
|
|
* Set the [composite] primary key. |
965
|
|
|
* |
966
|
|
|
* @param array $keys The elements of the composite key (order must match the order in XML file). |
967
|
|
|
* @return void |
|
|
|
|
968
|
|
|
*/ |
969
|
|
|
public function setPrimaryKey($keys) |
970
|
|
|
{ |
971
|
|
|
$this->setLinkId($keys[0]); |
972
|
|
|
$this->setProductId($keys[1]); |
973
|
|
|
} |
974
|
|
|
|
975
|
|
|
/** |
976
|
|
|
* Returns true if the primary key for this object is null. |
977
|
|
|
* @return boolean |
978
|
|
|
*/ |
979
|
|
|
public function isPrimaryKeyNull() |
980
|
|
|
{ |
981
|
|
|
return (null === $this->getLinkId()) && (null === $this->getProductId()); |
982
|
|
|
} |
983
|
|
|
|
984
|
|
|
/** |
985
|
|
|
* Sets contents of passed object to values from current object. |
986
|
|
|
* |
987
|
|
|
* If desired, this method can also make copies of all associated (fkey referrers) |
988
|
|
|
* objects. |
989
|
|
|
* |
990
|
|
|
* @param object $copyObj An object of \mod_link\models\PageLinkProducts (or compatible) type. |
991
|
|
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
992
|
|
|
* @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
993
|
|
|
* @throws PropelException |
|
|
|
|
994
|
|
|
*/ |
995
|
|
View Code Duplication |
public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
996
|
|
|
{ |
997
|
|
|
$copyObj->setLinkId($this->getLinkId()); |
998
|
|
|
$copyObj->setProductId($this->getProductId()); |
999
|
|
|
if ($makeNew) { |
1000
|
|
|
$copyObj->setNew(true); |
1001
|
|
|
} |
1002
|
|
|
} |
1003
|
|
|
|
1004
|
|
|
/** |
1005
|
|
|
* Makes a copy of this object that will be inserted as a new row in table when saved. |
1006
|
|
|
* It creates a new object filling in the simple attributes, but skipping any primary |
1007
|
|
|
* keys that are defined for the table. |
1008
|
|
|
* |
1009
|
|
|
* If desired, this method can also make copies of all associated (fkey referrers) |
1010
|
|
|
* objects. |
1011
|
|
|
* |
1012
|
|
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
1013
|
|
|
* @return \mod_link\models\PageLinkProducts Clone of current object. |
1014
|
|
|
* @throws PropelException |
|
|
|
|
1015
|
|
|
*/ |
1016
|
|
|
public function copy($deepCopy = false) |
1017
|
|
|
{ |
1018
|
|
|
// we use get_class(), because this might be a subclass |
1019
|
|
|
$clazz = get_class($this); |
1020
|
|
|
$copyObj = new $clazz(); |
1021
|
|
|
$this->copyInto($copyObj, $deepCopy); |
1022
|
|
|
|
1023
|
|
|
return $copyObj; |
1024
|
|
|
} |
1025
|
|
|
|
1026
|
|
|
/** |
1027
|
|
|
* Declares an association between this object and a ChildPageLink object. |
1028
|
|
|
* |
1029
|
|
|
* @param ChildPageLink $v |
1030
|
|
|
* @return $this|\mod_link\models\PageLinkProducts The current object (for fluent API support) |
|
|
|
|
1031
|
|
|
* @throws PropelException |
|
|
|
|
1032
|
|
|
*/ |
1033
|
|
View Code Duplication |
public function setPageLink(ChildPageLink $v = null) |
1034
|
|
|
{ |
1035
|
|
|
if ($v === null) { |
1036
|
|
|
$this->setLinkId(NULL); |
1037
|
|
|
} else { |
1038
|
|
|
$this->setLinkId($v->getId()); |
1039
|
|
|
} |
1040
|
|
|
|
1041
|
|
|
$this->aPageLink = $v; |
1042
|
|
|
|
1043
|
|
|
// Add binding for other direction of this n:n relationship. |
1044
|
|
|
// If this object has already been added to the ChildPageLink object, it will not be re-added. |
1045
|
|
|
if ($v !== null) { |
1046
|
|
|
$v->addPageLinkProducts($this); |
1047
|
|
|
} |
1048
|
|
|
|
|
|
|
|
1049
|
|
|
|
1050
|
|
|
return $this; |
1051
|
|
|
} |
|
|
|
|
1052
|
|
|
|
1053
|
|
|
|
1054
|
|
|
/** |
1055
|
|
|
* Get the associated ChildPageLink object |
1056
|
|
|
* |
1057
|
|
|
* @param ConnectionInterface $con Optional Connection object. |
1058
|
|
|
* @return ChildPageLink The associated ChildPageLink object. |
1059
|
|
|
* @throws PropelException |
|
|
|
|
1060
|
|
|
*/ |
1061
|
|
View Code Duplication |
public function getPageLink(ConnectionInterface $con = null) |
1062
|
|
|
{ |
1063
|
|
|
if ($this->aPageLink === null && ($this->link_id !== null)) { |
1064
|
|
|
$this->aPageLink = ChildPageLinkQuery::create()->findPk($this->link_id, $con); |
1065
|
|
|
/* The following can be used additionally to |
1066
|
|
|
guarantee the related object contains a reference |
1067
|
|
|
to this object. This level of coupling may, however, be |
1068
|
|
|
undesirable since it could result in an only partially populated collection |
1069
|
|
|
in the referenced object. |
1070
|
|
|
$this->aPageLink->addPageLinkProductss($this); |
1071
|
|
|
*/ |
1072
|
|
|
} |
1073
|
|
|
|
1074
|
|
|
return $this->aPageLink; |
1075
|
|
|
} |
1076
|
|
|
|
1077
|
|
|
/** |
1078
|
|
|
* Clears the current object, sets all attributes to their default values and removes |
1079
|
|
|
* outgoing references as well as back-references (from other objects to this one. Results probably in a database |
1080
|
|
|
* change of those foreign objects when you call `save` there). |
1081
|
|
|
*/ |
1082
|
|
View Code Duplication |
public function clear() |
1083
|
|
|
{ |
1084
|
|
|
if (null !== $this->aPageLink) { |
1085
|
|
|
$this->aPageLink->removePageLinkProducts($this); |
1086
|
|
|
} |
1087
|
|
|
$this->link_id = null; |
1088
|
|
|
$this->product_id = null; |
1089
|
|
|
$this->alreadyInSave = false; |
1090
|
|
|
$this->clearAllReferences(); |
1091
|
|
|
$this->resetModified(); |
1092
|
|
|
$this->setNew(true); |
1093
|
|
|
$this->setDeleted(false); |
1094
|
|
|
} |
1095
|
|
|
|
1096
|
|
|
/** |
1097
|
|
|
* Resets all references and back-references to other model objects or collections of model objects. |
1098
|
|
|
* |
1099
|
|
|
* This method is used to reset all php object references (not the actual reference in the database). |
1100
|
|
|
* Necessary for object serialisation. |
1101
|
|
|
* |
1102
|
|
|
* @param boolean $deep Whether to also clear the references on all referrer objects. |
1103
|
|
|
*/ |
1104
|
|
|
public function clearAllReferences($deep = false) |
1105
|
|
|
{ |
1106
|
|
|
if ($deep) { |
|
|
|
|
1107
|
|
|
} // if ($deep) |
1108
|
|
|
|
1109
|
|
|
$this->aPageLink = null; |
1110
|
|
|
} |
1111
|
|
|
|
1112
|
|
|
/** |
1113
|
|
|
* Return the string representation of this object |
1114
|
|
|
* |
1115
|
|
|
* @return string |
1116
|
|
|
*/ |
1117
|
|
|
public function __toString() |
1118
|
|
|
{ |
1119
|
|
|
return (string) $this->exportTo(PageLinkProductsTableMap::DEFAULT_STRING_FORMAT); |
1120
|
|
|
} |
1121
|
|
|
|
1122
|
|
|
/** |
1123
|
|
|
* Code to be run before persisting the object |
1124
|
|
|
* @param ConnectionInterface $con |
1125
|
|
|
* @return boolean |
1126
|
|
|
*/ |
1127
|
|
|
public function preSave(ConnectionInterface $con = null) |
1128
|
|
|
{ |
1129
|
|
|
return true; |
1130
|
|
|
} |
1131
|
|
|
|
1132
|
|
|
/** |
1133
|
|
|
* Code to be run after persisting the object |
1134
|
|
|
* @param ConnectionInterface $con |
1135
|
|
|
*/ |
1136
|
|
|
public function postSave(ConnectionInterface $con = null) |
1137
|
|
|
{ |
1138
|
|
|
|
1139
|
|
|
} |
1140
|
|
|
|
1141
|
|
|
/** |
1142
|
|
|
* Code to be run before inserting to database |
1143
|
|
|
* @param ConnectionInterface $con |
1144
|
|
|
* @return boolean |
1145
|
|
|
*/ |
1146
|
|
|
public function preInsert(ConnectionInterface $con = null) |
1147
|
|
|
{ |
1148
|
|
|
return true; |
1149
|
|
|
} |
1150
|
|
|
|
1151
|
|
|
/** |
1152
|
|
|
* Code to be run after inserting to database |
1153
|
|
|
* @param ConnectionInterface $con |
1154
|
|
|
*/ |
1155
|
|
|
public function postInsert(ConnectionInterface $con = null) |
1156
|
|
|
{ |
1157
|
|
|
|
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
/** |
1161
|
|
|
* Code to be run before updating the object in database |
1162
|
|
|
* @param ConnectionInterface $con |
1163
|
|
|
* @return boolean |
1164
|
|
|
*/ |
1165
|
|
|
public function preUpdate(ConnectionInterface $con = null) |
1166
|
|
|
{ |
1167
|
|
|
return true; |
1168
|
|
|
} |
1169
|
|
|
|
1170
|
|
|
/** |
1171
|
|
|
* Code to be run after updating the object in database |
1172
|
|
|
* @param ConnectionInterface $con |
1173
|
|
|
*/ |
1174
|
|
|
public function postUpdate(ConnectionInterface $con = null) |
1175
|
|
|
{ |
1176
|
|
|
|
1177
|
|
|
} |
1178
|
|
|
|
1179
|
|
|
/** |
1180
|
|
|
* Code to be run before deleting the object in database |
1181
|
|
|
* @param ConnectionInterface $con |
1182
|
|
|
* @return boolean |
1183
|
|
|
*/ |
1184
|
|
|
public function preDelete(ConnectionInterface $con = null) |
1185
|
|
|
{ |
1186
|
|
|
return true; |
1187
|
|
|
} |
1188
|
|
|
|
1189
|
|
|
/** |
1190
|
|
|
* Code to be run after deleting the object in database |
1191
|
|
|
* @param ConnectionInterface $con |
1192
|
|
|
*/ |
1193
|
|
|
public function postDelete(ConnectionInterface $con = null) |
1194
|
|
|
{ |
1195
|
|
|
|
1196
|
|
|
} |
|
|
|
|
1197
|
|
|
|
1198
|
|
|
|
1199
|
|
|
/** |
1200
|
|
|
* Derived method to catches calls to undefined methods. |
1201
|
|
|
* |
1202
|
|
|
* Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
1203
|
|
|
* Allows to define default __call() behavior if you overwrite __call() |
1204
|
|
|
* |
1205
|
|
|
* @param string $name |
1206
|
|
|
* @param mixed $params |
|
|
|
|
1207
|
|
|
* |
1208
|
|
|
* @return array|string |
1209
|
|
|
*/ |
1210
|
|
View Code Duplication |
public function __call($name, $params) |
1211
|
|
|
{ |
1212
|
|
|
if (0 === strpos($name, 'get')) { |
1213
|
|
|
$virtualColumn = substr($name, 3); |
1214
|
|
|
if ($this->hasVirtualColumn($virtualColumn)) { |
1215
|
|
|
return $this->getVirtualColumn($virtualColumn); |
1216
|
|
|
} |
1217
|
|
|
|
1218
|
|
|
$virtualColumn = lcfirst($virtualColumn); |
1219
|
|
|
if ($this->hasVirtualColumn($virtualColumn)) { |
1220
|
|
|
return $this->getVirtualColumn($virtualColumn); |
1221
|
|
|
} |
1222
|
|
|
} |
1223
|
|
|
|
1224
|
|
|
if (0 === strpos($name, 'from')) { |
1225
|
|
|
$format = substr($name, 4); |
1226
|
|
|
|
1227
|
|
|
return $this->importFrom($format, reset($params)); |
1228
|
|
|
} |
1229
|
|
|
|
1230
|
|
|
if (0 === strpos($name, 'to')) { |
1231
|
|
|
$format = substr($name, 2); |
1232
|
|
|
$includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
1233
|
|
|
|
1234
|
|
|
return $this->exportTo($format, $includeLazyLoadColumns); |
1235
|
|
|
} |
1236
|
|
|
|
1237
|
|
|
throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
1238
|
|
|
} |
1239
|
|
|
|
1240
|
|
|
} |
|
|
|
|
1241
|
|
|
|