@@ -34,1650 +34,1650 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | abstract class Channel implements ActiveRecordInterface |
| 36 | 36 | { |
| 37 | - /** |
|
| 38 | - * TableMap class name |
|
| 39 | - */ |
|
| 40 | - const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\ChannelTableMap'; |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * attribute to determine if this object has previously been saved. |
|
| 45 | - * @var boolean |
|
| 46 | - */ |
|
| 47 | - protected $new = true; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * attribute to determine whether this object has been deleted. |
|
| 51 | - * @var boolean |
|
| 52 | - */ |
|
| 53 | - protected $deleted = false; |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * The columns that have been modified in current object. |
|
| 57 | - * Tracking modified columns allows us to only update modified columns. |
|
| 58 | - * @var array |
|
| 59 | - */ |
|
| 60 | - protected $modifiedColumns = array(); |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * The (virtual) columns that are added at runtime |
|
| 64 | - * The formatters can add supplementary columns based on a resultset |
|
| 65 | - * @var array |
|
| 66 | - */ |
|
| 67 | - protected $virtualColumns = array(); |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The value for the id field. |
|
| 71 | - * |
|
| 72 | - * @var int |
|
| 73 | - */ |
|
| 74 | - protected $id; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * The value for the instance_name field. |
|
| 78 | - * |
|
| 79 | - * @var string |
|
| 80 | - */ |
|
| 81 | - protected $instance_name; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * The value for the name field. |
|
| 85 | - * |
|
| 86 | - * @var string |
|
| 87 | - */ |
|
| 88 | - protected $name; |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @var ChildInstance |
|
| 92 | - */ |
|
| 93 | - protected $aInstance; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 97 | - */ |
|
| 98 | - protected $collSubscriptions; |
|
| 99 | - protected $collSubscriptionsPartial; |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Flag to prevent endless save loop, if this object is referenced |
|
| 103 | - * by another object which falls in this transaction. |
|
| 104 | - * |
|
| 105 | - * @var boolean |
|
| 106 | - */ |
|
| 107 | - protected $alreadyInSave = false; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * An array of objects scheduled for deletion. |
|
| 111 | - * @var ObjectCollection|ChildSubscription[] |
|
| 112 | - */ |
|
| 113 | - protected $subscriptionsScheduledForDeletion = null; |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Initializes internal state of Jalle19\StatusManager\Database\Base\Channel object. |
|
| 117 | - */ |
|
| 118 | - public function __construct() |
|
| 119 | - { |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Returns whether the object has been modified. |
|
| 124 | - * |
|
| 125 | - * @return boolean True if the object has been modified. |
|
| 126 | - */ |
|
| 127 | - public function isModified() |
|
| 128 | - { |
|
| 129 | - return !!$this->modifiedColumns; |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Has specified column been modified? |
|
| 134 | - * |
|
| 135 | - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 136 | - * @return boolean True if $col has been modified. |
|
| 137 | - */ |
|
| 138 | - public function isColumnModified($col) |
|
| 139 | - { |
|
| 140 | - return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Get the columns that have been modified in this object. |
|
| 145 | - * @return array A unique list of the modified column names for this object. |
|
| 146 | - */ |
|
| 147 | - public function getModifiedColumns() |
|
| 148 | - { |
|
| 149 | - return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Returns whether the object has ever been saved. This will |
|
| 154 | - * be false, if the object was retrieved from storage or was created |
|
| 155 | - * and then saved. |
|
| 156 | - * |
|
| 157 | - * @return boolean true, if the object has never been persisted. |
|
| 158 | - */ |
|
| 159 | - public function isNew() |
|
| 160 | - { |
|
| 161 | - return $this->new; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Setter for the isNew attribute. This method will be called |
|
| 166 | - * by Propel-generated children and objects. |
|
| 167 | - * |
|
| 168 | - * @param boolean $b the state of the object. |
|
| 169 | - */ |
|
| 170 | - public function setNew($b) |
|
| 171 | - { |
|
| 172 | - $this->new = (boolean) $b; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Whether this object has been deleted. |
|
| 177 | - * @return boolean The deleted state of this object. |
|
| 178 | - */ |
|
| 179 | - public function isDeleted() |
|
| 180 | - { |
|
| 181 | - return $this->deleted; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Specify whether this object has been deleted. |
|
| 186 | - * @param boolean $b The deleted state of this object. |
|
| 187 | - * @return void |
|
| 188 | - */ |
|
| 189 | - public function setDeleted($b) |
|
| 190 | - { |
|
| 191 | - $this->deleted = (boolean) $b; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Sets the modified state for the object to be false. |
|
| 196 | - * @param string $col If supplied, only the specified column is reset. |
|
| 197 | - * @return void |
|
| 198 | - */ |
|
| 199 | - public function resetModified($col = null) |
|
| 200 | - { |
|
| 201 | - if (null !== $col) { |
|
| 202 | - if (isset($this->modifiedColumns[$col])) { |
|
| 203 | - unset($this->modifiedColumns[$col]); |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - $this->modifiedColumns = array(); |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /** |
|
| 211 | - * Compares this with another <code>Channel</code> instance. If |
|
| 212 | - * <code>obj</code> is an instance of <code>Channel</code>, delegates to |
|
| 213 | - * <code>equals(Channel)</code>. Otherwise, returns <code>false</code>. |
|
| 214 | - * |
|
| 215 | - * @param mixed $obj The object to compare to. |
|
| 216 | - * @return boolean Whether equal to the object specified. |
|
| 217 | - */ |
|
| 218 | - public function equals($obj) |
|
| 219 | - { |
|
| 220 | - if (!$obj instanceof static) { |
|
| 221 | - return false; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - if ($this === $obj) { |
|
| 225 | - return true; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 229 | - return false; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 233 | - } |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * Get the associative array of the virtual columns in this object |
|
| 237 | - * |
|
| 238 | - * @return array |
|
| 239 | - */ |
|
| 240 | - public function getVirtualColumns() |
|
| 241 | - { |
|
| 242 | - return $this->virtualColumns; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * Checks the existence of a virtual column in this object |
|
| 247 | - * |
|
| 248 | - * @param string $name The virtual column name |
|
| 249 | - * @return boolean |
|
| 250 | - */ |
|
| 251 | - public function hasVirtualColumn($name) |
|
| 252 | - { |
|
| 253 | - return array_key_exists($name, $this->virtualColumns); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * Get the value of a virtual column in this object |
|
| 258 | - * |
|
| 259 | - * @param string $name The virtual column name |
|
| 260 | - * @return mixed |
|
| 261 | - * |
|
| 262 | - * @throws PropelException |
|
| 263 | - */ |
|
| 264 | - public function getVirtualColumn($name) |
|
| 265 | - { |
|
| 266 | - if (!$this->hasVirtualColumn($name)) { |
|
| 267 | - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - return $this->virtualColumns[$name]; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Set the value of a virtual column in this object |
|
| 275 | - * |
|
| 276 | - * @param string $name The virtual column name |
|
| 277 | - * @param mixed $value The value to give to the virtual column |
|
| 278 | - * |
|
| 279 | - * @return $this|Channel The current object, for fluid interface |
|
| 280 | - */ |
|
| 281 | - public function setVirtualColumn($name, $value) |
|
| 282 | - { |
|
| 283 | - $this->virtualColumns[$name] = $value; |
|
| 284 | - |
|
| 285 | - return $this; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Logs a message using Propel::log(). |
|
| 290 | - * |
|
| 291 | - * @param string $msg |
|
| 292 | - * @param int $priority One of the Propel::LOG_* logging levels |
|
| 293 | - * @return boolean |
|
| 294 | - */ |
|
| 295 | - protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 296 | - { |
|
| 297 | - return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * Export the current object properties to a string, using a given parser format |
|
| 302 | - * <code> |
|
| 303 | - * $book = BookQuery::create()->findPk(9012); |
|
| 304 | - * echo $book->exportTo('JSON'); |
|
| 305 | - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 306 | - * </code> |
|
| 307 | - * |
|
| 308 | - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 309 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 310 | - * @return string The exported data |
|
| 311 | - */ |
|
| 312 | - public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 313 | - { |
|
| 314 | - if (!$parser instanceof AbstractParser) { |
|
| 315 | - $parser = AbstractParser::getParser($parser); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - /** |
|
| 322 | - * Clean up internal collections prior to serializing |
|
| 323 | - * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 324 | - */ |
|
| 325 | - public function __sleep() |
|
| 326 | - { |
|
| 327 | - $this->clearAllReferences(); |
|
| 328 | - |
|
| 329 | - $cls = new \ReflectionClass($this); |
|
| 330 | - $propertyNames = []; |
|
| 331 | - $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 332 | - |
|
| 333 | - foreach($serializableProperties as $property) { |
|
| 334 | - $propertyNames[] = $property->getName(); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return $propertyNames; |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Get the [id] column value. |
|
| 342 | - * |
|
| 343 | - * @return int |
|
| 344 | - */ |
|
| 345 | - public function getId() |
|
| 346 | - { |
|
| 347 | - return $this->id; |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Get the [instance_name] column value. |
|
| 352 | - * |
|
| 353 | - * @return string |
|
| 354 | - */ |
|
| 355 | - public function getInstanceName() |
|
| 356 | - { |
|
| 357 | - return $this->instance_name; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Get the [name] column value. |
|
| 362 | - * |
|
| 363 | - * @return string |
|
| 364 | - */ |
|
| 365 | - public function getName() |
|
| 366 | - { |
|
| 367 | - return $this->name; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Set the value of [id] column. |
|
| 372 | - * |
|
| 373 | - * @param int $v new value |
|
| 374 | - * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 375 | - */ |
|
| 376 | - public function setId($v) |
|
| 377 | - { |
|
| 378 | - if ($v !== null) { |
|
| 379 | - $v = (int) $v; |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - if ($this->id !== $v) { |
|
| 383 | - $this->id = $v; |
|
| 384 | - $this->modifiedColumns[ChannelTableMap::COL_ID] = true; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - return $this; |
|
| 388 | - } // setId() |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Set the value of [instance_name] column. |
|
| 392 | - * |
|
| 393 | - * @param string $v new value |
|
| 394 | - * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 395 | - */ |
|
| 396 | - public function setInstanceName($v) |
|
| 397 | - { |
|
| 398 | - if ($v !== null) { |
|
| 399 | - $v = (string) $v; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - if ($this->instance_name !== $v) { |
|
| 403 | - $this->instance_name = $v; |
|
| 404 | - $this->modifiedColumns[ChannelTableMap::COL_INSTANCE_NAME] = true; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
| 408 | - $this->aInstance = null; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - return $this; |
|
| 412 | - } // setInstanceName() |
|
| 413 | - |
|
| 414 | - /** |
|
| 415 | - * Set the value of [name] column. |
|
| 416 | - * |
|
| 417 | - * @param string $v new value |
|
| 418 | - * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 419 | - */ |
|
| 420 | - public function setName($v) |
|
| 421 | - { |
|
| 422 | - if ($v !== null) { |
|
| 423 | - $v = (string) $v; |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - if ($this->name !== $v) { |
|
| 427 | - $this->name = $v; |
|
| 428 | - $this->modifiedColumns[ChannelTableMap::COL_NAME] = true; |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - return $this; |
|
| 432 | - } // setName() |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * Indicates whether the columns in this object are only set to default values. |
|
| 436 | - * |
|
| 437 | - * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 438 | - * modified _and_ has some values set which are non-default. |
|
| 439 | - * |
|
| 440 | - * @return boolean Whether the columns in this object are only been set with default values. |
|
| 441 | - */ |
|
| 442 | - public function hasOnlyDefaultValues() |
|
| 443 | - { |
|
| 444 | - // otherwise, everything was equal, so return TRUE |
|
| 445 | - return true; |
|
| 446 | - } // hasOnlyDefaultValues() |
|
| 447 | - |
|
| 448 | - /** |
|
| 449 | - * Hydrates (populates) the object variables with values from the database resultset. |
|
| 450 | - * |
|
| 451 | - * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 452 | - * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 453 | - * for results of JOIN queries where the resultset row includes columns from two or |
|
| 454 | - * more tables. |
|
| 455 | - * |
|
| 456 | - * @param array $row The row returned by DataFetcher->fetch(). |
|
| 457 | - * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 458 | - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 459 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 37 | + /** |
|
| 38 | + * TableMap class name |
|
| 39 | + */ |
|
| 40 | + const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\ChannelTableMap'; |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * attribute to determine if this object has previously been saved. |
|
| 45 | + * @var boolean |
|
| 46 | + */ |
|
| 47 | + protected $new = true; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * attribute to determine whether this object has been deleted. |
|
| 51 | + * @var boolean |
|
| 52 | + */ |
|
| 53 | + protected $deleted = false; |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * The columns that have been modified in current object. |
|
| 57 | + * Tracking modified columns allows us to only update modified columns. |
|
| 58 | + * @var array |
|
| 59 | + */ |
|
| 60 | + protected $modifiedColumns = array(); |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * The (virtual) columns that are added at runtime |
|
| 64 | + * The formatters can add supplementary columns based on a resultset |
|
| 65 | + * @var array |
|
| 66 | + */ |
|
| 67 | + protected $virtualColumns = array(); |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The value for the id field. |
|
| 71 | + * |
|
| 72 | + * @var int |
|
| 73 | + */ |
|
| 74 | + protected $id; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * The value for the instance_name field. |
|
| 78 | + * |
|
| 79 | + * @var string |
|
| 80 | + */ |
|
| 81 | + protected $instance_name; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * The value for the name field. |
|
| 85 | + * |
|
| 86 | + * @var string |
|
| 87 | + */ |
|
| 88 | + protected $name; |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @var ChildInstance |
|
| 92 | + */ |
|
| 93 | + protected $aInstance; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 97 | + */ |
|
| 98 | + protected $collSubscriptions; |
|
| 99 | + protected $collSubscriptionsPartial; |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Flag to prevent endless save loop, if this object is referenced |
|
| 103 | + * by another object which falls in this transaction. |
|
| 104 | + * |
|
| 105 | + * @var boolean |
|
| 106 | + */ |
|
| 107 | + protected $alreadyInSave = false; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * An array of objects scheduled for deletion. |
|
| 111 | + * @var ObjectCollection|ChildSubscription[] |
|
| 112 | + */ |
|
| 113 | + protected $subscriptionsScheduledForDeletion = null; |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Initializes internal state of Jalle19\StatusManager\Database\Base\Channel object. |
|
| 117 | + */ |
|
| 118 | + public function __construct() |
|
| 119 | + { |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Returns whether the object has been modified. |
|
| 124 | + * |
|
| 125 | + * @return boolean True if the object has been modified. |
|
| 126 | + */ |
|
| 127 | + public function isModified() |
|
| 128 | + { |
|
| 129 | + return !!$this->modifiedColumns; |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Has specified column been modified? |
|
| 134 | + * |
|
| 135 | + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 136 | + * @return boolean True if $col has been modified. |
|
| 137 | + */ |
|
| 138 | + public function isColumnModified($col) |
|
| 139 | + { |
|
| 140 | + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Get the columns that have been modified in this object. |
|
| 145 | + * @return array A unique list of the modified column names for this object. |
|
| 146 | + */ |
|
| 147 | + public function getModifiedColumns() |
|
| 148 | + { |
|
| 149 | + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Returns whether the object has ever been saved. This will |
|
| 154 | + * be false, if the object was retrieved from storage or was created |
|
| 155 | + * and then saved. |
|
| 156 | + * |
|
| 157 | + * @return boolean true, if the object has never been persisted. |
|
| 158 | + */ |
|
| 159 | + public function isNew() |
|
| 160 | + { |
|
| 161 | + return $this->new; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Setter for the isNew attribute. This method will be called |
|
| 166 | + * by Propel-generated children and objects. |
|
| 167 | + * |
|
| 168 | + * @param boolean $b the state of the object. |
|
| 169 | + */ |
|
| 170 | + public function setNew($b) |
|
| 171 | + { |
|
| 172 | + $this->new = (boolean) $b; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Whether this object has been deleted. |
|
| 177 | + * @return boolean The deleted state of this object. |
|
| 178 | + */ |
|
| 179 | + public function isDeleted() |
|
| 180 | + { |
|
| 181 | + return $this->deleted; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Specify whether this object has been deleted. |
|
| 186 | + * @param boolean $b The deleted state of this object. |
|
| 187 | + * @return void |
|
| 188 | + */ |
|
| 189 | + public function setDeleted($b) |
|
| 190 | + { |
|
| 191 | + $this->deleted = (boolean) $b; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Sets the modified state for the object to be false. |
|
| 196 | + * @param string $col If supplied, only the specified column is reset. |
|
| 197 | + * @return void |
|
| 198 | + */ |
|
| 199 | + public function resetModified($col = null) |
|
| 200 | + { |
|
| 201 | + if (null !== $col) { |
|
| 202 | + if (isset($this->modifiedColumns[$col])) { |
|
| 203 | + unset($this->modifiedColumns[$col]); |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + $this->modifiedColumns = array(); |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + /** |
|
| 211 | + * Compares this with another <code>Channel</code> instance. If |
|
| 212 | + * <code>obj</code> is an instance of <code>Channel</code>, delegates to |
|
| 213 | + * <code>equals(Channel)</code>. Otherwise, returns <code>false</code>. |
|
| 214 | + * |
|
| 215 | + * @param mixed $obj The object to compare to. |
|
| 216 | + * @return boolean Whether equal to the object specified. |
|
| 217 | + */ |
|
| 218 | + public function equals($obj) |
|
| 219 | + { |
|
| 220 | + if (!$obj instanceof static) { |
|
| 221 | + return false; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + if ($this === $obj) { |
|
| 225 | + return true; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 229 | + return false; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 233 | + } |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * Get the associative array of the virtual columns in this object |
|
| 237 | + * |
|
| 238 | + * @return array |
|
| 239 | + */ |
|
| 240 | + public function getVirtualColumns() |
|
| 241 | + { |
|
| 242 | + return $this->virtualColumns; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * Checks the existence of a virtual column in this object |
|
| 247 | + * |
|
| 248 | + * @param string $name The virtual column name |
|
| 249 | + * @return boolean |
|
| 250 | + */ |
|
| 251 | + public function hasVirtualColumn($name) |
|
| 252 | + { |
|
| 253 | + return array_key_exists($name, $this->virtualColumns); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * Get the value of a virtual column in this object |
|
| 258 | + * |
|
| 259 | + * @param string $name The virtual column name |
|
| 260 | + * @return mixed |
|
| 261 | + * |
|
| 262 | + * @throws PropelException |
|
| 263 | + */ |
|
| 264 | + public function getVirtualColumn($name) |
|
| 265 | + { |
|
| 266 | + if (!$this->hasVirtualColumn($name)) { |
|
| 267 | + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + return $this->virtualColumns[$name]; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Set the value of a virtual column in this object |
|
| 275 | + * |
|
| 276 | + * @param string $name The virtual column name |
|
| 277 | + * @param mixed $value The value to give to the virtual column |
|
| 278 | + * |
|
| 279 | + * @return $this|Channel The current object, for fluid interface |
|
| 280 | + */ |
|
| 281 | + public function setVirtualColumn($name, $value) |
|
| 282 | + { |
|
| 283 | + $this->virtualColumns[$name] = $value; |
|
| 284 | + |
|
| 285 | + return $this; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Logs a message using Propel::log(). |
|
| 290 | + * |
|
| 291 | + * @param string $msg |
|
| 292 | + * @param int $priority One of the Propel::LOG_* logging levels |
|
| 293 | + * @return boolean |
|
| 294 | + */ |
|
| 295 | + protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 296 | + { |
|
| 297 | + return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * Export the current object properties to a string, using a given parser format |
|
| 302 | + * <code> |
|
| 303 | + * $book = BookQuery::create()->findPk(9012); |
|
| 304 | + * echo $book->exportTo('JSON'); |
|
| 305 | + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 306 | + * </code> |
|
| 307 | + * |
|
| 308 | + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 309 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 310 | + * @return string The exported data |
|
| 311 | + */ |
|
| 312 | + public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 313 | + { |
|
| 314 | + if (!$parser instanceof AbstractParser) { |
|
| 315 | + $parser = AbstractParser::getParser($parser); |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * Clean up internal collections prior to serializing |
|
| 323 | + * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 324 | + */ |
|
| 325 | + public function __sleep() |
|
| 326 | + { |
|
| 327 | + $this->clearAllReferences(); |
|
| 328 | + |
|
| 329 | + $cls = new \ReflectionClass($this); |
|
| 330 | + $propertyNames = []; |
|
| 331 | + $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 332 | + |
|
| 333 | + foreach($serializableProperties as $property) { |
|
| 334 | + $propertyNames[] = $property->getName(); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return $propertyNames; |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * Get the [id] column value. |
|
| 342 | + * |
|
| 343 | + * @return int |
|
| 344 | + */ |
|
| 345 | + public function getId() |
|
| 346 | + { |
|
| 347 | + return $this->id; |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * Get the [instance_name] column value. |
|
| 352 | + * |
|
| 353 | + * @return string |
|
| 354 | + */ |
|
| 355 | + public function getInstanceName() |
|
| 356 | + { |
|
| 357 | + return $this->instance_name; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Get the [name] column value. |
|
| 362 | + * |
|
| 363 | + * @return string |
|
| 364 | + */ |
|
| 365 | + public function getName() |
|
| 366 | + { |
|
| 367 | + return $this->name; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Set the value of [id] column. |
|
| 372 | + * |
|
| 373 | + * @param int $v new value |
|
| 374 | + * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 375 | + */ |
|
| 376 | + public function setId($v) |
|
| 377 | + { |
|
| 378 | + if ($v !== null) { |
|
| 379 | + $v = (int) $v; |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + if ($this->id !== $v) { |
|
| 383 | + $this->id = $v; |
|
| 384 | + $this->modifiedColumns[ChannelTableMap::COL_ID] = true; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + return $this; |
|
| 388 | + } // setId() |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Set the value of [instance_name] column. |
|
| 392 | + * |
|
| 393 | + * @param string $v new value |
|
| 394 | + * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 395 | + */ |
|
| 396 | + public function setInstanceName($v) |
|
| 397 | + { |
|
| 398 | + if ($v !== null) { |
|
| 399 | + $v = (string) $v; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + if ($this->instance_name !== $v) { |
|
| 403 | + $this->instance_name = $v; |
|
| 404 | + $this->modifiedColumns[ChannelTableMap::COL_INSTANCE_NAME] = true; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
| 408 | + $this->aInstance = null; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return $this; |
|
| 412 | + } // setInstanceName() |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * Set the value of [name] column. |
|
| 416 | + * |
|
| 417 | + * @param string $v new value |
|
| 418 | + * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 419 | + */ |
|
| 420 | + public function setName($v) |
|
| 421 | + { |
|
| 422 | + if ($v !== null) { |
|
| 423 | + $v = (string) $v; |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + if ($this->name !== $v) { |
|
| 427 | + $this->name = $v; |
|
| 428 | + $this->modifiedColumns[ChannelTableMap::COL_NAME] = true; |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + return $this; |
|
| 432 | + } // setName() |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * Indicates whether the columns in this object are only set to default values. |
|
| 436 | + * |
|
| 437 | + * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 438 | + * modified _and_ has some values set which are non-default. |
|
| 439 | + * |
|
| 440 | + * @return boolean Whether the columns in this object are only been set with default values. |
|
| 441 | + */ |
|
| 442 | + public function hasOnlyDefaultValues() |
|
| 443 | + { |
|
| 444 | + // otherwise, everything was equal, so return TRUE |
|
| 445 | + return true; |
|
| 446 | + } // hasOnlyDefaultValues() |
|
| 447 | + |
|
| 448 | + /** |
|
| 449 | + * Hydrates (populates) the object variables with values from the database resultset. |
|
| 450 | + * |
|
| 451 | + * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 452 | + * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 453 | + * for results of JOIN queries where the resultset row includes columns from two or |
|
| 454 | + * more tables. |
|
| 455 | + * |
|
| 456 | + * @param array $row The row returned by DataFetcher->fetch(). |
|
| 457 | + * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 458 | + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 459 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 460 | 460 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
| 461 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 462 | - * |
|
| 463 | - * @return int next starting column |
|
| 464 | - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 465 | - */ |
|
| 466 | - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 467 | - { |
|
| 468 | - try { |
|
| 469 | - |
|
| 470 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ChannelTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 471 | - $this->id = (null !== $col) ? (int) $col : null; |
|
| 472 | - |
|
| 473 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ChannelTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 474 | - $this->instance_name = (null !== $col) ? (string) $col : null; |
|
| 475 | - |
|
| 476 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ChannelTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 477 | - $this->name = (null !== $col) ? (string) $col : null; |
|
| 478 | - $this->resetModified(); |
|
| 479 | - |
|
| 480 | - $this->setNew(false); |
|
| 481 | - |
|
| 482 | - if ($rehydrate) { |
|
| 483 | - $this->ensureConsistency(); |
|
| 484 | - } |
|
| 485 | - |
|
| 486 | - return $startcol + 3; // 3 = ChannelTableMap::NUM_HYDRATE_COLUMNS. |
|
| 487 | - |
|
| 488 | - } catch (Exception $e) { |
|
| 489 | - throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Channel'), 0, $e); |
|
| 490 | - } |
|
| 491 | - } |
|
| 492 | - |
|
| 493 | - /** |
|
| 494 | - * Checks and repairs the internal consistency of the object. |
|
| 495 | - * |
|
| 496 | - * This method is executed after an already-instantiated object is re-hydrated |
|
| 497 | - * from the database. It exists to check any foreign keys to make sure that |
|
| 498 | - * the objects related to the current object are correct based on foreign key. |
|
| 499 | - * |
|
| 500 | - * You can override this method in the stub class, but you should always invoke |
|
| 501 | - * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 502 | - * in case your model changes. |
|
| 503 | - * |
|
| 504 | - * @throws PropelException |
|
| 505 | - */ |
|
| 506 | - public function ensureConsistency() |
|
| 507 | - { |
|
| 508 | - if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
| 509 | - $this->aInstance = null; |
|
| 510 | - } |
|
| 511 | - } // ensureConsistency |
|
| 512 | - |
|
| 513 | - /** |
|
| 514 | - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 515 | - * |
|
| 516 | - * This will only work if the object has been saved and has a valid primary key set. |
|
| 517 | - * |
|
| 518 | - * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 519 | - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 520 | - * @return void |
|
| 521 | - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 522 | - */ |
|
| 523 | - public function reload($deep = false, ConnectionInterface $con = null) |
|
| 524 | - { |
|
| 525 | - if ($this->isDeleted()) { |
|
| 526 | - throw new PropelException("Cannot reload a deleted object."); |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - if ($this->isNew()) { |
|
| 530 | - throw new PropelException("Cannot reload an unsaved object."); |
|
| 531 | - } |
|
| 532 | - |
|
| 533 | - if ($con === null) { |
|
| 534 | - $con = Propel::getServiceContainer()->getReadConnection(ChannelTableMap::DATABASE_NAME); |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 538 | - // already in the pool. |
|
| 539 | - |
|
| 540 | - $dataFetcher = ChildChannelQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 541 | - $row = $dataFetcher->fetch(); |
|
| 542 | - $dataFetcher->close(); |
|
| 543 | - if (!$row) { |
|
| 544 | - throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 545 | - } |
|
| 546 | - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 547 | - |
|
| 548 | - if ($deep) { // also de-associate any related objects? |
|
| 549 | - |
|
| 550 | - $this->aInstance = null; |
|
| 551 | - $this->collSubscriptions = null; |
|
| 552 | - |
|
| 553 | - } // if (deep) |
|
| 554 | - } |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * Removes this object from datastore and sets delete attribute. |
|
| 558 | - * |
|
| 559 | - * @param ConnectionInterface $con |
|
| 560 | - * @return void |
|
| 561 | - * @throws PropelException |
|
| 562 | - * @see Channel::setDeleted() |
|
| 563 | - * @see Channel::isDeleted() |
|
| 564 | - */ |
|
| 565 | - public function delete(ConnectionInterface $con = null) |
|
| 566 | - { |
|
| 567 | - if ($this->isDeleted()) { |
|
| 568 | - throw new PropelException("This object has already been deleted."); |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - if ($con === null) { |
|
| 572 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - $con->transaction(function () use ($con) { |
|
| 576 | - $deleteQuery = ChildChannelQuery::create() |
|
| 577 | - ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 578 | - $ret = $this->preDelete($con); |
|
| 579 | - if ($ret) { |
|
| 580 | - $deleteQuery->delete($con); |
|
| 581 | - $this->postDelete($con); |
|
| 582 | - $this->setDeleted(true); |
|
| 583 | - } |
|
| 584 | - }); |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Persists this object to the database. |
|
| 589 | - * |
|
| 590 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 591 | - * All modified related objects will also be persisted in the doSave() |
|
| 592 | - * method. This method wraps all precipitate database operations in a |
|
| 593 | - * single transaction. |
|
| 594 | - * |
|
| 595 | - * @param ConnectionInterface $con |
|
| 596 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 597 | - * @throws PropelException |
|
| 598 | - * @see doSave() |
|
| 599 | - */ |
|
| 600 | - public function save(ConnectionInterface $con = null) |
|
| 601 | - { |
|
| 602 | - if ($this->isDeleted()) { |
|
| 603 | - throw new PropelException("You cannot save an object that has been deleted."); |
|
| 604 | - } |
|
| 605 | - |
|
| 606 | - if ($con === null) { |
|
| 607 | - $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - return $con->transaction(function () use ($con) { |
|
| 611 | - $isInsert = $this->isNew(); |
|
| 612 | - $ret = $this->preSave($con); |
|
| 613 | - if ($isInsert) { |
|
| 614 | - $ret = $ret && $this->preInsert($con); |
|
| 615 | - } else { |
|
| 616 | - $ret = $ret && $this->preUpdate($con); |
|
| 617 | - } |
|
| 618 | - if ($ret) { |
|
| 619 | - $affectedRows = $this->doSave($con); |
|
| 620 | - if ($isInsert) { |
|
| 621 | - $this->postInsert($con); |
|
| 622 | - } else { |
|
| 623 | - $this->postUpdate($con); |
|
| 624 | - } |
|
| 625 | - $this->postSave($con); |
|
| 626 | - ChannelTableMap::addInstanceToPool($this); |
|
| 627 | - } else { |
|
| 628 | - $affectedRows = 0; |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - return $affectedRows; |
|
| 632 | - }); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - /** |
|
| 636 | - * Performs the work of inserting or updating the row in the database. |
|
| 637 | - * |
|
| 638 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 639 | - * All related objects are also updated in this method. |
|
| 640 | - * |
|
| 641 | - * @param ConnectionInterface $con |
|
| 642 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 643 | - * @throws PropelException |
|
| 644 | - * @see save() |
|
| 645 | - */ |
|
| 646 | - protected function doSave(ConnectionInterface $con) |
|
| 647 | - { |
|
| 648 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 649 | - if (!$this->alreadyInSave) { |
|
| 650 | - $this->alreadyInSave = true; |
|
| 651 | - |
|
| 652 | - // We call the save method on the following object(s) if they |
|
| 653 | - // were passed to this object by their corresponding set |
|
| 654 | - // method. This object relates to these object(s) by a |
|
| 655 | - // foreign key reference. |
|
| 656 | - |
|
| 657 | - if ($this->aInstance !== null) { |
|
| 658 | - if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
| 659 | - $affectedRows += $this->aInstance->save($con); |
|
| 660 | - } |
|
| 661 | - $this->setInstance($this->aInstance); |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - if ($this->isNew() || $this->isModified()) { |
|
| 665 | - // persist changes |
|
| 666 | - if ($this->isNew()) { |
|
| 667 | - $this->doInsert($con); |
|
| 668 | - $affectedRows += 1; |
|
| 669 | - } else { |
|
| 670 | - $affectedRows += $this->doUpdate($con); |
|
| 671 | - } |
|
| 672 | - $this->resetModified(); |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 676 | - if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 677 | - \Jalle19\StatusManager\Database\SubscriptionQuery::create() |
|
| 678 | - ->filterByPrimaryKeys($this->subscriptionsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 679 | - ->delete($con); |
|
| 680 | - $this->subscriptionsScheduledForDeletion = null; |
|
| 681 | - } |
|
| 682 | - } |
|
| 683 | - |
|
| 684 | - if ($this->collSubscriptions !== null) { |
|
| 685 | - foreach ($this->collSubscriptions as $referrerFK) { |
|
| 686 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 687 | - $affectedRows += $referrerFK->save($con); |
|
| 688 | - } |
|
| 689 | - } |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - $this->alreadyInSave = false; |
|
| 693 | - |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - return $affectedRows; |
|
| 697 | - } // doSave() |
|
| 698 | - |
|
| 699 | - /** |
|
| 700 | - * Insert the row in the database. |
|
| 701 | - * |
|
| 702 | - * @param ConnectionInterface $con |
|
| 703 | - * |
|
| 704 | - * @throws PropelException |
|
| 705 | - * @see doSave() |
|
| 706 | - */ |
|
| 707 | - protected function doInsert(ConnectionInterface $con) |
|
| 708 | - { |
|
| 709 | - $modifiedColumns = array(); |
|
| 710 | - $index = 0; |
|
| 711 | - |
|
| 712 | - $this->modifiedColumns[ChannelTableMap::COL_ID] = true; |
|
| 713 | - if (null !== $this->id) { |
|
| 714 | - throw new PropelException('Cannot insert a value for auto-increment primary key (' . ChannelTableMap::COL_ID . ')'); |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - // check the columns in natural order for more readable SQL queries |
|
| 718 | - if ($this->isColumnModified(ChannelTableMap::COL_ID)) { |
|
| 719 | - $modifiedColumns[':p' . $index++] = 'id'; |
|
| 720 | - } |
|
| 721 | - if ($this->isColumnModified(ChannelTableMap::COL_INSTANCE_NAME)) { |
|
| 722 | - $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
| 723 | - } |
|
| 724 | - if ($this->isColumnModified(ChannelTableMap::COL_NAME)) { |
|
| 725 | - $modifiedColumns[':p' . $index++] = 'name'; |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - $sql = sprintf( |
|
| 729 | - 'INSERT INTO channel (%s) VALUES (%s)', |
|
| 730 | - implode(', ', $modifiedColumns), |
|
| 731 | - implode(', ', array_keys($modifiedColumns)) |
|
| 732 | - ); |
|
| 733 | - |
|
| 734 | - try { |
|
| 735 | - $stmt = $con->prepare($sql); |
|
| 736 | - foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 737 | - switch ($columnName) { |
|
| 738 | - case 'id': |
|
| 739 | - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
| 740 | - break; |
|
| 741 | - case 'instance_name': |
|
| 742 | - $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
| 743 | - break; |
|
| 744 | - case 'name': |
|
| 745 | - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
|
| 746 | - break; |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - $stmt->execute(); |
|
| 750 | - } catch (Exception $e) { |
|
| 751 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 752 | - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 753 | - } |
|
| 754 | - |
|
| 755 | - try { |
|
| 756 | - $pk = $con->lastInsertId(); |
|
| 757 | - } catch (Exception $e) { |
|
| 758 | - throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
| 759 | - } |
|
| 760 | - $this->setId($pk); |
|
| 761 | - |
|
| 762 | - $this->setNew(false); |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - /** |
|
| 766 | - * Update the row in the database. |
|
| 767 | - * |
|
| 768 | - * @param ConnectionInterface $con |
|
| 769 | - * |
|
| 770 | - * @return Integer Number of updated rows |
|
| 771 | - * @see doSave() |
|
| 772 | - */ |
|
| 773 | - protected function doUpdate(ConnectionInterface $con) |
|
| 774 | - { |
|
| 775 | - $selectCriteria = $this->buildPkeyCriteria(); |
|
| 776 | - $valuesCriteria = $this->buildCriteria(); |
|
| 777 | - |
|
| 778 | - return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - /** |
|
| 782 | - * Retrieves a field from the object by name passed in as a string. |
|
| 783 | - * |
|
| 784 | - * @param string $name name |
|
| 785 | - * @param string $type The type of fieldname the $name is of: |
|
| 786 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 787 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 788 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 789 | - * @return mixed Value of field. |
|
| 790 | - */ |
|
| 791 | - public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 792 | - { |
|
| 793 | - $pos = ChannelTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 794 | - $field = $this->getByPosition($pos); |
|
| 795 | - |
|
| 796 | - return $field; |
|
| 797 | - } |
|
| 798 | - |
|
| 799 | - /** |
|
| 800 | - * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 801 | - * Zero-based. |
|
| 802 | - * |
|
| 803 | - * @param int $pos position in xml schema |
|
| 804 | - * @return mixed Value of field at $pos |
|
| 805 | - */ |
|
| 806 | - public function getByPosition($pos) |
|
| 807 | - { |
|
| 808 | - switch ($pos) { |
|
| 809 | - case 0: |
|
| 810 | - return $this->getId(); |
|
| 811 | - break; |
|
| 812 | - case 1: |
|
| 813 | - return $this->getInstanceName(); |
|
| 814 | - break; |
|
| 815 | - case 2: |
|
| 816 | - return $this->getName(); |
|
| 817 | - break; |
|
| 818 | - default: |
|
| 819 | - return null; |
|
| 820 | - break; |
|
| 821 | - } // switch() |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - /** |
|
| 825 | - * Exports the object as an array. |
|
| 826 | - * |
|
| 827 | - * You can specify the key type of the array by passing one of the class |
|
| 828 | - * type constants. |
|
| 829 | - * |
|
| 830 | - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 831 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 832 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 833 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 834 | - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 835 | - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 836 | - * |
|
| 837 | - * @return array an associative array containing the field names (as keys) and field values |
|
| 838 | - */ |
|
| 839 | - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 840 | - { |
|
| 841 | - |
|
| 842 | - if (isset($alreadyDumpedObjects['Channel'][$this->hashCode()])) { |
|
| 843 | - return '*RECURSION*'; |
|
| 844 | - } |
|
| 845 | - $alreadyDumpedObjects['Channel'][$this->hashCode()] = true; |
|
| 846 | - $keys = ChannelTableMap::getFieldNames($keyType); |
|
| 847 | - $result = array( |
|
| 848 | - $keys[0] => $this->getId(), |
|
| 849 | - $keys[1] => $this->getInstanceName(), |
|
| 850 | - $keys[2] => $this->getName(), |
|
| 851 | - ); |
|
| 852 | - $virtualColumns = $this->virtualColumns; |
|
| 853 | - foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 854 | - $result[$key] = $virtualColumn; |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - if ($includeForeignObjects) { |
|
| 858 | - if (null !== $this->aInstance) { |
|
| 859 | - |
|
| 860 | - switch ($keyType) { |
|
| 861 | - case TableMap::TYPE_CAMELNAME: |
|
| 862 | - $key = 'instance'; |
|
| 863 | - break; |
|
| 864 | - case TableMap::TYPE_FIELDNAME: |
|
| 865 | - $key = 'instance'; |
|
| 866 | - break; |
|
| 867 | - default: |
|
| 868 | - $key = 'Instance'; |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
| 872 | - } |
|
| 873 | - if (null !== $this->collSubscriptions) { |
|
| 874 | - |
|
| 875 | - switch ($keyType) { |
|
| 876 | - case TableMap::TYPE_CAMELNAME: |
|
| 877 | - $key = 'subscriptions'; |
|
| 878 | - break; |
|
| 879 | - case TableMap::TYPE_FIELDNAME: |
|
| 880 | - $key = 'subscriptions'; |
|
| 881 | - break; |
|
| 882 | - default: |
|
| 883 | - $key = 'Subscriptions'; |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 887 | - } |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - return $result; |
|
| 891 | - } |
|
| 892 | - |
|
| 893 | - /** |
|
| 894 | - * Sets a field from the object by name passed in as a string. |
|
| 895 | - * |
|
| 896 | - * @param string $name |
|
| 897 | - * @param mixed $value field value |
|
| 898 | - * @param string $type The type of fieldname the $name is of: |
|
| 899 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 900 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 901 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 902 | - * @return $this|\Jalle19\StatusManager\Database\Channel |
|
| 903 | - */ |
|
| 904 | - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 905 | - { |
|
| 906 | - $pos = ChannelTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 907 | - |
|
| 908 | - return $this->setByPosition($pos, $value); |
|
| 909 | - } |
|
| 910 | - |
|
| 911 | - /** |
|
| 912 | - * Sets a field from the object by Position as specified in the xml schema. |
|
| 913 | - * Zero-based. |
|
| 914 | - * |
|
| 915 | - * @param int $pos position in xml schema |
|
| 916 | - * @param mixed $value field value |
|
| 917 | - * @return $this|\Jalle19\StatusManager\Database\Channel |
|
| 918 | - */ |
|
| 919 | - public function setByPosition($pos, $value) |
|
| 920 | - { |
|
| 921 | - switch ($pos) { |
|
| 922 | - case 0: |
|
| 923 | - $this->setId($value); |
|
| 924 | - break; |
|
| 925 | - case 1: |
|
| 926 | - $this->setInstanceName($value); |
|
| 927 | - break; |
|
| 928 | - case 2: |
|
| 929 | - $this->setName($value); |
|
| 930 | - break; |
|
| 931 | - } // switch() |
|
| 932 | - |
|
| 933 | - return $this; |
|
| 934 | - } |
|
| 935 | - |
|
| 936 | - /** |
|
| 937 | - * Populates the object using an array. |
|
| 938 | - * |
|
| 939 | - * This is particularly useful when populating an object from one of the |
|
| 940 | - * request arrays (e.g. $_POST). This method goes through the column |
|
| 941 | - * names, checking to see whether a matching key exists in populated |
|
| 942 | - * array. If so the setByName() method is called for that column. |
|
| 943 | - * |
|
| 944 | - * You can specify the key type of the array by additionally passing one |
|
| 945 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 946 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 947 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 948 | - * |
|
| 949 | - * @param array $arr An array to populate the object from. |
|
| 950 | - * @param string $keyType The type of keys the array uses. |
|
| 951 | - * @return void |
|
| 952 | - */ |
|
| 953 | - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 954 | - { |
|
| 955 | - $keys = ChannelTableMap::getFieldNames($keyType); |
|
| 956 | - |
|
| 957 | - if (array_key_exists($keys[0], $arr)) { |
|
| 958 | - $this->setId($arr[$keys[0]]); |
|
| 959 | - } |
|
| 960 | - if (array_key_exists($keys[1], $arr)) { |
|
| 961 | - $this->setInstanceName($arr[$keys[1]]); |
|
| 962 | - } |
|
| 963 | - if (array_key_exists($keys[2], $arr)) { |
|
| 964 | - $this->setName($arr[$keys[2]]); |
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - /** |
|
| 969 | - * Populate the current object from a string, using a given parser format |
|
| 970 | - * <code> |
|
| 971 | - * $book = new Book(); |
|
| 972 | - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 973 | - * </code> |
|
| 974 | - * |
|
| 975 | - * You can specify the key type of the array by additionally passing one |
|
| 976 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 977 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 978 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 979 | - * |
|
| 980 | - * @param mixed $parser A AbstractParser instance, |
|
| 981 | - * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 982 | - * @param string $data The source data to import from |
|
| 983 | - * @param string $keyType The type of keys the array uses. |
|
| 984 | - * |
|
| 985 | - * @return $this|\Jalle19\StatusManager\Database\Channel The current object, for fluid interface |
|
| 986 | - */ |
|
| 987 | - public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 988 | - { |
|
| 989 | - if (!$parser instanceof AbstractParser) { |
|
| 990 | - $parser = AbstractParser::getParser($parser); |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - $this->fromArray($parser->toArray($data), $keyType); |
|
| 994 | - |
|
| 995 | - return $this; |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - /** |
|
| 999 | - * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1000 | - * |
|
| 1001 | - * @return Criteria The Criteria object containing all modified values. |
|
| 1002 | - */ |
|
| 1003 | - public function buildCriteria() |
|
| 1004 | - { |
|
| 1005 | - $criteria = new Criteria(ChannelTableMap::DATABASE_NAME); |
|
| 1006 | - |
|
| 1007 | - if ($this->isColumnModified(ChannelTableMap::COL_ID)) { |
|
| 1008 | - $criteria->add(ChannelTableMap::COL_ID, $this->id); |
|
| 1009 | - } |
|
| 1010 | - if ($this->isColumnModified(ChannelTableMap::COL_INSTANCE_NAME)) { |
|
| 1011 | - $criteria->add(ChannelTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
| 1012 | - } |
|
| 1013 | - if ($this->isColumnModified(ChannelTableMap::COL_NAME)) { |
|
| 1014 | - $criteria->add(ChannelTableMap::COL_NAME, $this->name); |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - return $criteria; |
|
| 1018 | - } |
|
| 1019 | - |
|
| 1020 | - /** |
|
| 1021 | - * Builds a Criteria object containing the primary key for this object. |
|
| 1022 | - * |
|
| 1023 | - * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1024 | - * of whether or not they have been modified. |
|
| 1025 | - * |
|
| 1026 | - * @throws LogicException if no primary key is defined |
|
| 1027 | - * |
|
| 1028 | - * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1029 | - */ |
|
| 1030 | - public function buildPkeyCriteria() |
|
| 1031 | - { |
|
| 1032 | - $criteria = ChildChannelQuery::create(); |
|
| 1033 | - $criteria->add(ChannelTableMap::COL_ID, $this->id); |
|
| 1034 | - |
|
| 1035 | - return $criteria; |
|
| 1036 | - } |
|
| 1037 | - |
|
| 1038 | - /** |
|
| 1039 | - * If the primary key is not null, return the hashcode of the |
|
| 1040 | - * primary key. Otherwise, return the hash code of the object. |
|
| 1041 | - * |
|
| 1042 | - * @return int Hashcode |
|
| 1043 | - */ |
|
| 1044 | - public function hashCode() |
|
| 1045 | - { |
|
| 1046 | - $validPk = null !== $this->getId(); |
|
| 1047 | - |
|
| 1048 | - $validPrimaryKeyFKs = 0; |
|
| 1049 | - $primaryKeyFKs = []; |
|
| 1050 | - |
|
| 1051 | - if ($validPk) { |
|
| 1052 | - return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1053 | - } elseif ($validPrimaryKeyFKs) { |
|
| 1054 | - return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1055 | - } |
|
| 1056 | - |
|
| 1057 | - return spl_object_hash($this); |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - /** |
|
| 1061 | - * Returns the primary key for this object (row). |
|
| 1062 | - * @return int |
|
| 1063 | - */ |
|
| 1064 | - public function getPrimaryKey() |
|
| 1065 | - { |
|
| 1066 | - return $this->getId(); |
|
| 1067 | - } |
|
| 1068 | - |
|
| 1069 | - /** |
|
| 1070 | - * Generic method to set the primary key (id column). |
|
| 1071 | - * |
|
| 1072 | - * @param int $key Primary key. |
|
| 1073 | - * @return void |
|
| 1074 | - */ |
|
| 1075 | - public function setPrimaryKey($key) |
|
| 1076 | - { |
|
| 1077 | - $this->setId($key); |
|
| 1078 | - } |
|
| 1079 | - |
|
| 1080 | - /** |
|
| 1081 | - * Returns true if the primary key for this object is null. |
|
| 1082 | - * @return boolean |
|
| 1083 | - */ |
|
| 1084 | - public function isPrimaryKeyNull() |
|
| 1085 | - { |
|
| 1086 | - return null === $this->getId(); |
|
| 1087 | - } |
|
| 1088 | - |
|
| 1089 | - /** |
|
| 1090 | - * Sets contents of passed object to values from current object. |
|
| 1091 | - * |
|
| 1092 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1093 | - * objects. |
|
| 1094 | - * |
|
| 1095 | - * @param object $copyObj An object of \Jalle19\StatusManager\Database\Channel (or compatible) type. |
|
| 1096 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1097 | - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1098 | - * @throws PropelException |
|
| 1099 | - */ |
|
| 1100 | - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1101 | - { |
|
| 1102 | - $copyObj->setInstanceName($this->getInstanceName()); |
|
| 1103 | - $copyObj->setName($this->getName()); |
|
| 1104 | - |
|
| 1105 | - if ($deepCopy) { |
|
| 1106 | - // important: temporarily setNew(false) because this affects the behavior of |
|
| 1107 | - // the getter/setter methods for fkey referrer objects. |
|
| 1108 | - $copyObj->setNew(false); |
|
| 1109 | - |
|
| 1110 | - foreach ($this->getSubscriptions() as $relObj) { |
|
| 1111 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1112 | - $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1113 | - } |
|
| 1114 | - } |
|
| 1115 | - |
|
| 1116 | - } // if ($deepCopy) |
|
| 1117 | - |
|
| 1118 | - if ($makeNew) { |
|
| 1119 | - $copyObj->setNew(true); |
|
| 1120 | - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
|
| 1121 | - } |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - /** |
|
| 1125 | - * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1126 | - * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1127 | - * keys that are defined for the table. |
|
| 1128 | - * |
|
| 1129 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1130 | - * objects. |
|
| 1131 | - * |
|
| 1132 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1133 | - * @return \Jalle19\StatusManager\Database\Channel Clone of current object. |
|
| 1134 | - * @throws PropelException |
|
| 1135 | - */ |
|
| 1136 | - public function copy($deepCopy = false) |
|
| 1137 | - { |
|
| 1138 | - // we use get_class(), because this might be a subclass |
|
| 1139 | - $clazz = get_class($this); |
|
| 1140 | - $copyObj = new $clazz(); |
|
| 1141 | - $this->copyInto($copyObj, $deepCopy); |
|
| 1142 | - |
|
| 1143 | - return $copyObj; |
|
| 1144 | - } |
|
| 1145 | - |
|
| 1146 | - /** |
|
| 1147 | - * Declares an association between this object and a ChildInstance object. |
|
| 1148 | - * |
|
| 1149 | - * @param ChildInstance $v |
|
| 1150 | - * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 1151 | - * @throws PropelException |
|
| 1152 | - */ |
|
| 1153 | - public function setInstance(ChildInstance $v = null) |
|
| 1154 | - { |
|
| 1155 | - if ($v === null) { |
|
| 1156 | - $this->setInstanceName(NULL); |
|
| 1157 | - } else { |
|
| 1158 | - $this->setInstanceName($v->getName()); |
|
| 1159 | - } |
|
| 1160 | - |
|
| 1161 | - $this->aInstance = $v; |
|
| 1162 | - |
|
| 1163 | - // Add binding for other direction of this n:n relationship. |
|
| 1164 | - // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
| 1165 | - if ($v !== null) { |
|
| 1166 | - $v->addChannel($this); |
|
| 1167 | - } |
|
| 1168 | - |
|
| 1169 | - |
|
| 1170 | - return $this; |
|
| 1171 | - } |
|
| 1172 | - |
|
| 1173 | - |
|
| 1174 | - /** |
|
| 1175 | - * Get the associated ChildInstance object |
|
| 1176 | - * |
|
| 1177 | - * @param ConnectionInterface $con Optional Connection object. |
|
| 1178 | - * @return ChildInstance The associated ChildInstance object. |
|
| 1179 | - * @throws PropelException |
|
| 1180 | - */ |
|
| 1181 | - public function getInstance(ConnectionInterface $con = null) |
|
| 1182 | - { |
|
| 1183 | - if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
| 1184 | - $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
| 1185 | - /* The following can be used additionally to |
|
| 461 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 462 | + * |
|
| 463 | + * @return int next starting column |
|
| 464 | + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 465 | + */ |
|
| 466 | + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 467 | + { |
|
| 468 | + try { |
|
| 469 | + |
|
| 470 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ChannelTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 471 | + $this->id = (null !== $col) ? (int) $col : null; |
|
| 472 | + |
|
| 473 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ChannelTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 474 | + $this->instance_name = (null !== $col) ? (string) $col : null; |
|
| 475 | + |
|
| 476 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ChannelTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 477 | + $this->name = (null !== $col) ? (string) $col : null; |
|
| 478 | + $this->resetModified(); |
|
| 479 | + |
|
| 480 | + $this->setNew(false); |
|
| 481 | + |
|
| 482 | + if ($rehydrate) { |
|
| 483 | + $this->ensureConsistency(); |
|
| 484 | + } |
|
| 485 | + |
|
| 486 | + return $startcol + 3; // 3 = ChannelTableMap::NUM_HYDRATE_COLUMNS. |
|
| 487 | + |
|
| 488 | + } catch (Exception $e) { |
|
| 489 | + throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Channel'), 0, $e); |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * Checks and repairs the internal consistency of the object. |
|
| 495 | + * |
|
| 496 | + * This method is executed after an already-instantiated object is re-hydrated |
|
| 497 | + * from the database. It exists to check any foreign keys to make sure that |
|
| 498 | + * the objects related to the current object are correct based on foreign key. |
|
| 499 | + * |
|
| 500 | + * You can override this method in the stub class, but you should always invoke |
|
| 501 | + * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 502 | + * in case your model changes. |
|
| 503 | + * |
|
| 504 | + * @throws PropelException |
|
| 505 | + */ |
|
| 506 | + public function ensureConsistency() |
|
| 507 | + { |
|
| 508 | + if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
| 509 | + $this->aInstance = null; |
|
| 510 | + } |
|
| 511 | + } // ensureConsistency |
|
| 512 | + |
|
| 513 | + /** |
|
| 514 | + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 515 | + * |
|
| 516 | + * This will only work if the object has been saved and has a valid primary key set. |
|
| 517 | + * |
|
| 518 | + * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 519 | + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 520 | + * @return void |
|
| 521 | + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 522 | + */ |
|
| 523 | + public function reload($deep = false, ConnectionInterface $con = null) |
|
| 524 | + { |
|
| 525 | + if ($this->isDeleted()) { |
|
| 526 | + throw new PropelException("Cannot reload a deleted object."); |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + if ($this->isNew()) { |
|
| 530 | + throw new PropelException("Cannot reload an unsaved object."); |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + if ($con === null) { |
|
| 534 | + $con = Propel::getServiceContainer()->getReadConnection(ChannelTableMap::DATABASE_NAME); |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 538 | + // already in the pool. |
|
| 539 | + |
|
| 540 | + $dataFetcher = ChildChannelQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 541 | + $row = $dataFetcher->fetch(); |
|
| 542 | + $dataFetcher->close(); |
|
| 543 | + if (!$row) { |
|
| 544 | + throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 545 | + } |
|
| 546 | + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 547 | + |
|
| 548 | + if ($deep) { // also de-associate any related objects? |
|
| 549 | + |
|
| 550 | + $this->aInstance = null; |
|
| 551 | + $this->collSubscriptions = null; |
|
| 552 | + |
|
| 553 | + } // if (deep) |
|
| 554 | + } |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * Removes this object from datastore and sets delete attribute. |
|
| 558 | + * |
|
| 559 | + * @param ConnectionInterface $con |
|
| 560 | + * @return void |
|
| 561 | + * @throws PropelException |
|
| 562 | + * @see Channel::setDeleted() |
|
| 563 | + * @see Channel::isDeleted() |
|
| 564 | + */ |
|
| 565 | + public function delete(ConnectionInterface $con = null) |
|
| 566 | + { |
|
| 567 | + if ($this->isDeleted()) { |
|
| 568 | + throw new PropelException("This object has already been deleted."); |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + if ($con === null) { |
|
| 572 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + $con->transaction(function () use ($con) { |
|
| 576 | + $deleteQuery = ChildChannelQuery::create() |
|
| 577 | + ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 578 | + $ret = $this->preDelete($con); |
|
| 579 | + if ($ret) { |
|
| 580 | + $deleteQuery->delete($con); |
|
| 581 | + $this->postDelete($con); |
|
| 582 | + $this->setDeleted(true); |
|
| 583 | + } |
|
| 584 | + }); |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + /** |
|
| 588 | + * Persists this object to the database. |
|
| 589 | + * |
|
| 590 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 591 | + * All modified related objects will also be persisted in the doSave() |
|
| 592 | + * method. This method wraps all precipitate database operations in a |
|
| 593 | + * single transaction. |
|
| 594 | + * |
|
| 595 | + * @param ConnectionInterface $con |
|
| 596 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 597 | + * @throws PropelException |
|
| 598 | + * @see doSave() |
|
| 599 | + */ |
|
| 600 | + public function save(ConnectionInterface $con = null) |
|
| 601 | + { |
|
| 602 | + if ($this->isDeleted()) { |
|
| 603 | + throw new PropelException("You cannot save an object that has been deleted."); |
|
| 604 | + } |
|
| 605 | + |
|
| 606 | + if ($con === null) { |
|
| 607 | + $con = Propel::getServiceContainer()->getWriteConnection(ChannelTableMap::DATABASE_NAME); |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + return $con->transaction(function () use ($con) { |
|
| 611 | + $isInsert = $this->isNew(); |
|
| 612 | + $ret = $this->preSave($con); |
|
| 613 | + if ($isInsert) { |
|
| 614 | + $ret = $ret && $this->preInsert($con); |
|
| 615 | + } else { |
|
| 616 | + $ret = $ret && $this->preUpdate($con); |
|
| 617 | + } |
|
| 618 | + if ($ret) { |
|
| 619 | + $affectedRows = $this->doSave($con); |
|
| 620 | + if ($isInsert) { |
|
| 621 | + $this->postInsert($con); |
|
| 622 | + } else { |
|
| 623 | + $this->postUpdate($con); |
|
| 624 | + } |
|
| 625 | + $this->postSave($con); |
|
| 626 | + ChannelTableMap::addInstanceToPool($this); |
|
| 627 | + } else { |
|
| 628 | + $affectedRows = 0; |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + return $affectedRows; |
|
| 632 | + }); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + /** |
|
| 636 | + * Performs the work of inserting or updating the row in the database. |
|
| 637 | + * |
|
| 638 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 639 | + * All related objects are also updated in this method. |
|
| 640 | + * |
|
| 641 | + * @param ConnectionInterface $con |
|
| 642 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 643 | + * @throws PropelException |
|
| 644 | + * @see save() |
|
| 645 | + */ |
|
| 646 | + protected function doSave(ConnectionInterface $con) |
|
| 647 | + { |
|
| 648 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 649 | + if (!$this->alreadyInSave) { |
|
| 650 | + $this->alreadyInSave = true; |
|
| 651 | + |
|
| 652 | + // We call the save method on the following object(s) if they |
|
| 653 | + // were passed to this object by their corresponding set |
|
| 654 | + // method. This object relates to these object(s) by a |
|
| 655 | + // foreign key reference. |
|
| 656 | + |
|
| 657 | + if ($this->aInstance !== null) { |
|
| 658 | + if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
| 659 | + $affectedRows += $this->aInstance->save($con); |
|
| 660 | + } |
|
| 661 | + $this->setInstance($this->aInstance); |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + if ($this->isNew() || $this->isModified()) { |
|
| 665 | + // persist changes |
|
| 666 | + if ($this->isNew()) { |
|
| 667 | + $this->doInsert($con); |
|
| 668 | + $affectedRows += 1; |
|
| 669 | + } else { |
|
| 670 | + $affectedRows += $this->doUpdate($con); |
|
| 671 | + } |
|
| 672 | + $this->resetModified(); |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 676 | + if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 677 | + \Jalle19\StatusManager\Database\SubscriptionQuery::create() |
|
| 678 | + ->filterByPrimaryKeys($this->subscriptionsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 679 | + ->delete($con); |
|
| 680 | + $this->subscriptionsScheduledForDeletion = null; |
|
| 681 | + } |
|
| 682 | + } |
|
| 683 | + |
|
| 684 | + if ($this->collSubscriptions !== null) { |
|
| 685 | + foreach ($this->collSubscriptions as $referrerFK) { |
|
| 686 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 687 | + $affectedRows += $referrerFK->save($con); |
|
| 688 | + } |
|
| 689 | + } |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + $this->alreadyInSave = false; |
|
| 693 | + |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + return $affectedRows; |
|
| 697 | + } // doSave() |
|
| 698 | + |
|
| 699 | + /** |
|
| 700 | + * Insert the row in the database. |
|
| 701 | + * |
|
| 702 | + * @param ConnectionInterface $con |
|
| 703 | + * |
|
| 704 | + * @throws PropelException |
|
| 705 | + * @see doSave() |
|
| 706 | + */ |
|
| 707 | + protected function doInsert(ConnectionInterface $con) |
|
| 708 | + { |
|
| 709 | + $modifiedColumns = array(); |
|
| 710 | + $index = 0; |
|
| 711 | + |
|
| 712 | + $this->modifiedColumns[ChannelTableMap::COL_ID] = true; |
|
| 713 | + if (null !== $this->id) { |
|
| 714 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ChannelTableMap::COL_ID . ')'); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + // check the columns in natural order for more readable SQL queries |
|
| 718 | + if ($this->isColumnModified(ChannelTableMap::COL_ID)) { |
|
| 719 | + $modifiedColumns[':p' . $index++] = 'id'; |
|
| 720 | + } |
|
| 721 | + if ($this->isColumnModified(ChannelTableMap::COL_INSTANCE_NAME)) { |
|
| 722 | + $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
| 723 | + } |
|
| 724 | + if ($this->isColumnModified(ChannelTableMap::COL_NAME)) { |
|
| 725 | + $modifiedColumns[':p' . $index++] = 'name'; |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + $sql = sprintf( |
|
| 729 | + 'INSERT INTO channel (%s) VALUES (%s)', |
|
| 730 | + implode(', ', $modifiedColumns), |
|
| 731 | + implode(', ', array_keys($modifiedColumns)) |
|
| 732 | + ); |
|
| 733 | + |
|
| 734 | + try { |
|
| 735 | + $stmt = $con->prepare($sql); |
|
| 736 | + foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 737 | + switch ($columnName) { |
|
| 738 | + case 'id': |
|
| 739 | + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
| 740 | + break; |
|
| 741 | + case 'instance_name': |
|
| 742 | + $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
| 743 | + break; |
|
| 744 | + case 'name': |
|
| 745 | + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
|
| 746 | + break; |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + $stmt->execute(); |
|
| 750 | + } catch (Exception $e) { |
|
| 751 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 752 | + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 753 | + } |
|
| 754 | + |
|
| 755 | + try { |
|
| 756 | + $pk = $con->lastInsertId(); |
|
| 757 | + } catch (Exception $e) { |
|
| 758 | + throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
| 759 | + } |
|
| 760 | + $this->setId($pk); |
|
| 761 | + |
|
| 762 | + $this->setNew(false); |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + /** |
|
| 766 | + * Update the row in the database. |
|
| 767 | + * |
|
| 768 | + * @param ConnectionInterface $con |
|
| 769 | + * |
|
| 770 | + * @return Integer Number of updated rows |
|
| 771 | + * @see doSave() |
|
| 772 | + */ |
|
| 773 | + protected function doUpdate(ConnectionInterface $con) |
|
| 774 | + { |
|
| 775 | + $selectCriteria = $this->buildPkeyCriteria(); |
|
| 776 | + $valuesCriteria = $this->buildCriteria(); |
|
| 777 | + |
|
| 778 | + return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + /** |
|
| 782 | + * Retrieves a field from the object by name passed in as a string. |
|
| 783 | + * |
|
| 784 | + * @param string $name name |
|
| 785 | + * @param string $type The type of fieldname the $name is of: |
|
| 786 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 787 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 788 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 789 | + * @return mixed Value of field. |
|
| 790 | + */ |
|
| 791 | + public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 792 | + { |
|
| 793 | + $pos = ChannelTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 794 | + $field = $this->getByPosition($pos); |
|
| 795 | + |
|
| 796 | + return $field; |
|
| 797 | + } |
|
| 798 | + |
|
| 799 | + /** |
|
| 800 | + * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 801 | + * Zero-based. |
|
| 802 | + * |
|
| 803 | + * @param int $pos position in xml schema |
|
| 804 | + * @return mixed Value of field at $pos |
|
| 805 | + */ |
|
| 806 | + public function getByPosition($pos) |
|
| 807 | + { |
|
| 808 | + switch ($pos) { |
|
| 809 | + case 0: |
|
| 810 | + return $this->getId(); |
|
| 811 | + break; |
|
| 812 | + case 1: |
|
| 813 | + return $this->getInstanceName(); |
|
| 814 | + break; |
|
| 815 | + case 2: |
|
| 816 | + return $this->getName(); |
|
| 817 | + break; |
|
| 818 | + default: |
|
| 819 | + return null; |
|
| 820 | + break; |
|
| 821 | + } // switch() |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + /** |
|
| 825 | + * Exports the object as an array. |
|
| 826 | + * |
|
| 827 | + * You can specify the key type of the array by passing one of the class |
|
| 828 | + * type constants. |
|
| 829 | + * |
|
| 830 | + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 831 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 832 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 833 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 834 | + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 835 | + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 836 | + * |
|
| 837 | + * @return array an associative array containing the field names (as keys) and field values |
|
| 838 | + */ |
|
| 839 | + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 840 | + { |
|
| 841 | + |
|
| 842 | + if (isset($alreadyDumpedObjects['Channel'][$this->hashCode()])) { |
|
| 843 | + return '*RECURSION*'; |
|
| 844 | + } |
|
| 845 | + $alreadyDumpedObjects['Channel'][$this->hashCode()] = true; |
|
| 846 | + $keys = ChannelTableMap::getFieldNames($keyType); |
|
| 847 | + $result = array( |
|
| 848 | + $keys[0] => $this->getId(), |
|
| 849 | + $keys[1] => $this->getInstanceName(), |
|
| 850 | + $keys[2] => $this->getName(), |
|
| 851 | + ); |
|
| 852 | + $virtualColumns = $this->virtualColumns; |
|
| 853 | + foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 854 | + $result[$key] = $virtualColumn; |
|
| 855 | + } |
|
| 856 | + |
|
| 857 | + if ($includeForeignObjects) { |
|
| 858 | + if (null !== $this->aInstance) { |
|
| 859 | + |
|
| 860 | + switch ($keyType) { |
|
| 861 | + case TableMap::TYPE_CAMELNAME: |
|
| 862 | + $key = 'instance'; |
|
| 863 | + break; |
|
| 864 | + case TableMap::TYPE_FIELDNAME: |
|
| 865 | + $key = 'instance'; |
|
| 866 | + break; |
|
| 867 | + default: |
|
| 868 | + $key = 'Instance'; |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
| 872 | + } |
|
| 873 | + if (null !== $this->collSubscriptions) { |
|
| 874 | + |
|
| 875 | + switch ($keyType) { |
|
| 876 | + case TableMap::TYPE_CAMELNAME: |
|
| 877 | + $key = 'subscriptions'; |
|
| 878 | + break; |
|
| 879 | + case TableMap::TYPE_FIELDNAME: |
|
| 880 | + $key = 'subscriptions'; |
|
| 881 | + break; |
|
| 882 | + default: |
|
| 883 | + $key = 'Subscriptions'; |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 887 | + } |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + return $result; |
|
| 891 | + } |
|
| 892 | + |
|
| 893 | + /** |
|
| 894 | + * Sets a field from the object by name passed in as a string. |
|
| 895 | + * |
|
| 896 | + * @param string $name |
|
| 897 | + * @param mixed $value field value |
|
| 898 | + * @param string $type The type of fieldname the $name is of: |
|
| 899 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 900 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 901 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 902 | + * @return $this|\Jalle19\StatusManager\Database\Channel |
|
| 903 | + */ |
|
| 904 | + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 905 | + { |
|
| 906 | + $pos = ChannelTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 907 | + |
|
| 908 | + return $this->setByPosition($pos, $value); |
|
| 909 | + } |
|
| 910 | + |
|
| 911 | + /** |
|
| 912 | + * Sets a field from the object by Position as specified in the xml schema. |
|
| 913 | + * Zero-based. |
|
| 914 | + * |
|
| 915 | + * @param int $pos position in xml schema |
|
| 916 | + * @param mixed $value field value |
|
| 917 | + * @return $this|\Jalle19\StatusManager\Database\Channel |
|
| 918 | + */ |
|
| 919 | + public function setByPosition($pos, $value) |
|
| 920 | + { |
|
| 921 | + switch ($pos) { |
|
| 922 | + case 0: |
|
| 923 | + $this->setId($value); |
|
| 924 | + break; |
|
| 925 | + case 1: |
|
| 926 | + $this->setInstanceName($value); |
|
| 927 | + break; |
|
| 928 | + case 2: |
|
| 929 | + $this->setName($value); |
|
| 930 | + break; |
|
| 931 | + } // switch() |
|
| 932 | + |
|
| 933 | + return $this; |
|
| 934 | + } |
|
| 935 | + |
|
| 936 | + /** |
|
| 937 | + * Populates the object using an array. |
|
| 938 | + * |
|
| 939 | + * This is particularly useful when populating an object from one of the |
|
| 940 | + * request arrays (e.g. $_POST). This method goes through the column |
|
| 941 | + * names, checking to see whether a matching key exists in populated |
|
| 942 | + * array. If so the setByName() method is called for that column. |
|
| 943 | + * |
|
| 944 | + * You can specify the key type of the array by additionally passing one |
|
| 945 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 946 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 947 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 948 | + * |
|
| 949 | + * @param array $arr An array to populate the object from. |
|
| 950 | + * @param string $keyType The type of keys the array uses. |
|
| 951 | + * @return void |
|
| 952 | + */ |
|
| 953 | + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 954 | + { |
|
| 955 | + $keys = ChannelTableMap::getFieldNames($keyType); |
|
| 956 | + |
|
| 957 | + if (array_key_exists($keys[0], $arr)) { |
|
| 958 | + $this->setId($arr[$keys[0]]); |
|
| 959 | + } |
|
| 960 | + if (array_key_exists($keys[1], $arr)) { |
|
| 961 | + $this->setInstanceName($arr[$keys[1]]); |
|
| 962 | + } |
|
| 963 | + if (array_key_exists($keys[2], $arr)) { |
|
| 964 | + $this->setName($arr[$keys[2]]); |
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + /** |
|
| 969 | + * Populate the current object from a string, using a given parser format |
|
| 970 | + * <code> |
|
| 971 | + * $book = new Book(); |
|
| 972 | + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 973 | + * </code> |
|
| 974 | + * |
|
| 975 | + * You can specify the key type of the array by additionally passing one |
|
| 976 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 977 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 978 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 979 | + * |
|
| 980 | + * @param mixed $parser A AbstractParser instance, |
|
| 981 | + * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 982 | + * @param string $data The source data to import from |
|
| 983 | + * @param string $keyType The type of keys the array uses. |
|
| 984 | + * |
|
| 985 | + * @return $this|\Jalle19\StatusManager\Database\Channel The current object, for fluid interface |
|
| 986 | + */ |
|
| 987 | + public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 988 | + { |
|
| 989 | + if (!$parser instanceof AbstractParser) { |
|
| 990 | + $parser = AbstractParser::getParser($parser); |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + $this->fromArray($parser->toArray($data), $keyType); |
|
| 994 | + |
|
| 995 | + return $this; |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + /** |
|
| 999 | + * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1000 | + * |
|
| 1001 | + * @return Criteria The Criteria object containing all modified values. |
|
| 1002 | + */ |
|
| 1003 | + public function buildCriteria() |
|
| 1004 | + { |
|
| 1005 | + $criteria = new Criteria(ChannelTableMap::DATABASE_NAME); |
|
| 1006 | + |
|
| 1007 | + if ($this->isColumnModified(ChannelTableMap::COL_ID)) { |
|
| 1008 | + $criteria->add(ChannelTableMap::COL_ID, $this->id); |
|
| 1009 | + } |
|
| 1010 | + if ($this->isColumnModified(ChannelTableMap::COL_INSTANCE_NAME)) { |
|
| 1011 | + $criteria->add(ChannelTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
| 1012 | + } |
|
| 1013 | + if ($this->isColumnModified(ChannelTableMap::COL_NAME)) { |
|
| 1014 | + $criteria->add(ChannelTableMap::COL_NAME, $this->name); |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + return $criteria; |
|
| 1018 | + } |
|
| 1019 | + |
|
| 1020 | + /** |
|
| 1021 | + * Builds a Criteria object containing the primary key for this object. |
|
| 1022 | + * |
|
| 1023 | + * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1024 | + * of whether or not they have been modified. |
|
| 1025 | + * |
|
| 1026 | + * @throws LogicException if no primary key is defined |
|
| 1027 | + * |
|
| 1028 | + * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1029 | + */ |
|
| 1030 | + public function buildPkeyCriteria() |
|
| 1031 | + { |
|
| 1032 | + $criteria = ChildChannelQuery::create(); |
|
| 1033 | + $criteria->add(ChannelTableMap::COL_ID, $this->id); |
|
| 1034 | + |
|
| 1035 | + return $criteria; |
|
| 1036 | + } |
|
| 1037 | + |
|
| 1038 | + /** |
|
| 1039 | + * If the primary key is not null, return the hashcode of the |
|
| 1040 | + * primary key. Otherwise, return the hash code of the object. |
|
| 1041 | + * |
|
| 1042 | + * @return int Hashcode |
|
| 1043 | + */ |
|
| 1044 | + public function hashCode() |
|
| 1045 | + { |
|
| 1046 | + $validPk = null !== $this->getId(); |
|
| 1047 | + |
|
| 1048 | + $validPrimaryKeyFKs = 0; |
|
| 1049 | + $primaryKeyFKs = []; |
|
| 1050 | + |
|
| 1051 | + if ($validPk) { |
|
| 1052 | + return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1053 | + } elseif ($validPrimaryKeyFKs) { |
|
| 1054 | + return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1055 | + } |
|
| 1056 | + |
|
| 1057 | + return spl_object_hash($this); |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + /** |
|
| 1061 | + * Returns the primary key for this object (row). |
|
| 1062 | + * @return int |
|
| 1063 | + */ |
|
| 1064 | + public function getPrimaryKey() |
|
| 1065 | + { |
|
| 1066 | + return $this->getId(); |
|
| 1067 | + } |
|
| 1068 | + |
|
| 1069 | + /** |
|
| 1070 | + * Generic method to set the primary key (id column). |
|
| 1071 | + * |
|
| 1072 | + * @param int $key Primary key. |
|
| 1073 | + * @return void |
|
| 1074 | + */ |
|
| 1075 | + public function setPrimaryKey($key) |
|
| 1076 | + { |
|
| 1077 | + $this->setId($key); |
|
| 1078 | + } |
|
| 1079 | + |
|
| 1080 | + /** |
|
| 1081 | + * Returns true if the primary key for this object is null. |
|
| 1082 | + * @return boolean |
|
| 1083 | + */ |
|
| 1084 | + public function isPrimaryKeyNull() |
|
| 1085 | + { |
|
| 1086 | + return null === $this->getId(); |
|
| 1087 | + } |
|
| 1088 | + |
|
| 1089 | + /** |
|
| 1090 | + * Sets contents of passed object to values from current object. |
|
| 1091 | + * |
|
| 1092 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1093 | + * objects. |
|
| 1094 | + * |
|
| 1095 | + * @param object $copyObj An object of \Jalle19\StatusManager\Database\Channel (or compatible) type. |
|
| 1096 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1097 | + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1098 | + * @throws PropelException |
|
| 1099 | + */ |
|
| 1100 | + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1101 | + { |
|
| 1102 | + $copyObj->setInstanceName($this->getInstanceName()); |
|
| 1103 | + $copyObj->setName($this->getName()); |
|
| 1104 | + |
|
| 1105 | + if ($deepCopy) { |
|
| 1106 | + // important: temporarily setNew(false) because this affects the behavior of |
|
| 1107 | + // the getter/setter methods for fkey referrer objects. |
|
| 1108 | + $copyObj->setNew(false); |
|
| 1109 | + |
|
| 1110 | + foreach ($this->getSubscriptions() as $relObj) { |
|
| 1111 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1112 | + $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1113 | + } |
|
| 1114 | + } |
|
| 1115 | + |
|
| 1116 | + } // if ($deepCopy) |
|
| 1117 | + |
|
| 1118 | + if ($makeNew) { |
|
| 1119 | + $copyObj->setNew(true); |
|
| 1120 | + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
|
| 1121 | + } |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + /** |
|
| 1125 | + * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1126 | + * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1127 | + * keys that are defined for the table. |
|
| 1128 | + * |
|
| 1129 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1130 | + * objects. |
|
| 1131 | + * |
|
| 1132 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1133 | + * @return \Jalle19\StatusManager\Database\Channel Clone of current object. |
|
| 1134 | + * @throws PropelException |
|
| 1135 | + */ |
|
| 1136 | + public function copy($deepCopy = false) |
|
| 1137 | + { |
|
| 1138 | + // we use get_class(), because this might be a subclass |
|
| 1139 | + $clazz = get_class($this); |
|
| 1140 | + $copyObj = new $clazz(); |
|
| 1141 | + $this->copyInto($copyObj, $deepCopy); |
|
| 1142 | + |
|
| 1143 | + return $copyObj; |
|
| 1144 | + } |
|
| 1145 | + |
|
| 1146 | + /** |
|
| 1147 | + * Declares an association between this object and a ChildInstance object. |
|
| 1148 | + * |
|
| 1149 | + * @param ChildInstance $v |
|
| 1150 | + * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 1151 | + * @throws PropelException |
|
| 1152 | + */ |
|
| 1153 | + public function setInstance(ChildInstance $v = null) |
|
| 1154 | + { |
|
| 1155 | + if ($v === null) { |
|
| 1156 | + $this->setInstanceName(NULL); |
|
| 1157 | + } else { |
|
| 1158 | + $this->setInstanceName($v->getName()); |
|
| 1159 | + } |
|
| 1160 | + |
|
| 1161 | + $this->aInstance = $v; |
|
| 1162 | + |
|
| 1163 | + // Add binding for other direction of this n:n relationship. |
|
| 1164 | + // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
| 1165 | + if ($v !== null) { |
|
| 1166 | + $v->addChannel($this); |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + |
|
| 1170 | + return $this; |
|
| 1171 | + } |
|
| 1172 | + |
|
| 1173 | + |
|
| 1174 | + /** |
|
| 1175 | + * Get the associated ChildInstance object |
|
| 1176 | + * |
|
| 1177 | + * @param ConnectionInterface $con Optional Connection object. |
|
| 1178 | + * @return ChildInstance The associated ChildInstance object. |
|
| 1179 | + * @throws PropelException |
|
| 1180 | + */ |
|
| 1181 | + public function getInstance(ConnectionInterface $con = null) |
|
| 1182 | + { |
|
| 1183 | + if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
| 1184 | + $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
| 1185 | + /* The following can be used additionally to |
|
| 1186 | 1186 | guarantee the related object contains a reference |
| 1187 | 1187 | to this object. This level of coupling may, however, be |
| 1188 | 1188 | undesirable since it could result in an only partially populated collection |
| 1189 | 1189 | in the referenced object. |
| 1190 | 1190 | $this->aInstance->addChannels($this); |
| 1191 | 1191 | */ |
| 1192 | - } |
|
| 1193 | - |
|
| 1194 | - return $this->aInstance; |
|
| 1195 | - } |
|
| 1196 | - |
|
| 1197 | - |
|
| 1198 | - /** |
|
| 1199 | - * Initializes a collection based on the name of a relation. |
|
| 1200 | - * Avoids crafting an 'init[$relationName]s' method name |
|
| 1201 | - * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1202 | - * |
|
| 1203 | - * @param string $relationName The name of the relation to initialize |
|
| 1204 | - * @return void |
|
| 1205 | - */ |
|
| 1206 | - public function initRelation($relationName) |
|
| 1207 | - { |
|
| 1208 | - if ('Subscription' == $relationName) { |
|
| 1209 | - return $this->initSubscriptions(); |
|
| 1210 | - } |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * Clears out the collSubscriptions collection |
|
| 1215 | - * |
|
| 1216 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1217 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1218 | - * |
|
| 1219 | - * @return void |
|
| 1220 | - * @see addSubscriptions() |
|
| 1221 | - */ |
|
| 1222 | - public function clearSubscriptions() |
|
| 1223 | - { |
|
| 1224 | - $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 1225 | - } |
|
| 1226 | - |
|
| 1227 | - /** |
|
| 1228 | - * Reset is the collSubscriptions collection loaded partially. |
|
| 1229 | - */ |
|
| 1230 | - public function resetPartialSubscriptions($v = true) |
|
| 1231 | - { |
|
| 1232 | - $this->collSubscriptionsPartial = $v; |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Initializes the collSubscriptions collection. |
|
| 1237 | - * |
|
| 1238 | - * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 1239 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1240 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1241 | - * |
|
| 1242 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1243 | - * the collection even if it is not empty |
|
| 1244 | - * |
|
| 1245 | - * @return void |
|
| 1246 | - */ |
|
| 1247 | - public function initSubscriptions($overrideExisting = true) |
|
| 1248 | - { |
|
| 1249 | - if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 1250 | - return; |
|
| 1251 | - } |
|
| 1252 | - |
|
| 1253 | - $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1254 | - |
|
| 1255 | - $this->collSubscriptions = new $collectionClassName; |
|
| 1256 | - $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 1261 | - * |
|
| 1262 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1263 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1264 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1265 | - * If this ChildChannel is new, it will return |
|
| 1266 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1267 | - * |
|
| 1268 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1269 | - * @param ConnectionInterface $con optional connection object |
|
| 1270 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1271 | - * @throws PropelException |
|
| 1272 | - */ |
|
| 1273 | - public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1274 | - { |
|
| 1275 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1276 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1277 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1278 | - // return empty collection |
|
| 1279 | - $this->initSubscriptions(); |
|
| 1280 | - } else { |
|
| 1281 | - $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 1282 | - ->filterByChannel($this) |
|
| 1283 | - ->find($con); |
|
| 1284 | - |
|
| 1285 | - if (null !== $criteria) { |
|
| 1286 | - if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 1287 | - $this->initSubscriptions(false); |
|
| 1288 | - |
|
| 1289 | - foreach ($collSubscriptions as $obj) { |
|
| 1290 | - if (false == $this->collSubscriptions->contains($obj)) { |
|
| 1291 | - $this->collSubscriptions->append($obj); |
|
| 1292 | - } |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - $this->collSubscriptionsPartial = true; |
|
| 1296 | - } |
|
| 1297 | - |
|
| 1298 | - return $collSubscriptions; |
|
| 1299 | - } |
|
| 1300 | - |
|
| 1301 | - if ($partial && $this->collSubscriptions) { |
|
| 1302 | - foreach ($this->collSubscriptions as $obj) { |
|
| 1303 | - if ($obj->isNew()) { |
|
| 1304 | - $collSubscriptions[] = $obj; |
|
| 1305 | - } |
|
| 1306 | - } |
|
| 1307 | - } |
|
| 1308 | - |
|
| 1309 | - $this->collSubscriptions = $collSubscriptions; |
|
| 1310 | - $this->collSubscriptionsPartial = false; |
|
| 1311 | - } |
|
| 1312 | - } |
|
| 1313 | - |
|
| 1314 | - return $this->collSubscriptions; |
|
| 1315 | - } |
|
| 1316 | - |
|
| 1317 | - /** |
|
| 1318 | - * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 1319 | - * to the current object. |
|
| 1320 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1321 | - * and new objects from the given Propel collection. |
|
| 1322 | - * |
|
| 1323 | - * @param Collection $subscriptions A Propel collection. |
|
| 1324 | - * @param ConnectionInterface $con Optional connection object |
|
| 1325 | - * @return $this|ChildChannel The current object (for fluent API support) |
|
| 1326 | - */ |
|
| 1327 | - public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1328 | - { |
|
| 1329 | - /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 1330 | - $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 1331 | - |
|
| 1332 | - |
|
| 1333 | - $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 1334 | - |
|
| 1335 | - foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 1336 | - $subscriptionRemoved->setChannel(null); |
|
| 1337 | - } |
|
| 1338 | - |
|
| 1339 | - $this->collSubscriptions = null; |
|
| 1340 | - foreach ($subscriptions as $subscription) { |
|
| 1341 | - $this->addSubscription($subscription); |
|
| 1342 | - } |
|
| 1343 | - |
|
| 1344 | - $this->collSubscriptions = $subscriptions; |
|
| 1345 | - $this->collSubscriptionsPartial = false; |
|
| 1346 | - |
|
| 1347 | - return $this; |
|
| 1348 | - } |
|
| 1349 | - |
|
| 1350 | - /** |
|
| 1351 | - * Returns the number of related Subscription objects. |
|
| 1352 | - * |
|
| 1353 | - * @param Criteria $criteria |
|
| 1354 | - * @param boolean $distinct |
|
| 1355 | - * @param ConnectionInterface $con |
|
| 1356 | - * @return int Count of related Subscription objects. |
|
| 1357 | - * @throws PropelException |
|
| 1358 | - */ |
|
| 1359 | - public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1360 | - { |
|
| 1361 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1362 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1363 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1364 | - return 0; |
|
| 1365 | - } |
|
| 1366 | - |
|
| 1367 | - if ($partial && !$criteria) { |
|
| 1368 | - return count($this->getSubscriptions()); |
|
| 1369 | - } |
|
| 1370 | - |
|
| 1371 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1372 | - if ($distinct) { |
|
| 1373 | - $query->distinct(); |
|
| 1374 | - } |
|
| 1375 | - |
|
| 1376 | - return $query |
|
| 1377 | - ->filterByChannel($this) |
|
| 1378 | - ->count($con); |
|
| 1379 | - } |
|
| 1380 | - |
|
| 1381 | - return count($this->collSubscriptions); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - /** |
|
| 1385 | - * Method called to associate a ChildSubscription object to this object |
|
| 1386 | - * through the ChildSubscription foreign key attribute. |
|
| 1387 | - * |
|
| 1388 | - * @param ChildSubscription $l ChildSubscription |
|
| 1389 | - * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 1390 | - */ |
|
| 1391 | - public function addSubscription(ChildSubscription $l) |
|
| 1392 | - { |
|
| 1393 | - if ($this->collSubscriptions === null) { |
|
| 1394 | - $this->initSubscriptions(); |
|
| 1395 | - $this->collSubscriptionsPartial = true; |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - if (!$this->collSubscriptions->contains($l)) { |
|
| 1399 | - $this->doAddSubscription($l); |
|
| 1400 | - |
|
| 1401 | - if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 1402 | - $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 1403 | - } |
|
| 1404 | - } |
|
| 1405 | - |
|
| 1406 | - return $this; |
|
| 1407 | - } |
|
| 1408 | - |
|
| 1409 | - /** |
|
| 1410 | - * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 1411 | - */ |
|
| 1412 | - protected function doAddSubscription(ChildSubscription $subscription) |
|
| 1413 | - { |
|
| 1414 | - $this->collSubscriptions[]= $subscription; |
|
| 1415 | - $subscription->setChannel($this); |
|
| 1416 | - } |
|
| 1417 | - |
|
| 1418 | - /** |
|
| 1419 | - * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 1420 | - * @return $this|ChildChannel The current object (for fluent API support) |
|
| 1421 | - */ |
|
| 1422 | - public function removeSubscription(ChildSubscription $subscription) |
|
| 1423 | - { |
|
| 1424 | - if ($this->getSubscriptions()->contains($subscription)) { |
|
| 1425 | - $pos = $this->collSubscriptions->search($subscription); |
|
| 1426 | - $this->collSubscriptions->remove($pos); |
|
| 1427 | - if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 1428 | - $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 1429 | - $this->subscriptionsScheduledForDeletion->clear(); |
|
| 1430 | - } |
|
| 1431 | - $this->subscriptionsScheduledForDeletion[]= clone $subscription; |
|
| 1432 | - $subscription->setChannel(null); |
|
| 1433 | - } |
|
| 1434 | - |
|
| 1435 | - return $this; |
|
| 1436 | - } |
|
| 1437 | - |
|
| 1438 | - |
|
| 1439 | - /** |
|
| 1440 | - * If this collection has already been initialized with |
|
| 1441 | - * an identical criteria, it returns the collection. |
|
| 1442 | - * Otherwise if this Channel is new, it will return |
|
| 1443 | - * an empty collection; or if this Channel has previously |
|
| 1444 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1445 | - * |
|
| 1446 | - * This method is protected by default in order to keep the public |
|
| 1447 | - * api reasonable. You can provide public methods for those you |
|
| 1448 | - * actually need in Channel. |
|
| 1449 | - * |
|
| 1450 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1451 | - * @param ConnectionInterface $con optional connection object |
|
| 1452 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1453 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1454 | - */ |
|
| 1455 | - public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1456 | - { |
|
| 1457 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1458 | - $query->joinWith('Instance', $joinBehavior); |
|
| 1459 | - |
|
| 1460 | - return $this->getSubscriptions($query, $con); |
|
| 1461 | - } |
|
| 1462 | - |
|
| 1463 | - |
|
| 1464 | - /** |
|
| 1465 | - * If this collection has already been initialized with |
|
| 1466 | - * an identical criteria, it returns the collection. |
|
| 1467 | - * Otherwise if this Channel is new, it will return |
|
| 1468 | - * an empty collection; or if this Channel has previously |
|
| 1469 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1470 | - * |
|
| 1471 | - * This method is protected by default in order to keep the public |
|
| 1472 | - * api reasonable. You can provide public methods for those you |
|
| 1473 | - * actually need in Channel. |
|
| 1474 | - * |
|
| 1475 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1476 | - * @param ConnectionInterface $con optional connection object |
|
| 1477 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1478 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1479 | - */ |
|
| 1480 | - public function getSubscriptionsJoinInput(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1481 | - { |
|
| 1482 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1483 | - $query->joinWith('Input', $joinBehavior); |
|
| 1484 | - |
|
| 1485 | - return $this->getSubscriptions($query, $con); |
|
| 1486 | - } |
|
| 1487 | - |
|
| 1488 | - |
|
| 1489 | - /** |
|
| 1490 | - * If this collection has already been initialized with |
|
| 1491 | - * an identical criteria, it returns the collection. |
|
| 1492 | - * Otherwise if this Channel is new, it will return |
|
| 1493 | - * an empty collection; or if this Channel has previously |
|
| 1494 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1495 | - * |
|
| 1496 | - * This method is protected by default in order to keep the public |
|
| 1497 | - * api reasonable. You can provide public methods for those you |
|
| 1498 | - * actually need in Channel. |
|
| 1499 | - * |
|
| 1500 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1501 | - * @param ConnectionInterface $con optional connection object |
|
| 1502 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1503 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1504 | - */ |
|
| 1505 | - public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1506 | - { |
|
| 1507 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1508 | - $query->joinWith('User', $joinBehavior); |
|
| 1509 | - |
|
| 1510 | - return $this->getSubscriptions($query, $con); |
|
| 1511 | - } |
|
| 1512 | - |
|
| 1513 | - /** |
|
| 1514 | - * Clears the current object, sets all attributes to their default values and removes |
|
| 1515 | - * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 1516 | - * change of those foreign objects when you call `save` there). |
|
| 1517 | - */ |
|
| 1518 | - public function clear() |
|
| 1519 | - { |
|
| 1520 | - if (null !== $this->aInstance) { |
|
| 1521 | - $this->aInstance->removeChannel($this); |
|
| 1522 | - } |
|
| 1523 | - $this->id = null; |
|
| 1524 | - $this->instance_name = null; |
|
| 1525 | - $this->name = null; |
|
| 1526 | - $this->alreadyInSave = false; |
|
| 1527 | - $this->clearAllReferences(); |
|
| 1528 | - $this->resetModified(); |
|
| 1529 | - $this->setNew(true); |
|
| 1530 | - $this->setDeleted(false); |
|
| 1531 | - } |
|
| 1532 | - |
|
| 1533 | - /** |
|
| 1534 | - * Resets all references and back-references to other model objects or collections of model objects. |
|
| 1535 | - * |
|
| 1536 | - * This method is used to reset all php object references (not the actual reference in the database). |
|
| 1537 | - * Necessary for object serialisation. |
|
| 1538 | - * |
|
| 1539 | - * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 1540 | - */ |
|
| 1541 | - public function clearAllReferences($deep = false) |
|
| 1542 | - { |
|
| 1543 | - if ($deep) { |
|
| 1544 | - if ($this->collSubscriptions) { |
|
| 1545 | - foreach ($this->collSubscriptions as $o) { |
|
| 1546 | - $o->clearAllReferences($deep); |
|
| 1547 | - } |
|
| 1548 | - } |
|
| 1549 | - } // if ($deep) |
|
| 1550 | - |
|
| 1551 | - $this->collSubscriptions = null; |
|
| 1552 | - $this->aInstance = null; |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - /** |
|
| 1556 | - * Return the string representation of this object |
|
| 1557 | - * |
|
| 1558 | - * @return string |
|
| 1559 | - */ |
|
| 1560 | - public function __toString() |
|
| 1561 | - { |
|
| 1562 | - return (string) $this->exportTo(ChannelTableMap::DEFAULT_STRING_FORMAT); |
|
| 1563 | - } |
|
| 1564 | - |
|
| 1565 | - /** |
|
| 1566 | - * Code to be run before persisting the object |
|
| 1567 | - * @param ConnectionInterface $con |
|
| 1568 | - * @return boolean |
|
| 1569 | - */ |
|
| 1570 | - public function preSave(ConnectionInterface $con = null) |
|
| 1571 | - { |
|
| 1572 | - return true; |
|
| 1573 | - } |
|
| 1574 | - |
|
| 1575 | - /** |
|
| 1576 | - * Code to be run after persisting the object |
|
| 1577 | - * @param ConnectionInterface $con |
|
| 1578 | - */ |
|
| 1579 | - public function postSave(ConnectionInterface $con = null) |
|
| 1580 | - { |
|
| 1581 | - |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - /** |
|
| 1585 | - * Code to be run before inserting to database |
|
| 1586 | - * @param ConnectionInterface $con |
|
| 1587 | - * @return boolean |
|
| 1588 | - */ |
|
| 1589 | - public function preInsert(ConnectionInterface $con = null) |
|
| 1590 | - { |
|
| 1591 | - return true; |
|
| 1592 | - } |
|
| 1593 | - |
|
| 1594 | - /** |
|
| 1595 | - * Code to be run after inserting to database |
|
| 1596 | - * @param ConnectionInterface $con |
|
| 1597 | - */ |
|
| 1598 | - public function postInsert(ConnectionInterface $con = null) |
|
| 1599 | - { |
|
| 1600 | - |
|
| 1601 | - } |
|
| 1602 | - |
|
| 1603 | - /** |
|
| 1604 | - * Code to be run before updating the object in database |
|
| 1605 | - * @param ConnectionInterface $con |
|
| 1606 | - * @return boolean |
|
| 1607 | - */ |
|
| 1608 | - public function preUpdate(ConnectionInterface $con = null) |
|
| 1609 | - { |
|
| 1610 | - return true; |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - /** |
|
| 1614 | - * Code to be run after updating the object in database |
|
| 1615 | - * @param ConnectionInterface $con |
|
| 1616 | - */ |
|
| 1617 | - public function postUpdate(ConnectionInterface $con = null) |
|
| 1618 | - { |
|
| 1619 | - |
|
| 1620 | - } |
|
| 1621 | - |
|
| 1622 | - /** |
|
| 1623 | - * Code to be run before deleting the object in database |
|
| 1624 | - * @param ConnectionInterface $con |
|
| 1625 | - * @return boolean |
|
| 1626 | - */ |
|
| 1627 | - public function preDelete(ConnectionInterface $con = null) |
|
| 1628 | - { |
|
| 1629 | - return true; |
|
| 1630 | - } |
|
| 1631 | - |
|
| 1632 | - /** |
|
| 1633 | - * Code to be run after deleting the object in database |
|
| 1634 | - * @param ConnectionInterface $con |
|
| 1635 | - */ |
|
| 1636 | - public function postDelete(ConnectionInterface $con = null) |
|
| 1637 | - { |
|
| 1638 | - |
|
| 1639 | - } |
|
| 1640 | - |
|
| 1641 | - |
|
| 1642 | - /** |
|
| 1643 | - * Derived method to catches calls to undefined methods. |
|
| 1644 | - * |
|
| 1645 | - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 1646 | - * Allows to define default __call() behavior if you overwrite __call() |
|
| 1647 | - * |
|
| 1648 | - * @param string $name |
|
| 1649 | - * @param mixed $params |
|
| 1650 | - * |
|
| 1651 | - * @return array|string |
|
| 1652 | - */ |
|
| 1653 | - public function __call($name, $params) |
|
| 1654 | - { |
|
| 1655 | - if (0 === strpos($name, 'get')) { |
|
| 1656 | - $virtualColumn = substr($name, 3); |
|
| 1657 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1658 | - return $this->getVirtualColumn($virtualColumn); |
|
| 1659 | - } |
|
| 1660 | - |
|
| 1661 | - $virtualColumn = lcfirst($virtualColumn); |
|
| 1662 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1663 | - return $this->getVirtualColumn($virtualColumn); |
|
| 1664 | - } |
|
| 1665 | - } |
|
| 1666 | - |
|
| 1667 | - if (0 === strpos($name, 'from')) { |
|
| 1668 | - $format = substr($name, 4); |
|
| 1669 | - |
|
| 1670 | - return $this->importFrom($format, reset($params)); |
|
| 1671 | - } |
|
| 1672 | - |
|
| 1673 | - if (0 === strpos($name, 'to')) { |
|
| 1674 | - $format = substr($name, 2); |
|
| 1675 | - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 1676 | - |
|
| 1677 | - return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 1678 | - } |
|
| 1679 | - |
|
| 1680 | - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 1681 | - } |
|
| 1192 | + } |
|
| 1193 | + |
|
| 1194 | + return $this->aInstance; |
|
| 1195 | + } |
|
| 1196 | + |
|
| 1197 | + |
|
| 1198 | + /** |
|
| 1199 | + * Initializes a collection based on the name of a relation. |
|
| 1200 | + * Avoids crafting an 'init[$relationName]s' method name |
|
| 1201 | + * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1202 | + * |
|
| 1203 | + * @param string $relationName The name of the relation to initialize |
|
| 1204 | + * @return void |
|
| 1205 | + */ |
|
| 1206 | + public function initRelation($relationName) |
|
| 1207 | + { |
|
| 1208 | + if ('Subscription' == $relationName) { |
|
| 1209 | + return $this->initSubscriptions(); |
|
| 1210 | + } |
|
| 1211 | + } |
|
| 1212 | + |
|
| 1213 | + /** |
|
| 1214 | + * Clears out the collSubscriptions collection |
|
| 1215 | + * |
|
| 1216 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1217 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1218 | + * |
|
| 1219 | + * @return void |
|
| 1220 | + * @see addSubscriptions() |
|
| 1221 | + */ |
|
| 1222 | + public function clearSubscriptions() |
|
| 1223 | + { |
|
| 1224 | + $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 1225 | + } |
|
| 1226 | + |
|
| 1227 | + /** |
|
| 1228 | + * Reset is the collSubscriptions collection loaded partially. |
|
| 1229 | + */ |
|
| 1230 | + public function resetPartialSubscriptions($v = true) |
|
| 1231 | + { |
|
| 1232 | + $this->collSubscriptionsPartial = $v; |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * Initializes the collSubscriptions collection. |
|
| 1237 | + * |
|
| 1238 | + * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 1239 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1240 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1241 | + * |
|
| 1242 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1243 | + * the collection even if it is not empty |
|
| 1244 | + * |
|
| 1245 | + * @return void |
|
| 1246 | + */ |
|
| 1247 | + public function initSubscriptions($overrideExisting = true) |
|
| 1248 | + { |
|
| 1249 | + if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 1250 | + return; |
|
| 1251 | + } |
|
| 1252 | + |
|
| 1253 | + $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1254 | + |
|
| 1255 | + $this->collSubscriptions = new $collectionClassName; |
|
| 1256 | + $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + /** |
|
| 1260 | + * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 1261 | + * |
|
| 1262 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1263 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1264 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1265 | + * If this ChildChannel is new, it will return |
|
| 1266 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1267 | + * |
|
| 1268 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1269 | + * @param ConnectionInterface $con optional connection object |
|
| 1270 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1271 | + * @throws PropelException |
|
| 1272 | + */ |
|
| 1273 | + public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1274 | + { |
|
| 1275 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1276 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1277 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1278 | + // return empty collection |
|
| 1279 | + $this->initSubscriptions(); |
|
| 1280 | + } else { |
|
| 1281 | + $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 1282 | + ->filterByChannel($this) |
|
| 1283 | + ->find($con); |
|
| 1284 | + |
|
| 1285 | + if (null !== $criteria) { |
|
| 1286 | + if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 1287 | + $this->initSubscriptions(false); |
|
| 1288 | + |
|
| 1289 | + foreach ($collSubscriptions as $obj) { |
|
| 1290 | + if (false == $this->collSubscriptions->contains($obj)) { |
|
| 1291 | + $this->collSubscriptions->append($obj); |
|
| 1292 | + } |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + $this->collSubscriptionsPartial = true; |
|
| 1296 | + } |
|
| 1297 | + |
|
| 1298 | + return $collSubscriptions; |
|
| 1299 | + } |
|
| 1300 | + |
|
| 1301 | + if ($partial && $this->collSubscriptions) { |
|
| 1302 | + foreach ($this->collSubscriptions as $obj) { |
|
| 1303 | + if ($obj->isNew()) { |
|
| 1304 | + $collSubscriptions[] = $obj; |
|
| 1305 | + } |
|
| 1306 | + } |
|
| 1307 | + } |
|
| 1308 | + |
|
| 1309 | + $this->collSubscriptions = $collSubscriptions; |
|
| 1310 | + $this->collSubscriptionsPartial = false; |
|
| 1311 | + } |
|
| 1312 | + } |
|
| 1313 | + |
|
| 1314 | + return $this->collSubscriptions; |
|
| 1315 | + } |
|
| 1316 | + |
|
| 1317 | + /** |
|
| 1318 | + * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 1319 | + * to the current object. |
|
| 1320 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1321 | + * and new objects from the given Propel collection. |
|
| 1322 | + * |
|
| 1323 | + * @param Collection $subscriptions A Propel collection. |
|
| 1324 | + * @param ConnectionInterface $con Optional connection object |
|
| 1325 | + * @return $this|ChildChannel The current object (for fluent API support) |
|
| 1326 | + */ |
|
| 1327 | + public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1328 | + { |
|
| 1329 | + /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 1330 | + $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 1331 | + |
|
| 1332 | + |
|
| 1333 | + $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 1334 | + |
|
| 1335 | + foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 1336 | + $subscriptionRemoved->setChannel(null); |
|
| 1337 | + } |
|
| 1338 | + |
|
| 1339 | + $this->collSubscriptions = null; |
|
| 1340 | + foreach ($subscriptions as $subscription) { |
|
| 1341 | + $this->addSubscription($subscription); |
|
| 1342 | + } |
|
| 1343 | + |
|
| 1344 | + $this->collSubscriptions = $subscriptions; |
|
| 1345 | + $this->collSubscriptionsPartial = false; |
|
| 1346 | + |
|
| 1347 | + return $this; |
|
| 1348 | + } |
|
| 1349 | + |
|
| 1350 | + /** |
|
| 1351 | + * Returns the number of related Subscription objects. |
|
| 1352 | + * |
|
| 1353 | + * @param Criteria $criteria |
|
| 1354 | + * @param boolean $distinct |
|
| 1355 | + * @param ConnectionInterface $con |
|
| 1356 | + * @return int Count of related Subscription objects. |
|
| 1357 | + * @throws PropelException |
|
| 1358 | + */ |
|
| 1359 | + public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1360 | + { |
|
| 1361 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1362 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1363 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1364 | + return 0; |
|
| 1365 | + } |
|
| 1366 | + |
|
| 1367 | + if ($partial && !$criteria) { |
|
| 1368 | + return count($this->getSubscriptions()); |
|
| 1369 | + } |
|
| 1370 | + |
|
| 1371 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1372 | + if ($distinct) { |
|
| 1373 | + $query->distinct(); |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + return $query |
|
| 1377 | + ->filterByChannel($this) |
|
| 1378 | + ->count($con); |
|
| 1379 | + } |
|
| 1380 | + |
|
| 1381 | + return count($this->collSubscriptions); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + /** |
|
| 1385 | + * Method called to associate a ChildSubscription object to this object |
|
| 1386 | + * through the ChildSubscription foreign key attribute. |
|
| 1387 | + * |
|
| 1388 | + * @param ChildSubscription $l ChildSubscription |
|
| 1389 | + * @return $this|\Jalle19\StatusManager\Database\Channel The current object (for fluent API support) |
|
| 1390 | + */ |
|
| 1391 | + public function addSubscription(ChildSubscription $l) |
|
| 1392 | + { |
|
| 1393 | + if ($this->collSubscriptions === null) { |
|
| 1394 | + $this->initSubscriptions(); |
|
| 1395 | + $this->collSubscriptionsPartial = true; |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + if (!$this->collSubscriptions->contains($l)) { |
|
| 1399 | + $this->doAddSubscription($l); |
|
| 1400 | + |
|
| 1401 | + if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 1402 | + $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 1403 | + } |
|
| 1404 | + } |
|
| 1405 | + |
|
| 1406 | + return $this; |
|
| 1407 | + } |
|
| 1408 | + |
|
| 1409 | + /** |
|
| 1410 | + * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 1411 | + */ |
|
| 1412 | + protected function doAddSubscription(ChildSubscription $subscription) |
|
| 1413 | + { |
|
| 1414 | + $this->collSubscriptions[]= $subscription; |
|
| 1415 | + $subscription->setChannel($this); |
|
| 1416 | + } |
|
| 1417 | + |
|
| 1418 | + /** |
|
| 1419 | + * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 1420 | + * @return $this|ChildChannel The current object (for fluent API support) |
|
| 1421 | + */ |
|
| 1422 | + public function removeSubscription(ChildSubscription $subscription) |
|
| 1423 | + { |
|
| 1424 | + if ($this->getSubscriptions()->contains($subscription)) { |
|
| 1425 | + $pos = $this->collSubscriptions->search($subscription); |
|
| 1426 | + $this->collSubscriptions->remove($pos); |
|
| 1427 | + if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 1428 | + $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 1429 | + $this->subscriptionsScheduledForDeletion->clear(); |
|
| 1430 | + } |
|
| 1431 | + $this->subscriptionsScheduledForDeletion[]= clone $subscription; |
|
| 1432 | + $subscription->setChannel(null); |
|
| 1433 | + } |
|
| 1434 | + |
|
| 1435 | + return $this; |
|
| 1436 | + } |
|
| 1437 | + |
|
| 1438 | + |
|
| 1439 | + /** |
|
| 1440 | + * If this collection has already been initialized with |
|
| 1441 | + * an identical criteria, it returns the collection. |
|
| 1442 | + * Otherwise if this Channel is new, it will return |
|
| 1443 | + * an empty collection; or if this Channel has previously |
|
| 1444 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1445 | + * |
|
| 1446 | + * This method is protected by default in order to keep the public |
|
| 1447 | + * api reasonable. You can provide public methods for those you |
|
| 1448 | + * actually need in Channel. |
|
| 1449 | + * |
|
| 1450 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1451 | + * @param ConnectionInterface $con optional connection object |
|
| 1452 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1453 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1454 | + */ |
|
| 1455 | + public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1456 | + { |
|
| 1457 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1458 | + $query->joinWith('Instance', $joinBehavior); |
|
| 1459 | + |
|
| 1460 | + return $this->getSubscriptions($query, $con); |
|
| 1461 | + } |
|
| 1462 | + |
|
| 1463 | + |
|
| 1464 | + /** |
|
| 1465 | + * If this collection has already been initialized with |
|
| 1466 | + * an identical criteria, it returns the collection. |
|
| 1467 | + * Otherwise if this Channel is new, it will return |
|
| 1468 | + * an empty collection; or if this Channel has previously |
|
| 1469 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1470 | + * |
|
| 1471 | + * This method is protected by default in order to keep the public |
|
| 1472 | + * api reasonable. You can provide public methods for those you |
|
| 1473 | + * actually need in Channel. |
|
| 1474 | + * |
|
| 1475 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1476 | + * @param ConnectionInterface $con optional connection object |
|
| 1477 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1478 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1479 | + */ |
|
| 1480 | + public function getSubscriptionsJoinInput(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1481 | + { |
|
| 1482 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1483 | + $query->joinWith('Input', $joinBehavior); |
|
| 1484 | + |
|
| 1485 | + return $this->getSubscriptions($query, $con); |
|
| 1486 | + } |
|
| 1487 | + |
|
| 1488 | + |
|
| 1489 | + /** |
|
| 1490 | + * If this collection has already been initialized with |
|
| 1491 | + * an identical criteria, it returns the collection. |
|
| 1492 | + * Otherwise if this Channel is new, it will return |
|
| 1493 | + * an empty collection; or if this Channel has previously |
|
| 1494 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1495 | + * |
|
| 1496 | + * This method is protected by default in order to keep the public |
|
| 1497 | + * api reasonable. You can provide public methods for those you |
|
| 1498 | + * actually need in Channel. |
|
| 1499 | + * |
|
| 1500 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1501 | + * @param ConnectionInterface $con optional connection object |
|
| 1502 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1503 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1504 | + */ |
|
| 1505 | + public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1506 | + { |
|
| 1507 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1508 | + $query->joinWith('User', $joinBehavior); |
|
| 1509 | + |
|
| 1510 | + return $this->getSubscriptions($query, $con); |
|
| 1511 | + } |
|
| 1512 | + |
|
| 1513 | + /** |
|
| 1514 | + * Clears the current object, sets all attributes to their default values and removes |
|
| 1515 | + * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 1516 | + * change of those foreign objects when you call `save` there). |
|
| 1517 | + */ |
|
| 1518 | + public function clear() |
|
| 1519 | + { |
|
| 1520 | + if (null !== $this->aInstance) { |
|
| 1521 | + $this->aInstance->removeChannel($this); |
|
| 1522 | + } |
|
| 1523 | + $this->id = null; |
|
| 1524 | + $this->instance_name = null; |
|
| 1525 | + $this->name = null; |
|
| 1526 | + $this->alreadyInSave = false; |
|
| 1527 | + $this->clearAllReferences(); |
|
| 1528 | + $this->resetModified(); |
|
| 1529 | + $this->setNew(true); |
|
| 1530 | + $this->setDeleted(false); |
|
| 1531 | + } |
|
| 1532 | + |
|
| 1533 | + /** |
|
| 1534 | + * Resets all references and back-references to other model objects or collections of model objects. |
|
| 1535 | + * |
|
| 1536 | + * This method is used to reset all php object references (not the actual reference in the database). |
|
| 1537 | + * Necessary for object serialisation. |
|
| 1538 | + * |
|
| 1539 | + * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 1540 | + */ |
|
| 1541 | + public function clearAllReferences($deep = false) |
|
| 1542 | + { |
|
| 1543 | + if ($deep) { |
|
| 1544 | + if ($this->collSubscriptions) { |
|
| 1545 | + foreach ($this->collSubscriptions as $o) { |
|
| 1546 | + $o->clearAllReferences($deep); |
|
| 1547 | + } |
|
| 1548 | + } |
|
| 1549 | + } // if ($deep) |
|
| 1550 | + |
|
| 1551 | + $this->collSubscriptions = null; |
|
| 1552 | + $this->aInstance = null; |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + /** |
|
| 1556 | + * Return the string representation of this object |
|
| 1557 | + * |
|
| 1558 | + * @return string |
|
| 1559 | + */ |
|
| 1560 | + public function __toString() |
|
| 1561 | + { |
|
| 1562 | + return (string) $this->exportTo(ChannelTableMap::DEFAULT_STRING_FORMAT); |
|
| 1563 | + } |
|
| 1564 | + |
|
| 1565 | + /** |
|
| 1566 | + * Code to be run before persisting the object |
|
| 1567 | + * @param ConnectionInterface $con |
|
| 1568 | + * @return boolean |
|
| 1569 | + */ |
|
| 1570 | + public function preSave(ConnectionInterface $con = null) |
|
| 1571 | + { |
|
| 1572 | + return true; |
|
| 1573 | + } |
|
| 1574 | + |
|
| 1575 | + /** |
|
| 1576 | + * Code to be run after persisting the object |
|
| 1577 | + * @param ConnectionInterface $con |
|
| 1578 | + */ |
|
| 1579 | + public function postSave(ConnectionInterface $con = null) |
|
| 1580 | + { |
|
| 1581 | + |
|
| 1582 | + } |
|
| 1583 | + |
|
| 1584 | + /** |
|
| 1585 | + * Code to be run before inserting to database |
|
| 1586 | + * @param ConnectionInterface $con |
|
| 1587 | + * @return boolean |
|
| 1588 | + */ |
|
| 1589 | + public function preInsert(ConnectionInterface $con = null) |
|
| 1590 | + { |
|
| 1591 | + return true; |
|
| 1592 | + } |
|
| 1593 | + |
|
| 1594 | + /** |
|
| 1595 | + * Code to be run after inserting to database |
|
| 1596 | + * @param ConnectionInterface $con |
|
| 1597 | + */ |
|
| 1598 | + public function postInsert(ConnectionInterface $con = null) |
|
| 1599 | + { |
|
| 1600 | + |
|
| 1601 | + } |
|
| 1602 | + |
|
| 1603 | + /** |
|
| 1604 | + * Code to be run before updating the object in database |
|
| 1605 | + * @param ConnectionInterface $con |
|
| 1606 | + * @return boolean |
|
| 1607 | + */ |
|
| 1608 | + public function preUpdate(ConnectionInterface $con = null) |
|
| 1609 | + { |
|
| 1610 | + return true; |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + /** |
|
| 1614 | + * Code to be run after updating the object in database |
|
| 1615 | + * @param ConnectionInterface $con |
|
| 1616 | + */ |
|
| 1617 | + public function postUpdate(ConnectionInterface $con = null) |
|
| 1618 | + { |
|
| 1619 | + |
|
| 1620 | + } |
|
| 1621 | + |
|
| 1622 | + /** |
|
| 1623 | + * Code to be run before deleting the object in database |
|
| 1624 | + * @param ConnectionInterface $con |
|
| 1625 | + * @return boolean |
|
| 1626 | + */ |
|
| 1627 | + public function preDelete(ConnectionInterface $con = null) |
|
| 1628 | + { |
|
| 1629 | + return true; |
|
| 1630 | + } |
|
| 1631 | + |
|
| 1632 | + /** |
|
| 1633 | + * Code to be run after deleting the object in database |
|
| 1634 | + * @param ConnectionInterface $con |
|
| 1635 | + */ |
|
| 1636 | + public function postDelete(ConnectionInterface $con = null) |
|
| 1637 | + { |
|
| 1638 | + |
|
| 1639 | + } |
|
| 1640 | + |
|
| 1641 | + |
|
| 1642 | + /** |
|
| 1643 | + * Derived method to catches calls to undefined methods. |
|
| 1644 | + * |
|
| 1645 | + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 1646 | + * Allows to define default __call() behavior if you overwrite __call() |
|
| 1647 | + * |
|
| 1648 | + * @param string $name |
|
| 1649 | + * @param mixed $params |
|
| 1650 | + * |
|
| 1651 | + * @return array|string |
|
| 1652 | + */ |
|
| 1653 | + public function __call($name, $params) |
|
| 1654 | + { |
|
| 1655 | + if (0 === strpos($name, 'get')) { |
|
| 1656 | + $virtualColumn = substr($name, 3); |
|
| 1657 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1658 | + return $this->getVirtualColumn($virtualColumn); |
|
| 1659 | + } |
|
| 1660 | + |
|
| 1661 | + $virtualColumn = lcfirst($virtualColumn); |
|
| 1662 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1663 | + return $this->getVirtualColumn($virtualColumn); |
|
| 1664 | + } |
|
| 1665 | + } |
|
| 1666 | + |
|
| 1667 | + if (0 === strpos($name, 'from')) { |
|
| 1668 | + $format = substr($name, 4); |
|
| 1669 | + |
|
| 1670 | + return $this->importFrom($format, reset($params)); |
|
| 1671 | + } |
|
| 1672 | + |
|
| 1673 | + if (0 === strpos($name, 'to')) { |
|
| 1674 | + $format = substr($name, 2); |
|
| 1675 | + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 1676 | + |
|
| 1677 | + return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 1678 | + } |
|
| 1679 | + |
|
| 1680 | + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 1681 | + } |
|
| 1682 | 1682 | |
| 1683 | 1683 | } |
@@ -36,1898 +36,1898 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | abstract class Input implements ActiveRecordInterface |
| 38 | 38 | { |
| 39 | - /** |
|
| 40 | - * TableMap class name |
|
| 41 | - */ |
|
| 42 | - const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\InputTableMap'; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * attribute to determine if this object has previously been saved. |
|
| 47 | - * @var boolean |
|
| 48 | - */ |
|
| 49 | - protected $new = true; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * attribute to determine whether this object has been deleted. |
|
| 53 | - * @var boolean |
|
| 54 | - */ |
|
| 55 | - protected $deleted = false; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * The columns that have been modified in current object. |
|
| 59 | - * Tracking modified columns allows us to only update modified columns. |
|
| 60 | - * @var array |
|
| 61 | - */ |
|
| 62 | - protected $modifiedColumns = array(); |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * The (virtual) columns that are added at runtime |
|
| 66 | - * The formatters can add supplementary columns based on a resultset |
|
| 67 | - * @var array |
|
| 68 | - */ |
|
| 69 | - protected $virtualColumns = array(); |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * The value for the uuid field. |
|
| 73 | - * |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - protected $uuid; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * The value for the instance_name field. |
|
| 80 | - * |
|
| 81 | - * @var string |
|
| 82 | - */ |
|
| 83 | - protected $instance_name; |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * The value for the started field. |
|
| 87 | - * |
|
| 88 | - * @var \DateTime |
|
| 89 | - */ |
|
| 90 | - protected $started; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * The value for the input field. |
|
| 94 | - * |
|
| 95 | - * @var string |
|
| 96 | - */ |
|
| 97 | - protected $input; |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * The value for the network field. |
|
| 101 | - * |
|
| 102 | - * @var string |
|
| 103 | - */ |
|
| 104 | - protected $network; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * The value for the mux field. |
|
| 108 | - * |
|
| 109 | - * @var string |
|
| 110 | - */ |
|
| 111 | - protected $mux; |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * The value for the weight field. |
|
| 115 | - * |
|
| 116 | - * @var int |
|
| 117 | - */ |
|
| 118 | - protected $weight; |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @var ChildInstance |
|
| 122 | - */ |
|
| 123 | - protected $aInstance; |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 127 | - */ |
|
| 128 | - protected $collSubscriptions; |
|
| 129 | - protected $collSubscriptionsPartial; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Flag to prevent endless save loop, if this object is referenced |
|
| 133 | - * by another object which falls in this transaction. |
|
| 134 | - * |
|
| 135 | - * @var boolean |
|
| 136 | - */ |
|
| 137 | - protected $alreadyInSave = false; |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * An array of objects scheduled for deletion. |
|
| 141 | - * @var ObjectCollection|ChildSubscription[] |
|
| 142 | - */ |
|
| 143 | - protected $subscriptionsScheduledForDeletion = null; |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * Initializes internal state of Jalle19\StatusManager\Database\Base\Input object. |
|
| 147 | - */ |
|
| 148 | - public function __construct() |
|
| 149 | - { |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Returns whether the object has been modified. |
|
| 154 | - * |
|
| 155 | - * @return boolean True if the object has been modified. |
|
| 156 | - */ |
|
| 157 | - public function isModified() |
|
| 158 | - { |
|
| 159 | - return !!$this->modifiedColumns; |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Has specified column been modified? |
|
| 164 | - * |
|
| 165 | - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 166 | - * @return boolean True if $col has been modified. |
|
| 167 | - */ |
|
| 168 | - public function isColumnModified($col) |
|
| 169 | - { |
|
| 170 | - return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Get the columns that have been modified in this object. |
|
| 175 | - * @return array A unique list of the modified column names for this object. |
|
| 176 | - */ |
|
| 177 | - public function getModifiedColumns() |
|
| 178 | - { |
|
| 179 | - return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Returns whether the object has ever been saved. This will |
|
| 184 | - * be false, if the object was retrieved from storage or was created |
|
| 185 | - * and then saved. |
|
| 186 | - * |
|
| 187 | - * @return boolean true, if the object has never been persisted. |
|
| 188 | - */ |
|
| 189 | - public function isNew() |
|
| 190 | - { |
|
| 191 | - return $this->new; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * Setter for the isNew attribute. This method will be called |
|
| 196 | - * by Propel-generated children and objects. |
|
| 197 | - * |
|
| 198 | - * @param boolean $b the state of the object. |
|
| 199 | - */ |
|
| 200 | - public function setNew($b) |
|
| 201 | - { |
|
| 202 | - $this->new = (boolean) $b; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * Whether this object has been deleted. |
|
| 207 | - * @return boolean The deleted state of this object. |
|
| 208 | - */ |
|
| 209 | - public function isDeleted() |
|
| 210 | - { |
|
| 211 | - return $this->deleted; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Specify whether this object has been deleted. |
|
| 216 | - * @param boolean $b The deleted state of this object. |
|
| 217 | - * @return void |
|
| 218 | - */ |
|
| 219 | - public function setDeleted($b) |
|
| 220 | - { |
|
| 221 | - $this->deleted = (boolean) $b; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * Sets the modified state for the object to be false. |
|
| 226 | - * @param string $col If supplied, only the specified column is reset. |
|
| 227 | - * @return void |
|
| 228 | - */ |
|
| 229 | - public function resetModified($col = null) |
|
| 230 | - { |
|
| 231 | - if (null !== $col) { |
|
| 232 | - if (isset($this->modifiedColumns[$col])) { |
|
| 233 | - unset($this->modifiedColumns[$col]); |
|
| 234 | - } |
|
| 235 | - } else { |
|
| 236 | - $this->modifiedColumns = array(); |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * Compares this with another <code>Input</code> instance. If |
|
| 242 | - * <code>obj</code> is an instance of <code>Input</code>, delegates to |
|
| 243 | - * <code>equals(Input)</code>. Otherwise, returns <code>false</code>. |
|
| 244 | - * |
|
| 245 | - * @param mixed $obj The object to compare to. |
|
| 246 | - * @return boolean Whether equal to the object specified. |
|
| 247 | - */ |
|
| 248 | - public function equals($obj) |
|
| 249 | - { |
|
| 250 | - if (!$obj instanceof static) { |
|
| 251 | - return false; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - if ($this === $obj) { |
|
| 255 | - return true; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 259 | - return false; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Get the associative array of the virtual columns in this object |
|
| 267 | - * |
|
| 268 | - * @return array |
|
| 269 | - */ |
|
| 270 | - public function getVirtualColumns() |
|
| 271 | - { |
|
| 272 | - return $this->virtualColumns; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Checks the existence of a virtual column in this object |
|
| 277 | - * |
|
| 278 | - * @param string $name The virtual column name |
|
| 279 | - * @return boolean |
|
| 280 | - */ |
|
| 281 | - public function hasVirtualColumn($name) |
|
| 282 | - { |
|
| 283 | - return array_key_exists($name, $this->virtualColumns); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - /** |
|
| 287 | - * Get the value of a virtual column in this object |
|
| 288 | - * |
|
| 289 | - * @param string $name The virtual column name |
|
| 290 | - * @return mixed |
|
| 291 | - * |
|
| 292 | - * @throws PropelException |
|
| 293 | - */ |
|
| 294 | - public function getVirtualColumn($name) |
|
| 295 | - { |
|
| 296 | - if (!$this->hasVirtualColumn($name)) { |
|
| 297 | - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - return $this->virtualColumns[$name]; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Set the value of a virtual column in this object |
|
| 305 | - * |
|
| 306 | - * @param string $name The virtual column name |
|
| 307 | - * @param mixed $value The value to give to the virtual column |
|
| 308 | - * |
|
| 309 | - * @return $this|Input The current object, for fluid interface |
|
| 310 | - */ |
|
| 311 | - public function setVirtualColumn($name, $value) |
|
| 312 | - { |
|
| 313 | - $this->virtualColumns[$name] = $value; |
|
| 314 | - |
|
| 315 | - return $this; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Logs a message using Propel::log(). |
|
| 320 | - * |
|
| 321 | - * @param string $msg |
|
| 322 | - * @param int $priority One of the Propel::LOG_* logging levels |
|
| 323 | - * @return boolean |
|
| 324 | - */ |
|
| 325 | - protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 326 | - { |
|
| 327 | - return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * Export the current object properties to a string, using a given parser format |
|
| 332 | - * <code> |
|
| 333 | - * $book = BookQuery::create()->findPk(9012); |
|
| 334 | - * echo $book->exportTo('JSON'); |
|
| 335 | - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 336 | - * </code> |
|
| 337 | - * |
|
| 338 | - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 339 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 340 | - * @return string The exported data |
|
| 341 | - */ |
|
| 342 | - public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 343 | - { |
|
| 344 | - if (!$parser instanceof AbstractParser) { |
|
| 345 | - $parser = AbstractParser::getParser($parser); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - /** |
|
| 352 | - * Clean up internal collections prior to serializing |
|
| 353 | - * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 354 | - */ |
|
| 355 | - public function __sleep() |
|
| 356 | - { |
|
| 357 | - $this->clearAllReferences(); |
|
| 358 | - |
|
| 359 | - $cls = new \ReflectionClass($this); |
|
| 360 | - $propertyNames = []; |
|
| 361 | - $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 362 | - |
|
| 363 | - foreach($serializableProperties as $property) { |
|
| 364 | - $propertyNames[] = $property->getName(); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - return $propertyNames; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - /** |
|
| 371 | - * Get the [uuid] column value. |
|
| 372 | - * |
|
| 373 | - * @return string |
|
| 374 | - */ |
|
| 375 | - public function getUuid() |
|
| 376 | - { |
|
| 377 | - return $this->uuid; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * Get the [instance_name] column value. |
|
| 382 | - * |
|
| 383 | - * @return string |
|
| 384 | - */ |
|
| 385 | - public function getInstanceName() |
|
| 386 | - { |
|
| 387 | - return $this->instance_name; |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - /** |
|
| 391 | - * Get the [optionally formatted] temporal [started] column value. |
|
| 392 | - * |
|
| 393 | - * |
|
| 394 | - * @param string $format The date/time format string (either date()-style or strftime()-style). |
|
| 395 | - * If format is NULL, then the raw DateTime object will be returned. |
|
| 396 | - * |
|
| 397 | - * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
|
| 398 | - * |
|
| 399 | - * @throws PropelException - if unable to parse/validate the date/time value. |
|
| 400 | - */ |
|
| 401 | - public function getStarted($format = NULL) |
|
| 402 | - { |
|
| 403 | - if ($format === null) { |
|
| 404 | - return $this->started; |
|
| 405 | - } else { |
|
| 406 | - return $this->started instanceof \DateTime ? $this->started->format($format) : null; |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - /** |
|
| 411 | - * Get the [input] column value. |
|
| 412 | - * |
|
| 413 | - * @return string |
|
| 414 | - */ |
|
| 415 | - public function getInput() |
|
| 416 | - { |
|
| 417 | - return $this->input; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - /** |
|
| 421 | - * Get the [network] column value. |
|
| 422 | - * |
|
| 423 | - * @return string |
|
| 424 | - */ |
|
| 425 | - public function getNetwork() |
|
| 426 | - { |
|
| 427 | - return $this->network; |
|
| 428 | - } |
|
| 429 | - |
|
| 430 | - /** |
|
| 431 | - * Get the [mux] column value. |
|
| 432 | - * |
|
| 433 | - * @return string |
|
| 434 | - */ |
|
| 435 | - public function getMux() |
|
| 436 | - { |
|
| 437 | - return $this->mux; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * Get the [weight] column value. |
|
| 442 | - * |
|
| 443 | - * @return int |
|
| 444 | - */ |
|
| 445 | - public function getWeight() |
|
| 446 | - { |
|
| 447 | - return $this->weight; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - /** |
|
| 451 | - * Set the value of [uuid] column. |
|
| 452 | - * |
|
| 453 | - * @param string $v new value |
|
| 454 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 455 | - */ |
|
| 456 | - public function setUuid($v) |
|
| 457 | - { |
|
| 458 | - if ($v !== null) { |
|
| 459 | - $v = (string) $v; |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - if ($this->uuid !== $v) { |
|
| 463 | - $this->uuid = $v; |
|
| 464 | - $this->modifiedColumns[InputTableMap::COL_UUID] = true; |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - return $this; |
|
| 468 | - } // setUuid() |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * Set the value of [instance_name] column. |
|
| 472 | - * |
|
| 473 | - * @param string $v new value |
|
| 474 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 475 | - */ |
|
| 476 | - public function setInstanceName($v) |
|
| 477 | - { |
|
| 478 | - if ($v !== null) { |
|
| 479 | - $v = (string) $v; |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - if ($this->instance_name !== $v) { |
|
| 483 | - $this->instance_name = $v; |
|
| 484 | - $this->modifiedColumns[InputTableMap::COL_INSTANCE_NAME] = true; |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
| 488 | - $this->aInstance = null; |
|
| 489 | - } |
|
| 490 | - |
|
| 491 | - return $this; |
|
| 492 | - } // setInstanceName() |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * Sets the value of [started] column to a normalized version of the date/time value specified. |
|
| 496 | - * |
|
| 497 | - * @param mixed $v string, integer (timestamp), or \DateTime value. |
|
| 498 | - * Empty strings are treated as NULL. |
|
| 499 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 500 | - */ |
|
| 501 | - public function setStarted($v) |
|
| 502 | - { |
|
| 503 | - $dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
|
| 504 | - if ($this->started !== null || $dt !== null) { |
|
| 505 | - if ($this->started === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->started->format("Y-m-d H:i:s")) { |
|
| 506 | - $this->started = $dt === null ? null : clone $dt; |
|
| 507 | - $this->modifiedColumns[InputTableMap::COL_STARTED] = true; |
|
| 508 | - } |
|
| 509 | - } // if either are not null |
|
| 510 | - |
|
| 511 | - return $this; |
|
| 512 | - } // setStarted() |
|
| 513 | - |
|
| 514 | - /** |
|
| 515 | - * Set the value of [input] column. |
|
| 516 | - * |
|
| 517 | - * @param string $v new value |
|
| 518 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 519 | - */ |
|
| 520 | - public function setInput($v) |
|
| 521 | - { |
|
| 522 | - if ($v !== null) { |
|
| 523 | - $v = (string) $v; |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - if ($this->input !== $v) { |
|
| 527 | - $this->input = $v; |
|
| 528 | - $this->modifiedColumns[InputTableMap::COL_INPUT] = true; |
|
| 529 | - } |
|
| 530 | - |
|
| 531 | - return $this; |
|
| 532 | - } // setInput() |
|
| 533 | - |
|
| 534 | - /** |
|
| 535 | - * Set the value of [network] column. |
|
| 536 | - * |
|
| 537 | - * @param string $v new value |
|
| 538 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 539 | - */ |
|
| 540 | - public function setNetwork($v) |
|
| 541 | - { |
|
| 542 | - if ($v !== null) { |
|
| 543 | - $v = (string) $v; |
|
| 544 | - } |
|
| 545 | - |
|
| 546 | - if ($this->network !== $v) { |
|
| 547 | - $this->network = $v; |
|
| 548 | - $this->modifiedColumns[InputTableMap::COL_NETWORK] = true; |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - return $this; |
|
| 552 | - } // setNetwork() |
|
| 553 | - |
|
| 554 | - /** |
|
| 555 | - * Set the value of [mux] column. |
|
| 556 | - * |
|
| 557 | - * @param string $v new value |
|
| 558 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 559 | - */ |
|
| 560 | - public function setMux($v) |
|
| 561 | - { |
|
| 562 | - if ($v !== null) { |
|
| 563 | - $v = (string) $v; |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - if ($this->mux !== $v) { |
|
| 567 | - $this->mux = $v; |
|
| 568 | - $this->modifiedColumns[InputTableMap::COL_MUX] = true; |
|
| 569 | - } |
|
| 570 | - |
|
| 571 | - return $this; |
|
| 572 | - } // setMux() |
|
| 573 | - |
|
| 574 | - /** |
|
| 575 | - * Set the value of [weight] column. |
|
| 576 | - * |
|
| 577 | - * @param int $v new value |
|
| 578 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 579 | - */ |
|
| 580 | - public function setWeight($v) |
|
| 581 | - { |
|
| 582 | - if ($v !== null) { |
|
| 583 | - $v = (int) $v; |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - if ($this->weight !== $v) { |
|
| 587 | - $this->weight = $v; |
|
| 588 | - $this->modifiedColumns[InputTableMap::COL_WEIGHT] = true; |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - return $this; |
|
| 592 | - } // setWeight() |
|
| 593 | - |
|
| 594 | - /** |
|
| 595 | - * Indicates whether the columns in this object are only set to default values. |
|
| 596 | - * |
|
| 597 | - * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 598 | - * modified _and_ has some values set which are non-default. |
|
| 599 | - * |
|
| 600 | - * @return boolean Whether the columns in this object are only been set with default values. |
|
| 601 | - */ |
|
| 602 | - public function hasOnlyDefaultValues() |
|
| 603 | - { |
|
| 604 | - // otherwise, everything was equal, so return TRUE |
|
| 605 | - return true; |
|
| 606 | - } // hasOnlyDefaultValues() |
|
| 607 | - |
|
| 608 | - /** |
|
| 609 | - * Hydrates (populates) the object variables with values from the database resultset. |
|
| 610 | - * |
|
| 611 | - * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 612 | - * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 613 | - * for results of JOIN queries where the resultset row includes columns from two or |
|
| 614 | - * more tables. |
|
| 615 | - * |
|
| 616 | - * @param array $row The row returned by DataFetcher->fetch(). |
|
| 617 | - * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 618 | - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 619 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 39 | + /** |
|
| 40 | + * TableMap class name |
|
| 41 | + */ |
|
| 42 | + const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\InputTableMap'; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * attribute to determine if this object has previously been saved. |
|
| 47 | + * @var boolean |
|
| 48 | + */ |
|
| 49 | + protected $new = true; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * attribute to determine whether this object has been deleted. |
|
| 53 | + * @var boolean |
|
| 54 | + */ |
|
| 55 | + protected $deleted = false; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * The columns that have been modified in current object. |
|
| 59 | + * Tracking modified columns allows us to only update modified columns. |
|
| 60 | + * @var array |
|
| 61 | + */ |
|
| 62 | + protected $modifiedColumns = array(); |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * The (virtual) columns that are added at runtime |
|
| 66 | + * The formatters can add supplementary columns based on a resultset |
|
| 67 | + * @var array |
|
| 68 | + */ |
|
| 69 | + protected $virtualColumns = array(); |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * The value for the uuid field. |
|
| 73 | + * |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + protected $uuid; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * The value for the instance_name field. |
|
| 80 | + * |
|
| 81 | + * @var string |
|
| 82 | + */ |
|
| 83 | + protected $instance_name; |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * The value for the started field. |
|
| 87 | + * |
|
| 88 | + * @var \DateTime |
|
| 89 | + */ |
|
| 90 | + protected $started; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * The value for the input field. |
|
| 94 | + * |
|
| 95 | + * @var string |
|
| 96 | + */ |
|
| 97 | + protected $input; |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * The value for the network field. |
|
| 101 | + * |
|
| 102 | + * @var string |
|
| 103 | + */ |
|
| 104 | + protected $network; |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * The value for the mux field. |
|
| 108 | + * |
|
| 109 | + * @var string |
|
| 110 | + */ |
|
| 111 | + protected $mux; |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * The value for the weight field. |
|
| 115 | + * |
|
| 116 | + * @var int |
|
| 117 | + */ |
|
| 118 | + protected $weight; |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @var ChildInstance |
|
| 122 | + */ |
|
| 123 | + protected $aInstance; |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 127 | + */ |
|
| 128 | + protected $collSubscriptions; |
|
| 129 | + protected $collSubscriptionsPartial; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Flag to prevent endless save loop, if this object is referenced |
|
| 133 | + * by another object which falls in this transaction. |
|
| 134 | + * |
|
| 135 | + * @var boolean |
|
| 136 | + */ |
|
| 137 | + protected $alreadyInSave = false; |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * An array of objects scheduled for deletion. |
|
| 141 | + * @var ObjectCollection|ChildSubscription[] |
|
| 142 | + */ |
|
| 143 | + protected $subscriptionsScheduledForDeletion = null; |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * Initializes internal state of Jalle19\StatusManager\Database\Base\Input object. |
|
| 147 | + */ |
|
| 148 | + public function __construct() |
|
| 149 | + { |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Returns whether the object has been modified. |
|
| 154 | + * |
|
| 155 | + * @return boolean True if the object has been modified. |
|
| 156 | + */ |
|
| 157 | + public function isModified() |
|
| 158 | + { |
|
| 159 | + return !!$this->modifiedColumns; |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Has specified column been modified? |
|
| 164 | + * |
|
| 165 | + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 166 | + * @return boolean True if $col has been modified. |
|
| 167 | + */ |
|
| 168 | + public function isColumnModified($col) |
|
| 169 | + { |
|
| 170 | + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Get the columns that have been modified in this object. |
|
| 175 | + * @return array A unique list of the modified column names for this object. |
|
| 176 | + */ |
|
| 177 | + public function getModifiedColumns() |
|
| 178 | + { |
|
| 179 | + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Returns whether the object has ever been saved. This will |
|
| 184 | + * be false, if the object was retrieved from storage or was created |
|
| 185 | + * and then saved. |
|
| 186 | + * |
|
| 187 | + * @return boolean true, if the object has never been persisted. |
|
| 188 | + */ |
|
| 189 | + public function isNew() |
|
| 190 | + { |
|
| 191 | + return $this->new; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * Setter for the isNew attribute. This method will be called |
|
| 196 | + * by Propel-generated children and objects. |
|
| 197 | + * |
|
| 198 | + * @param boolean $b the state of the object. |
|
| 199 | + */ |
|
| 200 | + public function setNew($b) |
|
| 201 | + { |
|
| 202 | + $this->new = (boolean) $b; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * Whether this object has been deleted. |
|
| 207 | + * @return boolean The deleted state of this object. |
|
| 208 | + */ |
|
| 209 | + public function isDeleted() |
|
| 210 | + { |
|
| 211 | + return $this->deleted; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Specify whether this object has been deleted. |
|
| 216 | + * @param boolean $b The deleted state of this object. |
|
| 217 | + * @return void |
|
| 218 | + */ |
|
| 219 | + public function setDeleted($b) |
|
| 220 | + { |
|
| 221 | + $this->deleted = (boolean) $b; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * Sets the modified state for the object to be false. |
|
| 226 | + * @param string $col If supplied, only the specified column is reset. |
|
| 227 | + * @return void |
|
| 228 | + */ |
|
| 229 | + public function resetModified($col = null) |
|
| 230 | + { |
|
| 231 | + if (null !== $col) { |
|
| 232 | + if (isset($this->modifiedColumns[$col])) { |
|
| 233 | + unset($this->modifiedColumns[$col]); |
|
| 234 | + } |
|
| 235 | + } else { |
|
| 236 | + $this->modifiedColumns = array(); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Compares this with another <code>Input</code> instance. If |
|
| 242 | + * <code>obj</code> is an instance of <code>Input</code>, delegates to |
|
| 243 | + * <code>equals(Input)</code>. Otherwise, returns <code>false</code>. |
|
| 244 | + * |
|
| 245 | + * @param mixed $obj The object to compare to. |
|
| 246 | + * @return boolean Whether equal to the object specified. |
|
| 247 | + */ |
|
| 248 | + public function equals($obj) |
|
| 249 | + { |
|
| 250 | + if (!$obj instanceof static) { |
|
| 251 | + return false; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + if ($this === $obj) { |
|
| 255 | + return true; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 259 | + return false; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Get the associative array of the virtual columns in this object |
|
| 267 | + * |
|
| 268 | + * @return array |
|
| 269 | + */ |
|
| 270 | + public function getVirtualColumns() |
|
| 271 | + { |
|
| 272 | + return $this->virtualColumns; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * Checks the existence of a virtual column in this object |
|
| 277 | + * |
|
| 278 | + * @param string $name The virtual column name |
|
| 279 | + * @return boolean |
|
| 280 | + */ |
|
| 281 | + public function hasVirtualColumn($name) |
|
| 282 | + { |
|
| 283 | + return array_key_exists($name, $this->virtualColumns); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + /** |
|
| 287 | + * Get the value of a virtual column in this object |
|
| 288 | + * |
|
| 289 | + * @param string $name The virtual column name |
|
| 290 | + * @return mixed |
|
| 291 | + * |
|
| 292 | + * @throws PropelException |
|
| 293 | + */ |
|
| 294 | + public function getVirtualColumn($name) |
|
| 295 | + { |
|
| 296 | + if (!$this->hasVirtualColumn($name)) { |
|
| 297 | + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + return $this->virtualColumns[$name]; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Set the value of a virtual column in this object |
|
| 305 | + * |
|
| 306 | + * @param string $name The virtual column name |
|
| 307 | + * @param mixed $value The value to give to the virtual column |
|
| 308 | + * |
|
| 309 | + * @return $this|Input The current object, for fluid interface |
|
| 310 | + */ |
|
| 311 | + public function setVirtualColumn($name, $value) |
|
| 312 | + { |
|
| 313 | + $this->virtualColumns[$name] = $value; |
|
| 314 | + |
|
| 315 | + return $this; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Logs a message using Propel::log(). |
|
| 320 | + * |
|
| 321 | + * @param string $msg |
|
| 322 | + * @param int $priority One of the Propel::LOG_* logging levels |
|
| 323 | + * @return boolean |
|
| 324 | + */ |
|
| 325 | + protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 326 | + { |
|
| 327 | + return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * Export the current object properties to a string, using a given parser format |
|
| 332 | + * <code> |
|
| 333 | + * $book = BookQuery::create()->findPk(9012); |
|
| 334 | + * echo $book->exportTo('JSON'); |
|
| 335 | + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 336 | + * </code> |
|
| 337 | + * |
|
| 338 | + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 339 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 340 | + * @return string The exported data |
|
| 341 | + */ |
|
| 342 | + public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 343 | + { |
|
| 344 | + if (!$parser instanceof AbstractParser) { |
|
| 345 | + $parser = AbstractParser::getParser($parser); |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * Clean up internal collections prior to serializing |
|
| 353 | + * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 354 | + */ |
|
| 355 | + public function __sleep() |
|
| 356 | + { |
|
| 357 | + $this->clearAllReferences(); |
|
| 358 | + |
|
| 359 | + $cls = new \ReflectionClass($this); |
|
| 360 | + $propertyNames = []; |
|
| 361 | + $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 362 | + |
|
| 363 | + foreach($serializableProperties as $property) { |
|
| 364 | + $propertyNames[] = $property->getName(); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + return $propertyNames; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + /** |
|
| 371 | + * Get the [uuid] column value. |
|
| 372 | + * |
|
| 373 | + * @return string |
|
| 374 | + */ |
|
| 375 | + public function getUuid() |
|
| 376 | + { |
|
| 377 | + return $this->uuid; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * Get the [instance_name] column value. |
|
| 382 | + * |
|
| 383 | + * @return string |
|
| 384 | + */ |
|
| 385 | + public function getInstanceName() |
|
| 386 | + { |
|
| 387 | + return $this->instance_name; |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + /** |
|
| 391 | + * Get the [optionally formatted] temporal [started] column value. |
|
| 392 | + * |
|
| 393 | + * |
|
| 394 | + * @param string $format The date/time format string (either date()-style or strftime()-style). |
|
| 395 | + * If format is NULL, then the raw DateTime object will be returned. |
|
| 396 | + * |
|
| 397 | + * @return string|DateTime Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL |
|
| 398 | + * |
|
| 399 | + * @throws PropelException - if unable to parse/validate the date/time value. |
|
| 400 | + */ |
|
| 401 | + public function getStarted($format = NULL) |
|
| 402 | + { |
|
| 403 | + if ($format === null) { |
|
| 404 | + return $this->started; |
|
| 405 | + } else { |
|
| 406 | + return $this->started instanceof \DateTime ? $this->started->format($format) : null; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Get the [input] column value. |
|
| 412 | + * |
|
| 413 | + * @return string |
|
| 414 | + */ |
|
| 415 | + public function getInput() |
|
| 416 | + { |
|
| 417 | + return $this->input; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + /** |
|
| 421 | + * Get the [network] column value. |
|
| 422 | + * |
|
| 423 | + * @return string |
|
| 424 | + */ |
|
| 425 | + public function getNetwork() |
|
| 426 | + { |
|
| 427 | + return $this->network; |
|
| 428 | + } |
|
| 429 | + |
|
| 430 | + /** |
|
| 431 | + * Get the [mux] column value. |
|
| 432 | + * |
|
| 433 | + * @return string |
|
| 434 | + */ |
|
| 435 | + public function getMux() |
|
| 436 | + { |
|
| 437 | + return $this->mux; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * Get the [weight] column value. |
|
| 442 | + * |
|
| 443 | + * @return int |
|
| 444 | + */ |
|
| 445 | + public function getWeight() |
|
| 446 | + { |
|
| 447 | + return $this->weight; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + /** |
|
| 451 | + * Set the value of [uuid] column. |
|
| 452 | + * |
|
| 453 | + * @param string $v new value |
|
| 454 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 455 | + */ |
|
| 456 | + public function setUuid($v) |
|
| 457 | + { |
|
| 458 | + if ($v !== null) { |
|
| 459 | + $v = (string) $v; |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + if ($this->uuid !== $v) { |
|
| 463 | + $this->uuid = $v; |
|
| 464 | + $this->modifiedColumns[InputTableMap::COL_UUID] = true; |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + return $this; |
|
| 468 | + } // setUuid() |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * Set the value of [instance_name] column. |
|
| 472 | + * |
|
| 473 | + * @param string $v new value |
|
| 474 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 475 | + */ |
|
| 476 | + public function setInstanceName($v) |
|
| 477 | + { |
|
| 478 | + if ($v !== null) { |
|
| 479 | + $v = (string) $v; |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + if ($this->instance_name !== $v) { |
|
| 483 | + $this->instance_name = $v; |
|
| 484 | + $this->modifiedColumns[InputTableMap::COL_INSTANCE_NAME] = true; |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
| 488 | + $this->aInstance = null; |
|
| 489 | + } |
|
| 490 | + |
|
| 491 | + return $this; |
|
| 492 | + } // setInstanceName() |
|
| 493 | + |
|
| 494 | + /** |
|
| 495 | + * Sets the value of [started] column to a normalized version of the date/time value specified. |
|
| 496 | + * |
|
| 497 | + * @param mixed $v string, integer (timestamp), or \DateTime value. |
|
| 498 | + * Empty strings are treated as NULL. |
|
| 499 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 500 | + */ |
|
| 501 | + public function setStarted($v) |
|
| 502 | + { |
|
| 503 | + $dt = PropelDateTime::newInstance($v, null, 'DateTime'); |
|
| 504 | + if ($this->started !== null || $dt !== null) { |
|
| 505 | + if ($this->started === null || $dt === null || $dt->format("Y-m-d H:i:s") !== $this->started->format("Y-m-d H:i:s")) { |
|
| 506 | + $this->started = $dt === null ? null : clone $dt; |
|
| 507 | + $this->modifiedColumns[InputTableMap::COL_STARTED] = true; |
|
| 508 | + } |
|
| 509 | + } // if either are not null |
|
| 510 | + |
|
| 511 | + return $this; |
|
| 512 | + } // setStarted() |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * Set the value of [input] column. |
|
| 516 | + * |
|
| 517 | + * @param string $v new value |
|
| 518 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 519 | + */ |
|
| 520 | + public function setInput($v) |
|
| 521 | + { |
|
| 522 | + if ($v !== null) { |
|
| 523 | + $v = (string) $v; |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + if ($this->input !== $v) { |
|
| 527 | + $this->input = $v; |
|
| 528 | + $this->modifiedColumns[InputTableMap::COL_INPUT] = true; |
|
| 529 | + } |
|
| 530 | + |
|
| 531 | + return $this; |
|
| 532 | + } // setInput() |
|
| 533 | + |
|
| 534 | + /** |
|
| 535 | + * Set the value of [network] column. |
|
| 536 | + * |
|
| 537 | + * @param string $v new value |
|
| 538 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 539 | + */ |
|
| 540 | + public function setNetwork($v) |
|
| 541 | + { |
|
| 542 | + if ($v !== null) { |
|
| 543 | + $v = (string) $v; |
|
| 544 | + } |
|
| 545 | + |
|
| 546 | + if ($this->network !== $v) { |
|
| 547 | + $this->network = $v; |
|
| 548 | + $this->modifiedColumns[InputTableMap::COL_NETWORK] = true; |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + return $this; |
|
| 552 | + } // setNetwork() |
|
| 553 | + |
|
| 554 | + /** |
|
| 555 | + * Set the value of [mux] column. |
|
| 556 | + * |
|
| 557 | + * @param string $v new value |
|
| 558 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 559 | + */ |
|
| 560 | + public function setMux($v) |
|
| 561 | + { |
|
| 562 | + if ($v !== null) { |
|
| 563 | + $v = (string) $v; |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + if ($this->mux !== $v) { |
|
| 567 | + $this->mux = $v; |
|
| 568 | + $this->modifiedColumns[InputTableMap::COL_MUX] = true; |
|
| 569 | + } |
|
| 570 | + |
|
| 571 | + return $this; |
|
| 572 | + } // setMux() |
|
| 573 | + |
|
| 574 | + /** |
|
| 575 | + * Set the value of [weight] column. |
|
| 576 | + * |
|
| 577 | + * @param int $v new value |
|
| 578 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 579 | + */ |
|
| 580 | + public function setWeight($v) |
|
| 581 | + { |
|
| 582 | + if ($v !== null) { |
|
| 583 | + $v = (int) $v; |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + if ($this->weight !== $v) { |
|
| 587 | + $this->weight = $v; |
|
| 588 | + $this->modifiedColumns[InputTableMap::COL_WEIGHT] = true; |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + return $this; |
|
| 592 | + } // setWeight() |
|
| 593 | + |
|
| 594 | + /** |
|
| 595 | + * Indicates whether the columns in this object are only set to default values. |
|
| 596 | + * |
|
| 597 | + * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 598 | + * modified _and_ has some values set which are non-default. |
|
| 599 | + * |
|
| 600 | + * @return boolean Whether the columns in this object are only been set with default values. |
|
| 601 | + */ |
|
| 602 | + public function hasOnlyDefaultValues() |
|
| 603 | + { |
|
| 604 | + // otherwise, everything was equal, so return TRUE |
|
| 605 | + return true; |
|
| 606 | + } // hasOnlyDefaultValues() |
|
| 607 | + |
|
| 608 | + /** |
|
| 609 | + * Hydrates (populates) the object variables with values from the database resultset. |
|
| 610 | + * |
|
| 611 | + * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 612 | + * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 613 | + * for results of JOIN queries where the resultset row includes columns from two or |
|
| 614 | + * more tables. |
|
| 615 | + * |
|
| 616 | + * @param array $row The row returned by DataFetcher->fetch(). |
|
| 617 | + * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 618 | + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 619 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 620 | 620 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
| 621 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 622 | - * |
|
| 623 | - * @return int next starting column |
|
| 624 | - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 625 | - */ |
|
| 626 | - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 627 | - { |
|
| 628 | - try { |
|
| 629 | - |
|
| 630 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : InputTableMap::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 631 | - $this->uuid = (null !== $col) ? (string) $col : null; |
|
| 632 | - |
|
| 633 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : InputTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 634 | - $this->instance_name = (null !== $col) ? (string) $col : null; |
|
| 635 | - |
|
| 636 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : InputTableMap::translateFieldName('Started', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 637 | - $this->started = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
|
| 638 | - |
|
| 639 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : InputTableMap::translateFieldName('Input', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 640 | - $this->input = (null !== $col) ? (string) $col : null; |
|
| 641 | - |
|
| 642 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : InputTableMap::translateFieldName('Network', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 643 | - $this->network = (null !== $col) ? (string) $col : null; |
|
| 644 | - |
|
| 645 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : InputTableMap::translateFieldName('Mux', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 646 | - $this->mux = (null !== $col) ? (string) $col : null; |
|
| 647 | - |
|
| 648 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : InputTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 649 | - $this->weight = (null !== $col) ? (int) $col : null; |
|
| 650 | - $this->resetModified(); |
|
| 651 | - |
|
| 652 | - $this->setNew(false); |
|
| 653 | - |
|
| 654 | - if ($rehydrate) { |
|
| 655 | - $this->ensureConsistency(); |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - return $startcol + 7; // 7 = InputTableMap::NUM_HYDRATE_COLUMNS. |
|
| 659 | - |
|
| 660 | - } catch (Exception $e) { |
|
| 661 | - throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Input'), 0, $e); |
|
| 662 | - } |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - /** |
|
| 666 | - * Checks and repairs the internal consistency of the object. |
|
| 667 | - * |
|
| 668 | - * This method is executed after an already-instantiated object is re-hydrated |
|
| 669 | - * from the database. It exists to check any foreign keys to make sure that |
|
| 670 | - * the objects related to the current object are correct based on foreign key. |
|
| 671 | - * |
|
| 672 | - * You can override this method in the stub class, but you should always invoke |
|
| 673 | - * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 674 | - * in case your model changes. |
|
| 675 | - * |
|
| 676 | - * @throws PropelException |
|
| 677 | - */ |
|
| 678 | - public function ensureConsistency() |
|
| 679 | - { |
|
| 680 | - if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
| 681 | - $this->aInstance = null; |
|
| 682 | - } |
|
| 683 | - } // ensureConsistency |
|
| 684 | - |
|
| 685 | - /** |
|
| 686 | - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 687 | - * |
|
| 688 | - * This will only work if the object has been saved and has a valid primary key set. |
|
| 689 | - * |
|
| 690 | - * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 691 | - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 692 | - * @return void |
|
| 693 | - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 694 | - */ |
|
| 695 | - public function reload($deep = false, ConnectionInterface $con = null) |
|
| 696 | - { |
|
| 697 | - if ($this->isDeleted()) { |
|
| 698 | - throw new PropelException("Cannot reload a deleted object."); |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - if ($this->isNew()) { |
|
| 702 | - throw new PropelException("Cannot reload an unsaved object."); |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - if ($con === null) { |
|
| 706 | - $con = Propel::getServiceContainer()->getReadConnection(InputTableMap::DATABASE_NAME); |
|
| 707 | - } |
|
| 708 | - |
|
| 709 | - // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 710 | - // already in the pool. |
|
| 711 | - |
|
| 712 | - $dataFetcher = ChildInputQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 713 | - $row = $dataFetcher->fetch(); |
|
| 714 | - $dataFetcher->close(); |
|
| 715 | - if (!$row) { |
|
| 716 | - throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 717 | - } |
|
| 718 | - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 719 | - |
|
| 720 | - if ($deep) { // also de-associate any related objects? |
|
| 721 | - |
|
| 722 | - $this->aInstance = null; |
|
| 723 | - $this->collSubscriptions = null; |
|
| 724 | - |
|
| 725 | - } // if (deep) |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - /** |
|
| 729 | - * Removes this object from datastore and sets delete attribute. |
|
| 730 | - * |
|
| 731 | - * @param ConnectionInterface $con |
|
| 732 | - * @return void |
|
| 733 | - * @throws PropelException |
|
| 734 | - * @see Input::setDeleted() |
|
| 735 | - * @see Input::isDeleted() |
|
| 736 | - */ |
|
| 737 | - public function delete(ConnectionInterface $con = null) |
|
| 738 | - { |
|
| 739 | - if ($this->isDeleted()) { |
|
| 740 | - throw new PropelException("This object has already been deleted."); |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - if ($con === null) { |
|
| 744 | - $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - $con->transaction(function () use ($con) { |
|
| 748 | - $deleteQuery = ChildInputQuery::create() |
|
| 749 | - ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 750 | - $ret = $this->preDelete($con); |
|
| 751 | - if ($ret) { |
|
| 752 | - $deleteQuery->delete($con); |
|
| 753 | - $this->postDelete($con); |
|
| 754 | - $this->setDeleted(true); |
|
| 755 | - } |
|
| 756 | - }); |
|
| 757 | - } |
|
| 758 | - |
|
| 759 | - /** |
|
| 760 | - * Persists this object to the database. |
|
| 761 | - * |
|
| 762 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 763 | - * All modified related objects will also be persisted in the doSave() |
|
| 764 | - * method. This method wraps all precipitate database operations in a |
|
| 765 | - * single transaction. |
|
| 766 | - * |
|
| 767 | - * @param ConnectionInterface $con |
|
| 768 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 769 | - * @throws PropelException |
|
| 770 | - * @see doSave() |
|
| 771 | - */ |
|
| 772 | - public function save(ConnectionInterface $con = null) |
|
| 773 | - { |
|
| 774 | - if ($this->isDeleted()) { |
|
| 775 | - throw new PropelException("You cannot save an object that has been deleted."); |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - if ($con === null) { |
|
| 779 | - $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - return $con->transaction(function () use ($con) { |
|
| 783 | - $isInsert = $this->isNew(); |
|
| 784 | - $ret = $this->preSave($con); |
|
| 785 | - if ($isInsert) { |
|
| 786 | - $ret = $ret && $this->preInsert($con); |
|
| 787 | - } else { |
|
| 788 | - $ret = $ret && $this->preUpdate($con); |
|
| 789 | - } |
|
| 790 | - if ($ret) { |
|
| 791 | - $affectedRows = $this->doSave($con); |
|
| 792 | - if ($isInsert) { |
|
| 793 | - $this->postInsert($con); |
|
| 794 | - } else { |
|
| 795 | - $this->postUpdate($con); |
|
| 796 | - } |
|
| 797 | - $this->postSave($con); |
|
| 798 | - InputTableMap::addInstanceToPool($this); |
|
| 799 | - } else { |
|
| 800 | - $affectedRows = 0; |
|
| 801 | - } |
|
| 802 | - |
|
| 803 | - return $affectedRows; |
|
| 804 | - }); |
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - /** |
|
| 808 | - * Performs the work of inserting or updating the row in the database. |
|
| 809 | - * |
|
| 810 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 811 | - * All related objects are also updated in this method. |
|
| 812 | - * |
|
| 813 | - * @param ConnectionInterface $con |
|
| 814 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 815 | - * @throws PropelException |
|
| 816 | - * @see save() |
|
| 817 | - */ |
|
| 818 | - protected function doSave(ConnectionInterface $con) |
|
| 819 | - { |
|
| 820 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 821 | - if (!$this->alreadyInSave) { |
|
| 822 | - $this->alreadyInSave = true; |
|
| 823 | - |
|
| 824 | - // We call the save method on the following object(s) if they |
|
| 825 | - // were passed to this object by their corresponding set |
|
| 826 | - // method. This object relates to these object(s) by a |
|
| 827 | - // foreign key reference. |
|
| 828 | - |
|
| 829 | - if ($this->aInstance !== null) { |
|
| 830 | - if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
| 831 | - $affectedRows += $this->aInstance->save($con); |
|
| 832 | - } |
|
| 833 | - $this->setInstance($this->aInstance); |
|
| 834 | - } |
|
| 835 | - |
|
| 836 | - if ($this->isNew() || $this->isModified()) { |
|
| 837 | - // persist changes |
|
| 838 | - if ($this->isNew()) { |
|
| 839 | - $this->doInsert($con); |
|
| 840 | - $affectedRows += 1; |
|
| 841 | - } else { |
|
| 842 | - $affectedRows += $this->doUpdate($con); |
|
| 843 | - } |
|
| 844 | - $this->resetModified(); |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 848 | - if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 849 | - foreach ($this->subscriptionsScheduledForDeletion as $subscription) { |
|
| 850 | - // need to save related object because we set the relation to null |
|
| 851 | - $subscription->save($con); |
|
| 852 | - } |
|
| 853 | - $this->subscriptionsScheduledForDeletion = null; |
|
| 854 | - } |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - if ($this->collSubscriptions !== null) { |
|
| 858 | - foreach ($this->collSubscriptions as $referrerFK) { |
|
| 859 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 860 | - $affectedRows += $referrerFK->save($con); |
|
| 861 | - } |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - $this->alreadyInSave = false; |
|
| 866 | - |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - return $affectedRows; |
|
| 870 | - } // doSave() |
|
| 871 | - |
|
| 872 | - /** |
|
| 873 | - * Insert the row in the database. |
|
| 874 | - * |
|
| 875 | - * @param ConnectionInterface $con |
|
| 876 | - * |
|
| 877 | - * @throws PropelException |
|
| 878 | - * @see doSave() |
|
| 879 | - */ |
|
| 880 | - protected function doInsert(ConnectionInterface $con) |
|
| 881 | - { |
|
| 882 | - $modifiedColumns = array(); |
|
| 883 | - $index = 0; |
|
| 884 | - |
|
| 885 | - |
|
| 886 | - // check the columns in natural order for more readable SQL queries |
|
| 887 | - if ($this->isColumnModified(InputTableMap::COL_UUID)) { |
|
| 888 | - $modifiedColumns[':p' . $index++] = 'uuid'; |
|
| 889 | - } |
|
| 890 | - if ($this->isColumnModified(InputTableMap::COL_INSTANCE_NAME)) { |
|
| 891 | - $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
| 892 | - } |
|
| 893 | - if ($this->isColumnModified(InputTableMap::COL_STARTED)) { |
|
| 894 | - $modifiedColumns[':p' . $index++] = 'started'; |
|
| 895 | - } |
|
| 896 | - if ($this->isColumnModified(InputTableMap::COL_INPUT)) { |
|
| 897 | - $modifiedColumns[':p' . $index++] = 'input'; |
|
| 898 | - } |
|
| 899 | - if ($this->isColumnModified(InputTableMap::COL_NETWORK)) { |
|
| 900 | - $modifiedColumns[':p' . $index++] = 'network'; |
|
| 901 | - } |
|
| 902 | - if ($this->isColumnModified(InputTableMap::COL_MUX)) { |
|
| 903 | - $modifiedColumns[':p' . $index++] = 'mux'; |
|
| 904 | - } |
|
| 905 | - if ($this->isColumnModified(InputTableMap::COL_WEIGHT)) { |
|
| 906 | - $modifiedColumns[':p' . $index++] = 'weight'; |
|
| 907 | - } |
|
| 908 | - |
|
| 909 | - $sql = sprintf( |
|
| 910 | - 'INSERT INTO input (%s) VALUES (%s)', |
|
| 911 | - implode(', ', $modifiedColumns), |
|
| 912 | - implode(', ', array_keys($modifiedColumns)) |
|
| 913 | - ); |
|
| 914 | - |
|
| 915 | - try { |
|
| 916 | - $stmt = $con->prepare($sql); |
|
| 917 | - foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 918 | - switch ($columnName) { |
|
| 919 | - case 'uuid': |
|
| 920 | - $stmt->bindValue($identifier, $this->uuid, PDO::PARAM_STR); |
|
| 921 | - break; |
|
| 922 | - case 'instance_name': |
|
| 923 | - $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
| 924 | - break; |
|
| 925 | - case 'started': |
|
| 926 | - $stmt->bindValue($identifier, $this->started ? $this->started->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
|
| 927 | - break; |
|
| 928 | - case 'input': |
|
| 929 | - $stmt->bindValue($identifier, $this->input, PDO::PARAM_STR); |
|
| 930 | - break; |
|
| 931 | - case 'network': |
|
| 932 | - $stmt->bindValue($identifier, $this->network, PDO::PARAM_STR); |
|
| 933 | - break; |
|
| 934 | - case 'mux': |
|
| 935 | - $stmt->bindValue($identifier, $this->mux, PDO::PARAM_STR); |
|
| 936 | - break; |
|
| 937 | - case 'weight': |
|
| 938 | - $stmt->bindValue($identifier, $this->weight, PDO::PARAM_INT); |
|
| 939 | - break; |
|
| 940 | - } |
|
| 941 | - } |
|
| 942 | - $stmt->execute(); |
|
| 943 | - } catch (Exception $e) { |
|
| 944 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 945 | - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - $this->setNew(false); |
|
| 949 | - } |
|
| 950 | - |
|
| 951 | - /** |
|
| 952 | - * Update the row in the database. |
|
| 953 | - * |
|
| 954 | - * @param ConnectionInterface $con |
|
| 955 | - * |
|
| 956 | - * @return Integer Number of updated rows |
|
| 957 | - * @see doSave() |
|
| 958 | - */ |
|
| 959 | - protected function doUpdate(ConnectionInterface $con) |
|
| 960 | - { |
|
| 961 | - $selectCriteria = $this->buildPkeyCriteria(); |
|
| 962 | - $valuesCriteria = $this->buildCriteria(); |
|
| 963 | - |
|
| 964 | - return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 965 | - } |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * Retrieves a field from the object by name passed in as a string. |
|
| 969 | - * |
|
| 970 | - * @param string $name name |
|
| 971 | - * @param string $type The type of fieldname the $name is of: |
|
| 972 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 973 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 974 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 975 | - * @return mixed Value of field. |
|
| 976 | - */ |
|
| 977 | - public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 978 | - { |
|
| 979 | - $pos = InputTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 980 | - $field = $this->getByPosition($pos); |
|
| 981 | - |
|
| 982 | - return $field; |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - /** |
|
| 986 | - * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 987 | - * Zero-based. |
|
| 988 | - * |
|
| 989 | - * @param int $pos position in xml schema |
|
| 990 | - * @return mixed Value of field at $pos |
|
| 991 | - */ |
|
| 992 | - public function getByPosition($pos) |
|
| 993 | - { |
|
| 994 | - switch ($pos) { |
|
| 995 | - case 0: |
|
| 996 | - return $this->getUuid(); |
|
| 997 | - break; |
|
| 998 | - case 1: |
|
| 999 | - return $this->getInstanceName(); |
|
| 1000 | - break; |
|
| 1001 | - case 2: |
|
| 1002 | - return $this->getStarted(); |
|
| 1003 | - break; |
|
| 1004 | - case 3: |
|
| 1005 | - return $this->getInput(); |
|
| 1006 | - break; |
|
| 1007 | - case 4: |
|
| 1008 | - return $this->getNetwork(); |
|
| 1009 | - break; |
|
| 1010 | - case 5: |
|
| 1011 | - return $this->getMux(); |
|
| 1012 | - break; |
|
| 1013 | - case 6: |
|
| 1014 | - return $this->getWeight(); |
|
| 1015 | - break; |
|
| 1016 | - default: |
|
| 1017 | - return null; |
|
| 1018 | - break; |
|
| 1019 | - } // switch() |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - /** |
|
| 1023 | - * Exports the object as an array. |
|
| 1024 | - * |
|
| 1025 | - * You can specify the key type of the array by passing one of the class |
|
| 1026 | - * type constants. |
|
| 1027 | - * |
|
| 1028 | - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1029 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1030 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 1031 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 1032 | - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 1033 | - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 1034 | - * |
|
| 1035 | - * @return array an associative array containing the field names (as keys) and field values |
|
| 1036 | - */ |
|
| 1037 | - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 1038 | - { |
|
| 1039 | - |
|
| 1040 | - if (isset($alreadyDumpedObjects['Input'][$this->hashCode()])) { |
|
| 1041 | - return '*RECURSION*'; |
|
| 1042 | - } |
|
| 1043 | - $alreadyDumpedObjects['Input'][$this->hashCode()] = true; |
|
| 1044 | - $keys = InputTableMap::getFieldNames($keyType); |
|
| 1045 | - $result = array( |
|
| 1046 | - $keys[0] => $this->getUuid(), |
|
| 1047 | - $keys[1] => $this->getInstanceName(), |
|
| 1048 | - $keys[2] => $this->getStarted(), |
|
| 1049 | - $keys[3] => $this->getInput(), |
|
| 1050 | - $keys[4] => $this->getNetwork(), |
|
| 1051 | - $keys[5] => $this->getMux(), |
|
| 1052 | - $keys[6] => $this->getWeight(), |
|
| 1053 | - ); |
|
| 1054 | - if ($result[$keys[2]] instanceof \DateTime) { |
|
| 1055 | - $result[$keys[2]] = $result[$keys[2]]->format('c'); |
|
| 1056 | - } |
|
| 1057 | - |
|
| 1058 | - $virtualColumns = $this->virtualColumns; |
|
| 1059 | - foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 1060 | - $result[$key] = $virtualColumn; |
|
| 1061 | - } |
|
| 1062 | - |
|
| 1063 | - if ($includeForeignObjects) { |
|
| 1064 | - if (null !== $this->aInstance) { |
|
| 1065 | - |
|
| 1066 | - switch ($keyType) { |
|
| 1067 | - case TableMap::TYPE_CAMELNAME: |
|
| 1068 | - $key = 'instance'; |
|
| 1069 | - break; |
|
| 1070 | - case TableMap::TYPE_FIELDNAME: |
|
| 1071 | - $key = 'instance'; |
|
| 1072 | - break; |
|
| 1073 | - default: |
|
| 1074 | - $key = 'Instance'; |
|
| 1075 | - } |
|
| 1076 | - |
|
| 1077 | - $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
| 1078 | - } |
|
| 1079 | - if (null !== $this->collSubscriptions) { |
|
| 1080 | - |
|
| 1081 | - switch ($keyType) { |
|
| 1082 | - case TableMap::TYPE_CAMELNAME: |
|
| 1083 | - $key = 'subscriptions'; |
|
| 1084 | - break; |
|
| 1085 | - case TableMap::TYPE_FIELDNAME: |
|
| 1086 | - $key = 'subscriptions'; |
|
| 1087 | - break; |
|
| 1088 | - default: |
|
| 1089 | - $key = 'Subscriptions'; |
|
| 1090 | - } |
|
| 1091 | - |
|
| 1092 | - $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 1093 | - } |
|
| 1094 | - } |
|
| 1095 | - |
|
| 1096 | - return $result; |
|
| 1097 | - } |
|
| 1098 | - |
|
| 1099 | - /** |
|
| 1100 | - * Sets a field from the object by name passed in as a string. |
|
| 1101 | - * |
|
| 1102 | - * @param string $name |
|
| 1103 | - * @param mixed $value field value |
|
| 1104 | - * @param string $type The type of fieldname the $name is of: |
|
| 1105 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 1106 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1107 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 1108 | - * @return $this|\Jalle19\StatusManager\Database\Input |
|
| 1109 | - */ |
|
| 1110 | - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 1111 | - { |
|
| 1112 | - $pos = InputTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 1113 | - |
|
| 1114 | - return $this->setByPosition($pos, $value); |
|
| 1115 | - } |
|
| 1116 | - |
|
| 1117 | - /** |
|
| 1118 | - * Sets a field from the object by Position as specified in the xml schema. |
|
| 1119 | - * Zero-based. |
|
| 1120 | - * |
|
| 1121 | - * @param int $pos position in xml schema |
|
| 1122 | - * @param mixed $value field value |
|
| 1123 | - * @return $this|\Jalle19\StatusManager\Database\Input |
|
| 1124 | - */ |
|
| 1125 | - public function setByPosition($pos, $value) |
|
| 1126 | - { |
|
| 1127 | - switch ($pos) { |
|
| 1128 | - case 0: |
|
| 1129 | - $this->setUuid($value); |
|
| 1130 | - break; |
|
| 1131 | - case 1: |
|
| 1132 | - $this->setInstanceName($value); |
|
| 1133 | - break; |
|
| 1134 | - case 2: |
|
| 1135 | - $this->setStarted($value); |
|
| 1136 | - break; |
|
| 1137 | - case 3: |
|
| 1138 | - $this->setInput($value); |
|
| 1139 | - break; |
|
| 1140 | - case 4: |
|
| 1141 | - $this->setNetwork($value); |
|
| 1142 | - break; |
|
| 1143 | - case 5: |
|
| 1144 | - $this->setMux($value); |
|
| 1145 | - break; |
|
| 1146 | - case 6: |
|
| 1147 | - $this->setWeight($value); |
|
| 1148 | - break; |
|
| 1149 | - } // switch() |
|
| 1150 | - |
|
| 1151 | - return $this; |
|
| 1152 | - } |
|
| 1153 | - |
|
| 1154 | - /** |
|
| 1155 | - * Populates the object using an array. |
|
| 1156 | - * |
|
| 1157 | - * This is particularly useful when populating an object from one of the |
|
| 1158 | - * request arrays (e.g. $_POST). This method goes through the column |
|
| 1159 | - * names, checking to see whether a matching key exists in populated |
|
| 1160 | - * array. If so the setByName() method is called for that column. |
|
| 1161 | - * |
|
| 1162 | - * You can specify the key type of the array by additionally passing one |
|
| 1163 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1164 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1165 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1166 | - * |
|
| 1167 | - * @param array $arr An array to populate the object from. |
|
| 1168 | - * @param string $keyType The type of keys the array uses. |
|
| 1169 | - * @return void |
|
| 1170 | - */ |
|
| 1171 | - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1172 | - { |
|
| 1173 | - $keys = InputTableMap::getFieldNames($keyType); |
|
| 1174 | - |
|
| 1175 | - if (array_key_exists($keys[0], $arr)) { |
|
| 1176 | - $this->setUuid($arr[$keys[0]]); |
|
| 1177 | - } |
|
| 1178 | - if (array_key_exists($keys[1], $arr)) { |
|
| 1179 | - $this->setInstanceName($arr[$keys[1]]); |
|
| 1180 | - } |
|
| 1181 | - if (array_key_exists($keys[2], $arr)) { |
|
| 1182 | - $this->setStarted($arr[$keys[2]]); |
|
| 1183 | - } |
|
| 1184 | - if (array_key_exists($keys[3], $arr)) { |
|
| 1185 | - $this->setInput($arr[$keys[3]]); |
|
| 1186 | - } |
|
| 1187 | - if (array_key_exists($keys[4], $arr)) { |
|
| 1188 | - $this->setNetwork($arr[$keys[4]]); |
|
| 1189 | - } |
|
| 1190 | - if (array_key_exists($keys[5], $arr)) { |
|
| 1191 | - $this->setMux($arr[$keys[5]]); |
|
| 1192 | - } |
|
| 1193 | - if (array_key_exists($keys[6], $arr)) { |
|
| 1194 | - $this->setWeight($arr[$keys[6]]); |
|
| 1195 | - } |
|
| 1196 | - } |
|
| 1197 | - |
|
| 1198 | - /** |
|
| 1199 | - * Populate the current object from a string, using a given parser format |
|
| 1200 | - * <code> |
|
| 1201 | - * $book = new Book(); |
|
| 1202 | - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 1203 | - * </code> |
|
| 1204 | - * |
|
| 1205 | - * You can specify the key type of the array by additionally passing one |
|
| 1206 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1207 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1208 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1209 | - * |
|
| 1210 | - * @param mixed $parser A AbstractParser instance, |
|
| 1211 | - * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 1212 | - * @param string $data The source data to import from |
|
| 1213 | - * @param string $keyType The type of keys the array uses. |
|
| 1214 | - * |
|
| 1215 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object, for fluid interface |
|
| 1216 | - */ |
|
| 1217 | - public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1218 | - { |
|
| 1219 | - if (!$parser instanceof AbstractParser) { |
|
| 1220 | - $parser = AbstractParser::getParser($parser); |
|
| 1221 | - } |
|
| 1222 | - |
|
| 1223 | - $this->fromArray($parser->toArray($data), $keyType); |
|
| 1224 | - |
|
| 1225 | - return $this; |
|
| 1226 | - } |
|
| 1227 | - |
|
| 1228 | - /** |
|
| 1229 | - * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1230 | - * |
|
| 1231 | - * @return Criteria The Criteria object containing all modified values. |
|
| 1232 | - */ |
|
| 1233 | - public function buildCriteria() |
|
| 1234 | - { |
|
| 1235 | - $criteria = new Criteria(InputTableMap::DATABASE_NAME); |
|
| 1236 | - |
|
| 1237 | - if ($this->isColumnModified(InputTableMap::COL_UUID)) { |
|
| 1238 | - $criteria->add(InputTableMap::COL_UUID, $this->uuid); |
|
| 1239 | - } |
|
| 1240 | - if ($this->isColumnModified(InputTableMap::COL_INSTANCE_NAME)) { |
|
| 1241 | - $criteria->add(InputTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
| 1242 | - } |
|
| 1243 | - if ($this->isColumnModified(InputTableMap::COL_STARTED)) { |
|
| 1244 | - $criteria->add(InputTableMap::COL_STARTED, $this->started); |
|
| 1245 | - } |
|
| 1246 | - if ($this->isColumnModified(InputTableMap::COL_INPUT)) { |
|
| 1247 | - $criteria->add(InputTableMap::COL_INPUT, $this->input); |
|
| 1248 | - } |
|
| 1249 | - if ($this->isColumnModified(InputTableMap::COL_NETWORK)) { |
|
| 1250 | - $criteria->add(InputTableMap::COL_NETWORK, $this->network); |
|
| 1251 | - } |
|
| 1252 | - if ($this->isColumnModified(InputTableMap::COL_MUX)) { |
|
| 1253 | - $criteria->add(InputTableMap::COL_MUX, $this->mux); |
|
| 1254 | - } |
|
| 1255 | - if ($this->isColumnModified(InputTableMap::COL_WEIGHT)) { |
|
| 1256 | - $criteria->add(InputTableMap::COL_WEIGHT, $this->weight); |
|
| 1257 | - } |
|
| 1258 | - |
|
| 1259 | - return $criteria; |
|
| 1260 | - } |
|
| 1261 | - |
|
| 1262 | - /** |
|
| 1263 | - * Builds a Criteria object containing the primary key for this object. |
|
| 1264 | - * |
|
| 1265 | - * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1266 | - * of whether or not they have been modified. |
|
| 1267 | - * |
|
| 1268 | - * @throws LogicException if no primary key is defined |
|
| 1269 | - * |
|
| 1270 | - * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1271 | - */ |
|
| 1272 | - public function buildPkeyCriteria() |
|
| 1273 | - { |
|
| 1274 | - $criteria = ChildInputQuery::create(); |
|
| 1275 | - $criteria->add(InputTableMap::COL_UUID, $this->uuid); |
|
| 1276 | - |
|
| 1277 | - return $criteria; |
|
| 1278 | - } |
|
| 1279 | - |
|
| 1280 | - /** |
|
| 1281 | - * If the primary key is not null, return the hashcode of the |
|
| 1282 | - * primary key. Otherwise, return the hash code of the object. |
|
| 1283 | - * |
|
| 1284 | - * @return int Hashcode |
|
| 1285 | - */ |
|
| 1286 | - public function hashCode() |
|
| 1287 | - { |
|
| 1288 | - $validPk = null !== $this->getUuid(); |
|
| 1289 | - |
|
| 1290 | - $validPrimaryKeyFKs = 0; |
|
| 1291 | - $primaryKeyFKs = []; |
|
| 1292 | - |
|
| 1293 | - if ($validPk) { |
|
| 1294 | - return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1295 | - } elseif ($validPrimaryKeyFKs) { |
|
| 1296 | - return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1297 | - } |
|
| 1298 | - |
|
| 1299 | - return spl_object_hash($this); |
|
| 1300 | - } |
|
| 1301 | - |
|
| 1302 | - /** |
|
| 1303 | - * Returns the primary key for this object (row). |
|
| 1304 | - * @return string |
|
| 1305 | - */ |
|
| 1306 | - public function getPrimaryKey() |
|
| 1307 | - { |
|
| 1308 | - return $this->getUuid(); |
|
| 1309 | - } |
|
| 1310 | - |
|
| 1311 | - /** |
|
| 1312 | - * Generic method to set the primary key (uuid column). |
|
| 1313 | - * |
|
| 1314 | - * @param string $key Primary key. |
|
| 1315 | - * @return void |
|
| 1316 | - */ |
|
| 1317 | - public function setPrimaryKey($key) |
|
| 1318 | - { |
|
| 1319 | - $this->setUuid($key); |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - /** |
|
| 1323 | - * Returns true if the primary key for this object is null. |
|
| 1324 | - * @return boolean |
|
| 1325 | - */ |
|
| 1326 | - public function isPrimaryKeyNull() |
|
| 1327 | - { |
|
| 1328 | - return null === $this->getUuid(); |
|
| 1329 | - } |
|
| 1330 | - |
|
| 1331 | - /** |
|
| 1332 | - * Sets contents of passed object to values from current object. |
|
| 1333 | - * |
|
| 1334 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1335 | - * objects. |
|
| 1336 | - * |
|
| 1337 | - * @param object $copyObj An object of \Jalle19\StatusManager\Database\Input (or compatible) type. |
|
| 1338 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1339 | - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1340 | - * @throws PropelException |
|
| 1341 | - */ |
|
| 1342 | - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1343 | - { |
|
| 1344 | - $copyObj->setUuid($this->getUuid()); |
|
| 1345 | - $copyObj->setInstanceName($this->getInstanceName()); |
|
| 1346 | - $copyObj->setStarted($this->getStarted()); |
|
| 1347 | - $copyObj->setInput($this->getInput()); |
|
| 1348 | - $copyObj->setNetwork($this->getNetwork()); |
|
| 1349 | - $copyObj->setMux($this->getMux()); |
|
| 1350 | - $copyObj->setWeight($this->getWeight()); |
|
| 1351 | - |
|
| 1352 | - if ($deepCopy) { |
|
| 1353 | - // important: temporarily setNew(false) because this affects the behavior of |
|
| 1354 | - // the getter/setter methods for fkey referrer objects. |
|
| 1355 | - $copyObj->setNew(false); |
|
| 1356 | - |
|
| 1357 | - foreach ($this->getSubscriptions() as $relObj) { |
|
| 1358 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1359 | - $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1360 | - } |
|
| 1361 | - } |
|
| 1362 | - |
|
| 1363 | - } // if ($deepCopy) |
|
| 1364 | - |
|
| 1365 | - if ($makeNew) { |
|
| 1366 | - $copyObj->setNew(true); |
|
| 1367 | - } |
|
| 1368 | - } |
|
| 1369 | - |
|
| 1370 | - /** |
|
| 1371 | - * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1372 | - * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1373 | - * keys that are defined for the table. |
|
| 1374 | - * |
|
| 1375 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1376 | - * objects. |
|
| 1377 | - * |
|
| 1378 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1379 | - * @return \Jalle19\StatusManager\Database\Input Clone of current object. |
|
| 1380 | - * @throws PropelException |
|
| 1381 | - */ |
|
| 1382 | - public function copy($deepCopy = false) |
|
| 1383 | - { |
|
| 1384 | - // we use get_class(), because this might be a subclass |
|
| 1385 | - $clazz = get_class($this); |
|
| 1386 | - $copyObj = new $clazz(); |
|
| 1387 | - $this->copyInto($copyObj, $deepCopy); |
|
| 1388 | - |
|
| 1389 | - return $copyObj; |
|
| 1390 | - } |
|
| 1391 | - |
|
| 1392 | - /** |
|
| 1393 | - * Declares an association between this object and a ChildInstance object. |
|
| 1394 | - * |
|
| 1395 | - * @param ChildInstance $v |
|
| 1396 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 1397 | - * @throws PropelException |
|
| 1398 | - */ |
|
| 1399 | - public function setInstance(ChildInstance $v = null) |
|
| 1400 | - { |
|
| 1401 | - if ($v === null) { |
|
| 1402 | - $this->setInstanceName(NULL); |
|
| 1403 | - } else { |
|
| 1404 | - $this->setInstanceName($v->getName()); |
|
| 1405 | - } |
|
| 1406 | - |
|
| 1407 | - $this->aInstance = $v; |
|
| 1408 | - |
|
| 1409 | - // Add binding for other direction of this n:n relationship. |
|
| 1410 | - // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
| 1411 | - if ($v !== null) { |
|
| 1412 | - $v->addInput($this); |
|
| 1413 | - } |
|
| 1414 | - |
|
| 1415 | - |
|
| 1416 | - return $this; |
|
| 1417 | - } |
|
| 1418 | - |
|
| 1419 | - |
|
| 1420 | - /** |
|
| 1421 | - * Get the associated ChildInstance object |
|
| 1422 | - * |
|
| 1423 | - * @param ConnectionInterface $con Optional Connection object. |
|
| 1424 | - * @return ChildInstance The associated ChildInstance object. |
|
| 1425 | - * @throws PropelException |
|
| 1426 | - */ |
|
| 1427 | - public function getInstance(ConnectionInterface $con = null) |
|
| 1428 | - { |
|
| 1429 | - if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
| 1430 | - $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
| 1431 | - /* The following can be used additionally to |
|
| 621 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 622 | + * |
|
| 623 | + * @return int next starting column |
|
| 624 | + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 625 | + */ |
|
| 626 | + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 627 | + { |
|
| 628 | + try { |
|
| 629 | + |
|
| 630 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : InputTableMap::translateFieldName('Uuid', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 631 | + $this->uuid = (null !== $col) ? (string) $col : null; |
|
| 632 | + |
|
| 633 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : InputTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 634 | + $this->instance_name = (null !== $col) ? (string) $col : null; |
|
| 635 | + |
|
| 636 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : InputTableMap::translateFieldName('Started', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 637 | + $this->started = (null !== $col) ? PropelDateTime::newInstance($col, null, 'DateTime') : null; |
|
| 638 | + |
|
| 639 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : InputTableMap::translateFieldName('Input', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 640 | + $this->input = (null !== $col) ? (string) $col : null; |
|
| 641 | + |
|
| 642 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : InputTableMap::translateFieldName('Network', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 643 | + $this->network = (null !== $col) ? (string) $col : null; |
|
| 644 | + |
|
| 645 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : InputTableMap::translateFieldName('Mux', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 646 | + $this->mux = (null !== $col) ? (string) $col : null; |
|
| 647 | + |
|
| 648 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : InputTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 649 | + $this->weight = (null !== $col) ? (int) $col : null; |
|
| 650 | + $this->resetModified(); |
|
| 651 | + |
|
| 652 | + $this->setNew(false); |
|
| 653 | + |
|
| 654 | + if ($rehydrate) { |
|
| 655 | + $this->ensureConsistency(); |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + return $startcol + 7; // 7 = InputTableMap::NUM_HYDRATE_COLUMNS. |
|
| 659 | + |
|
| 660 | + } catch (Exception $e) { |
|
| 661 | + throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Input'), 0, $e); |
|
| 662 | + } |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + /** |
|
| 666 | + * Checks and repairs the internal consistency of the object. |
|
| 667 | + * |
|
| 668 | + * This method is executed after an already-instantiated object is re-hydrated |
|
| 669 | + * from the database. It exists to check any foreign keys to make sure that |
|
| 670 | + * the objects related to the current object are correct based on foreign key. |
|
| 671 | + * |
|
| 672 | + * You can override this method in the stub class, but you should always invoke |
|
| 673 | + * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 674 | + * in case your model changes. |
|
| 675 | + * |
|
| 676 | + * @throws PropelException |
|
| 677 | + */ |
|
| 678 | + public function ensureConsistency() |
|
| 679 | + { |
|
| 680 | + if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
| 681 | + $this->aInstance = null; |
|
| 682 | + } |
|
| 683 | + } // ensureConsistency |
|
| 684 | + |
|
| 685 | + /** |
|
| 686 | + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 687 | + * |
|
| 688 | + * This will only work if the object has been saved and has a valid primary key set. |
|
| 689 | + * |
|
| 690 | + * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 691 | + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 692 | + * @return void |
|
| 693 | + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 694 | + */ |
|
| 695 | + public function reload($deep = false, ConnectionInterface $con = null) |
|
| 696 | + { |
|
| 697 | + if ($this->isDeleted()) { |
|
| 698 | + throw new PropelException("Cannot reload a deleted object."); |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + if ($this->isNew()) { |
|
| 702 | + throw new PropelException("Cannot reload an unsaved object."); |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + if ($con === null) { |
|
| 706 | + $con = Propel::getServiceContainer()->getReadConnection(InputTableMap::DATABASE_NAME); |
|
| 707 | + } |
|
| 708 | + |
|
| 709 | + // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 710 | + // already in the pool. |
|
| 711 | + |
|
| 712 | + $dataFetcher = ChildInputQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 713 | + $row = $dataFetcher->fetch(); |
|
| 714 | + $dataFetcher->close(); |
|
| 715 | + if (!$row) { |
|
| 716 | + throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 717 | + } |
|
| 718 | + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 719 | + |
|
| 720 | + if ($deep) { // also de-associate any related objects? |
|
| 721 | + |
|
| 722 | + $this->aInstance = null; |
|
| 723 | + $this->collSubscriptions = null; |
|
| 724 | + |
|
| 725 | + } // if (deep) |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * Removes this object from datastore and sets delete attribute. |
|
| 730 | + * |
|
| 731 | + * @param ConnectionInterface $con |
|
| 732 | + * @return void |
|
| 733 | + * @throws PropelException |
|
| 734 | + * @see Input::setDeleted() |
|
| 735 | + * @see Input::isDeleted() |
|
| 736 | + */ |
|
| 737 | + public function delete(ConnectionInterface $con = null) |
|
| 738 | + { |
|
| 739 | + if ($this->isDeleted()) { |
|
| 740 | + throw new PropelException("This object has already been deleted."); |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + if ($con === null) { |
|
| 744 | + $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + $con->transaction(function () use ($con) { |
|
| 748 | + $deleteQuery = ChildInputQuery::create() |
|
| 749 | + ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 750 | + $ret = $this->preDelete($con); |
|
| 751 | + if ($ret) { |
|
| 752 | + $deleteQuery->delete($con); |
|
| 753 | + $this->postDelete($con); |
|
| 754 | + $this->setDeleted(true); |
|
| 755 | + } |
|
| 756 | + }); |
|
| 757 | + } |
|
| 758 | + |
|
| 759 | + /** |
|
| 760 | + * Persists this object to the database. |
|
| 761 | + * |
|
| 762 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 763 | + * All modified related objects will also be persisted in the doSave() |
|
| 764 | + * method. This method wraps all precipitate database operations in a |
|
| 765 | + * single transaction. |
|
| 766 | + * |
|
| 767 | + * @param ConnectionInterface $con |
|
| 768 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 769 | + * @throws PropelException |
|
| 770 | + * @see doSave() |
|
| 771 | + */ |
|
| 772 | + public function save(ConnectionInterface $con = null) |
|
| 773 | + { |
|
| 774 | + if ($this->isDeleted()) { |
|
| 775 | + throw new PropelException("You cannot save an object that has been deleted."); |
|
| 776 | + } |
|
| 777 | + |
|
| 778 | + if ($con === null) { |
|
| 779 | + $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + return $con->transaction(function () use ($con) { |
|
| 783 | + $isInsert = $this->isNew(); |
|
| 784 | + $ret = $this->preSave($con); |
|
| 785 | + if ($isInsert) { |
|
| 786 | + $ret = $ret && $this->preInsert($con); |
|
| 787 | + } else { |
|
| 788 | + $ret = $ret && $this->preUpdate($con); |
|
| 789 | + } |
|
| 790 | + if ($ret) { |
|
| 791 | + $affectedRows = $this->doSave($con); |
|
| 792 | + if ($isInsert) { |
|
| 793 | + $this->postInsert($con); |
|
| 794 | + } else { |
|
| 795 | + $this->postUpdate($con); |
|
| 796 | + } |
|
| 797 | + $this->postSave($con); |
|
| 798 | + InputTableMap::addInstanceToPool($this); |
|
| 799 | + } else { |
|
| 800 | + $affectedRows = 0; |
|
| 801 | + } |
|
| 802 | + |
|
| 803 | + return $affectedRows; |
|
| 804 | + }); |
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + /** |
|
| 808 | + * Performs the work of inserting or updating the row in the database. |
|
| 809 | + * |
|
| 810 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 811 | + * All related objects are also updated in this method. |
|
| 812 | + * |
|
| 813 | + * @param ConnectionInterface $con |
|
| 814 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 815 | + * @throws PropelException |
|
| 816 | + * @see save() |
|
| 817 | + */ |
|
| 818 | + protected function doSave(ConnectionInterface $con) |
|
| 819 | + { |
|
| 820 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 821 | + if (!$this->alreadyInSave) { |
|
| 822 | + $this->alreadyInSave = true; |
|
| 823 | + |
|
| 824 | + // We call the save method on the following object(s) if they |
|
| 825 | + // were passed to this object by their corresponding set |
|
| 826 | + // method. This object relates to these object(s) by a |
|
| 827 | + // foreign key reference. |
|
| 828 | + |
|
| 829 | + if ($this->aInstance !== null) { |
|
| 830 | + if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
| 831 | + $affectedRows += $this->aInstance->save($con); |
|
| 832 | + } |
|
| 833 | + $this->setInstance($this->aInstance); |
|
| 834 | + } |
|
| 835 | + |
|
| 836 | + if ($this->isNew() || $this->isModified()) { |
|
| 837 | + // persist changes |
|
| 838 | + if ($this->isNew()) { |
|
| 839 | + $this->doInsert($con); |
|
| 840 | + $affectedRows += 1; |
|
| 841 | + } else { |
|
| 842 | + $affectedRows += $this->doUpdate($con); |
|
| 843 | + } |
|
| 844 | + $this->resetModified(); |
|
| 845 | + } |
|
| 846 | + |
|
| 847 | + if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 848 | + if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 849 | + foreach ($this->subscriptionsScheduledForDeletion as $subscription) { |
|
| 850 | + // need to save related object because we set the relation to null |
|
| 851 | + $subscription->save($con); |
|
| 852 | + } |
|
| 853 | + $this->subscriptionsScheduledForDeletion = null; |
|
| 854 | + } |
|
| 855 | + } |
|
| 856 | + |
|
| 857 | + if ($this->collSubscriptions !== null) { |
|
| 858 | + foreach ($this->collSubscriptions as $referrerFK) { |
|
| 859 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 860 | + $affectedRows += $referrerFK->save($con); |
|
| 861 | + } |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + $this->alreadyInSave = false; |
|
| 866 | + |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + return $affectedRows; |
|
| 870 | + } // doSave() |
|
| 871 | + |
|
| 872 | + /** |
|
| 873 | + * Insert the row in the database. |
|
| 874 | + * |
|
| 875 | + * @param ConnectionInterface $con |
|
| 876 | + * |
|
| 877 | + * @throws PropelException |
|
| 878 | + * @see doSave() |
|
| 879 | + */ |
|
| 880 | + protected function doInsert(ConnectionInterface $con) |
|
| 881 | + { |
|
| 882 | + $modifiedColumns = array(); |
|
| 883 | + $index = 0; |
|
| 884 | + |
|
| 885 | + |
|
| 886 | + // check the columns in natural order for more readable SQL queries |
|
| 887 | + if ($this->isColumnModified(InputTableMap::COL_UUID)) { |
|
| 888 | + $modifiedColumns[':p' . $index++] = 'uuid'; |
|
| 889 | + } |
|
| 890 | + if ($this->isColumnModified(InputTableMap::COL_INSTANCE_NAME)) { |
|
| 891 | + $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
| 892 | + } |
|
| 893 | + if ($this->isColumnModified(InputTableMap::COL_STARTED)) { |
|
| 894 | + $modifiedColumns[':p' . $index++] = 'started'; |
|
| 895 | + } |
|
| 896 | + if ($this->isColumnModified(InputTableMap::COL_INPUT)) { |
|
| 897 | + $modifiedColumns[':p' . $index++] = 'input'; |
|
| 898 | + } |
|
| 899 | + if ($this->isColumnModified(InputTableMap::COL_NETWORK)) { |
|
| 900 | + $modifiedColumns[':p' . $index++] = 'network'; |
|
| 901 | + } |
|
| 902 | + if ($this->isColumnModified(InputTableMap::COL_MUX)) { |
|
| 903 | + $modifiedColumns[':p' . $index++] = 'mux'; |
|
| 904 | + } |
|
| 905 | + if ($this->isColumnModified(InputTableMap::COL_WEIGHT)) { |
|
| 906 | + $modifiedColumns[':p' . $index++] = 'weight'; |
|
| 907 | + } |
|
| 908 | + |
|
| 909 | + $sql = sprintf( |
|
| 910 | + 'INSERT INTO input (%s) VALUES (%s)', |
|
| 911 | + implode(', ', $modifiedColumns), |
|
| 912 | + implode(', ', array_keys($modifiedColumns)) |
|
| 913 | + ); |
|
| 914 | + |
|
| 915 | + try { |
|
| 916 | + $stmt = $con->prepare($sql); |
|
| 917 | + foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 918 | + switch ($columnName) { |
|
| 919 | + case 'uuid': |
|
| 920 | + $stmt->bindValue($identifier, $this->uuid, PDO::PARAM_STR); |
|
| 921 | + break; |
|
| 922 | + case 'instance_name': |
|
| 923 | + $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
| 924 | + break; |
|
| 925 | + case 'started': |
|
| 926 | + $stmt->bindValue($identifier, $this->started ? $this->started->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); |
|
| 927 | + break; |
|
| 928 | + case 'input': |
|
| 929 | + $stmt->bindValue($identifier, $this->input, PDO::PARAM_STR); |
|
| 930 | + break; |
|
| 931 | + case 'network': |
|
| 932 | + $stmt->bindValue($identifier, $this->network, PDO::PARAM_STR); |
|
| 933 | + break; |
|
| 934 | + case 'mux': |
|
| 935 | + $stmt->bindValue($identifier, $this->mux, PDO::PARAM_STR); |
|
| 936 | + break; |
|
| 937 | + case 'weight': |
|
| 938 | + $stmt->bindValue($identifier, $this->weight, PDO::PARAM_INT); |
|
| 939 | + break; |
|
| 940 | + } |
|
| 941 | + } |
|
| 942 | + $stmt->execute(); |
|
| 943 | + } catch (Exception $e) { |
|
| 944 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 945 | + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + $this->setNew(false); |
|
| 949 | + } |
|
| 950 | + |
|
| 951 | + /** |
|
| 952 | + * Update the row in the database. |
|
| 953 | + * |
|
| 954 | + * @param ConnectionInterface $con |
|
| 955 | + * |
|
| 956 | + * @return Integer Number of updated rows |
|
| 957 | + * @see doSave() |
|
| 958 | + */ |
|
| 959 | + protected function doUpdate(ConnectionInterface $con) |
|
| 960 | + { |
|
| 961 | + $selectCriteria = $this->buildPkeyCriteria(); |
|
| 962 | + $valuesCriteria = $this->buildCriteria(); |
|
| 963 | + |
|
| 964 | + return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 965 | + } |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * Retrieves a field from the object by name passed in as a string. |
|
| 969 | + * |
|
| 970 | + * @param string $name name |
|
| 971 | + * @param string $type The type of fieldname the $name is of: |
|
| 972 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 973 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 974 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 975 | + * @return mixed Value of field. |
|
| 976 | + */ |
|
| 977 | + public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 978 | + { |
|
| 979 | + $pos = InputTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 980 | + $field = $this->getByPosition($pos); |
|
| 981 | + |
|
| 982 | + return $field; |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + /** |
|
| 986 | + * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 987 | + * Zero-based. |
|
| 988 | + * |
|
| 989 | + * @param int $pos position in xml schema |
|
| 990 | + * @return mixed Value of field at $pos |
|
| 991 | + */ |
|
| 992 | + public function getByPosition($pos) |
|
| 993 | + { |
|
| 994 | + switch ($pos) { |
|
| 995 | + case 0: |
|
| 996 | + return $this->getUuid(); |
|
| 997 | + break; |
|
| 998 | + case 1: |
|
| 999 | + return $this->getInstanceName(); |
|
| 1000 | + break; |
|
| 1001 | + case 2: |
|
| 1002 | + return $this->getStarted(); |
|
| 1003 | + break; |
|
| 1004 | + case 3: |
|
| 1005 | + return $this->getInput(); |
|
| 1006 | + break; |
|
| 1007 | + case 4: |
|
| 1008 | + return $this->getNetwork(); |
|
| 1009 | + break; |
|
| 1010 | + case 5: |
|
| 1011 | + return $this->getMux(); |
|
| 1012 | + break; |
|
| 1013 | + case 6: |
|
| 1014 | + return $this->getWeight(); |
|
| 1015 | + break; |
|
| 1016 | + default: |
|
| 1017 | + return null; |
|
| 1018 | + break; |
|
| 1019 | + } // switch() |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + /** |
|
| 1023 | + * Exports the object as an array. |
|
| 1024 | + * |
|
| 1025 | + * You can specify the key type of the array by passing one of the class |
|
| 1026 | + * type constants. |
|
| 1027 | + * |
|
| 1028 | + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1029 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1030 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 1031 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 1032 | + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 1033 | + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 1034 | + * |
|
| 1035 | + * @return array an associative array containing the field names (as keys) and field values |
|
| 1036 | + */ |
|
| 1037 | + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 1038 | + { |
|
| 1039 | + |
|
| 1040 | + if (isset($alreadyDumpedObjects['Input'][$this->hashCode()])) { |
|
| 1041 | + return '*RECURSION*'; |
|
| 1042 | + } |
|
| 1043 | + $alreadyDumpedObjects['Input'][$this->hashCode()] = true; |
|
| 1044 | + $keys = InputTableMap::getFieldNames($keyType); |
|
| 1045 | + $result = array( |
|
| 1046 | + $keys[0] => $this->getUuid(), |
|
| 1047 | + $keys[1] => $this->getInstanceName(), |
|
| 1048 | + $keys[2] => $this->getStarted(), |
|
| 1049 | + $keys[3] => $this->getInput(), |
|
| 1050 | + $keys[4] => $this->getNetwork(), |
|
| 1051 | + $keys[5] => $this->getMux(), |
|
| 1052 | + $keys[6] => $this->getWeight(), |
|
| 1053 | + ); |
|
| 1054 | + if ($result[$keys[2]] instanceof \DateTime) { |
|
| 1055 | + $result[$keys[2]] = $result[$keys[2]]->format('c'); |
|
| 1056 | + } |
|
| 1057 | + |
|
| 1058 | + $virtualColumns = $this->virtualColumns; |
|
| 1059 | + foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 1060 | + $result[$key] = $virtualColumn; |
|
| 1061 | + } |
|
| 1062 | + |
|
| 1063 | + if ($includeForeignObjects) { |
|
| 1064 | + if (null !== $this->aInstance) { |
|
| 1065 | + |
|
| 1066 | + switch ($keyType) { |
|
| 1067 | + case TableMap::TYPE_CAMELNAME: |
|
| 1068 | + $key = 'instance'; |
|
| 1069 | + break; |
|
| 1070 | + case TableMap::TYPE_FIELDNAME: |
|
| 1071 | + $key = 'instance'; |
|
| 1072 | + break; |
|
| 1073 | + default: |
|
| 1074 | + $key = 'Instance'; |
|
| 1075 | + } |
|
| 1076 | + |
|
| 1077 | + $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
| 1078 | + } |
|
| 1079 | + if (null !== $this->collSubscriptions) { |
|
| 1080 | + |
|
| 1081 | + switch ($keyType) { |
|
| 1082 | + case TableMap::TYPE_CAMELNAME: |
|
| 1083 | + $key = 'subscriptions'; |
|
| 1084 | + break; |
|
| 1085 | + case TableMap::TYPE_FIELDNAME: |
|
| 1086 | + $key = 'subscriptions'; |
|
| 1087 | + break; |
|
| 1088 | + default: |
|
| 1089 | + $key = 'Subscriptions'; |
|
| 1090 | + } |
|
| 1091 | + |
|
| 1092 | + $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 1093 | + } |
|
| 1094 | + } |
|
| 1095 | + |
|
| 1096 | + return $result; |
|
| 1097 | + } |
|
| 1098 | + |
|
| 1099 | + /** |
|
| 1100 | + * Sets a field from the object by name passed in as a string. |
|
| 1101 | + * |
|
| 1102 | + * @param string $name |
|
| 1103 | + * @param mixed $value field value |
|
| 1104 | + * @param string $type The type of fieldname the $name is of: |
|
| 1105 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 1106 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1107 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 1108 | + * @return $this|\Jalle19\StatusManager\Database\Input |
|
| 1109 | + */ |
|
| 1110 | + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 1111 | + { |
|
| 1112 | + $pos = InputTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 1113 | + |
|
| 1114 | + return $this->setByPosition($pos, $value); |
|
| 1115 | + } |
|
| 1116 | + |
|
| 1117 | + /** |
|
| 1118 | + * Sets a field from the object by Position as specified in the xml schema. |
|
| 1119 | + * Zero-based. |
|
| 1120 | + * |
|
| 1121 | + * @param int $pos position in xml schema |
|
| 1122 | + * @param mixed $value field value |
|
| 1123 | + * @return $this|\Jalle19\StatusManager\Database\Input |
|
| 1124 | + */ |
|
| 1125 | + public function setByPosition($pos, $value) |
|
| 1126 | + { |
|
| 1127 | + switch ($pos) { |
|
| 1128 | + case 0: |
|
| 1129 | + $this->setUuid($value); |
|
| 1130 | + break; |
|
| 1131 | + case 1: |
|
| 1132 | + $this->setInstanceName($value); |
|
| 1133 | + break; |
|
| 1134 | + case 2: |
|
| 1135 | + $this->setStarted($value); |
|
| 1136 | + break; |
|
| 1137 | + case 3: |
|
| 1138 | + $this->setInput($value); |
|
| 1139 | + break; |
|
| 1140 | + case 4: |
|
| 1141 | + $this->setNetwork($value); |
|
| 1142 | + break; |
|
| 1143 | + case 5: |
|
| 1144 | + $this->setMux($value); |
|
| 1145 | + break; |
|
| 1146 | + case 6: |
|
| 1147 | + $this->setWeight($value); |
|
| 1148 | + break; |
|
| 1149 | + } // switch() |
|
| 1150 | + |
|
| 1151 | + return $this; |
|
| 1152 | + } |
|
| 1153 | + |
|
| 1154 | + /** |
|
| 1155 | + * Populates the object using an array. |
|
| 1156 | + * |
|
| 1157 | + * This is particularly useful when populating an object from one of the |
|
| 1158 | + * request arrays (e.g. $_POST). This method goes through the column |
|
| 1159 | + * names, checking to see whether a matching key exists in populated |
|
| 1160 | + * array. If so the setByName() method is called for that column. |
|
| 1161 | + * |
|
| 1162 | + * You can specify the key type of the array by additionally passing one |
|
| 1163 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1164 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1165 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1166 | + * |
|
| 1167 | + * @param array $arr An array to populate the object from. |
|
| 1168 | + * @param string $keyType The type of keys the array uses. |
|
| 1169 | + * @return void |
|
| 1170 | + */ |
|
| 1171 | + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1172 | + { |
|
| 1173 | + $keys = InputTableMap::getFieldNames($keyType); |
|
| 1174 | + |
|
| 1175 | + if (array_key_exists($keys[0], $arr)) { |
|
| 1176 | + $this->setUuid($arr[$keys[0]]); |
|
| 1177 | + } |
|
| 1178 | + if (array_key_exists($keys[1], $arr)) { |
|
| 1179 | + $this->setInstanceName($arr[$keys[1]]); |
|
| 1180 | + } |
|
| 1181 | + if (array_key_exists($keys[2], $arr)) { |
|
| 1182 | + $this->setStarted($arr[$keys[2]]); |
|
| 1183 | + } |
|
| 1184 | + if (array_key_exists($keys[3], $arr)) { |
|
| 1185 | + $this->setInput($arr[$keys[3]]); |
|
| 1186 | + } |
|
| 1187 | + if (array_key_exists($keys[4], $arr)) { |
|
| 1188 | + $this->setNetwork($arr[$keys[4]]); |
|
| 1189 | + } |
|
| 1190 | + if (array_key_exists($keys[5], $arr)) { |
|
| 1191 | + $this->setMux($arr[$keys[5]]); |
|
| 1192 | + } |
|
| 1193 | + if (array_key_exists($keys[6], $arr)) { |
|
| 1194 | + $this->setWeight($arr[$keys[6]]); |
|
| 1195 | + } |
|
| 1196 | + } |
|
| 1197 | + |
|
| 1198 | + /** |
|
| 1199 | + * Populate the current object from a string, using a given parser format |
|
| 1200 | + * <code> |
|
| 1201 | + * $book = new Book(); |
|
| 1202 | + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 1203 | + * </code> |
|
| 1204 | + * |
|
| 1205 | + * You can specify the key type of the array by additionally passing one |
|
| 1206 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1207 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1208 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1209 | + * |
|
| 1210 | + * @param mixed $parser A AbstractParser instance, |
|
| 1211 | + * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 1212 | + * @param string $data The source data to import from |
|
| 1213 | + * @param string $keyType The type of keys the array uses. |
|
| 1214 | + * |
|
| 1215 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object, for fluid interface |
|
| 1216 | + */ |
|
| 1217 | + public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1218 | + { |
|
| 1219 | + if (!$parser instanceof AbstractParser) { |
|
| 1220 | + $parser = AbstractParser::getParser($parser); |
|
| 1221 | + } |
|
| 1222 | + |
|
| 1223 | + $this->fromArray($parser->toArray($data), $keyType); |
|
| 1224 | + |
|
| 1225 | + return $this; |
|
| 1226 | + } |
|
| 1227 | + |
|
| 1228 | + /** |
|
| 1229 | + * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1230 | + * |
|
| 1231 | + * @return Criteria The Criteria object containing all modified values. |
|
| 1232 | + */ |
|
| 1233 | + public function buildCriteria() |
|
| 1234 | + { |
|
| 1235 | + $criteria = new Criteria(InputTableMap::DATABASE_NAME); |
|
| 1236 | + |
|
| 1237 | + if ($this->isColumnModified(InputTableMap::COL_UUID)) { |
|
| 1238 | + $criteria->add(InputTableMap::COL_UUID, $this->uuid); |
|
| 1239 | + } |
|
| 1240 | + if ($this->isColumnModified(InputTableMap::COL_INSTANCE_NAME)) { |
|
| 1241 | + $criteria->add(InputTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
| 1242 | + } |
|
| 1243 | + if ($this->isColumnModified(InputTableMap::COL_STARTED)) { |
|
| 1244 | + $criteria->add(InputTableMap::COL_STARTED, $this->started); |
|
| 1245 | + } |
|
| 1246 | + if ($this->isColumnModified(InputTableMap::COL_INPUT)) { |
|
| 1247 | + $criteria->add(InputTableMap::COL_INPUT, $this->input); |
|
| 1248 | + } |
|
| 1249 | + if ($this->isColumnModified(InputTableMap::COL_NETWORK)) { |
|
| 1250 | + $criteria->add(InputTableMap::COL_NETWORK, $this->network); |
|
| 1251 | + } |
|
| 1252 | + if ($this->isColumnModified(InputTableMap::COL_MUX)) { |
|
| 1253 | + $criteria->add(InputTableMap::COL_MUX, $this->mux); |
|
| 1254 | + } |
|
| 1255 | + if ($this->isColumnModified(InputTableMap::COL_WEIGHT)) { |
|
| 1256 | + $criteria->add(InputTableMap::COL_WEIGHT, $this->weight); |
|
| 1257 | + } |
|
| 1258 | + |
|
| 1259 | + return $criteria; |
|
| 1260 | + } |
|
| 1261 | + |
|
| 1262 | + /** |
|
| 1263 | + * Builds a Criteria object containing the primary key for this object. |
|
| 1264 | + * |
|
| 1265 | + * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1266 | + * of whether or not they have been modified. |
|
| 1267 | + * |
|
| 1268 | + * @throws LogicException if no primary key is defined |
|
| 1269 | + * |
|
| 1270 | + * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1271 | + */ |
|
| 1272 | + public function buildPkeyCriteria() |
|
| 1273 | + { |
|
| 1274 | + $criteria = ChildInputQuery::create(); |
|
| 1275 | + $criteria->add(InputTableMap::COL_UUID, $this->uuid); |
|
| 1276 | + |
|
| 1277 | + return $criteria; |
|
| 1278 | + } |
|
| 1279 | + |
|
| 1280 | + /** |
|
| 1281 | + * If the primary key is not null, return the hashcode of the |
|
| 1282 | + * primary key. Otherwise, return the hash code of the object. |
|
| 1283 | + * |
|
| 1284 | + * @return int Hashcode |
|
| 1285 | + */ |
|
| 1286 | + public function hashCode() |
|
| 1287 | + { |
|
| 1288 | + $validPk = null !== $this->getUuid(); |
|
| 1289 | + |
|
| 1290 | + $validPrimaryKeyFKs = 0; |
|
| 1291 | + $primaryKeyFKs = []; |
|
| 1292 | + |
|
| 1293 | + if ($validPk) { |
|
| 1294 | + return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1295 | + } elseif ($validPrimaryKeyFKs) { |
|
| 1296 | + return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1297 | + } |
|
| 1298 | + |
|
| 1299 | + return spl_object_hash($this); |
|
| 1300 | + } |
|
| 1301 | + |
|
| 1302 | + /** |
|
| 1303 | + * Returns the primary key for this object (row). |
|
| 1304 | + * @return string |
|
| 1305 | + */ |
|
| 1306 | + public function getPrimaryKey() |
|
| 1307 | + { |
|
| 1308 | + return $this->getUuid(); |
|
| 1309 | + } |
|
| 1310 | + |
|
| 1311 | + /** |
|
| 1312 | + * Generic method to set the primary key (uuid column). |
|
| 1313 | + * |
|
| 1314 | + * @param string $key Primary key. |
|
| 1315 | + * @return void |
|
| 1316 | + */ |
|
| 1317 | + public function setPrimaryKey($key) |
|
| 1318 | + { |
|
| 1319 | + $this->setUuid($key); |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + /** |
|
| 1323 | + * Returns true if the primary key for this object is null. |
|
| 1324 | + * @return boolean |
|
| 1325 | + */ |
|
| 1326 | + public function isPrimaryKeyNull() |
|
| 1327 | + { |
|
| 1328 | + return null === $this->getUuid(); |
|
| 1329 | + } |
|
| 1330 | + |
|
| 1331 | + /** |
|
| 1332 | + * Sets contents of passed object to values from current object. |
|
| 1333 | + * |
|
| 1334 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1335 | + * objects. |
|
| 1336 | + * |
|
| 1337 | + * @param object $copyObj An object of \Jalle19\StatusManager\Database\Input (or compatible) type. |
|
| 1338 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1339 | + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1340 | + * @throws PropelException |
|
| 1341 | + */ |
|
| 1342 | + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1343 | + { |
|
| 1344 | + $copyObj->setUuid($this->getUuid()); |
|
| 1345 | + $copyObj->setInstanceName($this->getInstanceName()); |
|
| 1346 | + $copyObj->setStarted($this->getStarted()); |
|
| 1347 | + $copyObj->setInput($this->getInput()); |
|
| 1348 | + $copyObj->setNetwork($this->getNetwork()); |
|
| 1349 | + $copyObj->setMux($this->getMux()); |
|
| 1350 | + $copyObj->setWeight($this->getWeight()); |
|
| 1351 | + |
|
| 1352 | + if ($deepCopy) { |
|
| 1353 | + // important: temporarily setNew(false) because this affects the behavior of |
|
| 1354 | + // the getter/setter methods for fkey referrer objects. |
|
| 1355 | + $copyObj->setNew(false); |
|
| 1356 | + |
|
| 1357 | + foreach ($this->getSubscriptions() as $relObj) { |
|
| 1358 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1359 | + $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1360 | + } |
|
| 1361 | + } |
|
| 1362 | + |
|
| 1363 | + } // if ($deepCopy) |
|
| 1364 | + |
|
| 1365 | + if ($makeNew) { |
|
| 1366 | + $copyObj->setNew(true); |
|
| 1367 | + } |
|
| 1368 | + } |
|
| 1369 | + |
|
| 1370 | + /** |
|
| 1371 | + * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1372 | + * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1373 | + * keys that are defined for the table. |
|
| 1374 | + * |
|
| 1375 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1376 | + * objects. |
|
| 1377 | + * |
|
| 1378 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1379 | + * @return \Jalle19\StatusManager\Database\Input Clone of current object. |
|
| 1380 | + * @throws PropelException |
|
| 1381 | + */ |
|
| 1382 | + public function copy($deepCopy = false) |
|
| 1383 | + { |
|
| 1384 | + // we use get_class(), because this might be a subclass |
|
| 1385 | + $clazz = get_class($this); |
|
| 1386 | + $copyObj = new $clazz(); |
|
| 1387 | + $this->copyInto($copyObj, $deepCopy); |
|
| 1388 | + |
|
| 1389 | + return $copyObj; |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + /** |
|
| 1393 | + * Declares an association between this object and a ChildInstance object. |
|
| 1394 | + * |
|
| 1395 | + * @param ChildInstance $v |
|
| 1396 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 1397 | + * @throws PropelException |
|
| 1398 | + */ |
|
| 1399 | + public function setInstance(ChildInstance $v = null) |
|
| 1400 | + { |
|
| 1401 | + if ($v === null) { |
|
| 1402 | + $this->setInstanceName(NULL); |
|
| 1403 | + } else { |
|
| 1404 | + $this->setInstanceName($v->getName()); |
|
| 1405 | + } |
|
| 1406 | + |
|
| 1407 | + $this->aInstance = $v; |
|
| 1408 | + |
|
| 1409 | + // Add binding for other direction of this n:n relationship. |
|
| 1410 | + // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
| 1411 | + if ($v !== null) { |
|
| 1412 | + $v->addInput($this); |
|
| 1413 | + } |
|
| 1414 | + |
|
| 1415 | + |
|
| 1416 | + return $this; |
|
| 1417 | + } |
|
| 1418 | + |
|
| 1419 | + |
|
| 1420 | + /** |
|
| 1421 | + * Get the associated ChildInstance object |
|
| 1422 | + * |
|
| 1423 | + * @param ConnectionInterface $con Optional Connection object. |
|
| 1424 | + * @return ChildInstance The associated ChildInstance object. |
|
| 1425 | + * @throws PropelException |
|
| 1426 | + */ |
|
| 1427 | + public function getInstance(ConnectionInterface $con = null) |
|
| 1428 | + { |
|
| 1429 | + if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
| 1430 | + $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
| 1431 | + /* The following can be used additionally to |
|
| 1432 | 1432 | guarantee the related object contains a reference |
| 1433 | 1433 | to this object. This level of coupling may, however, be |
| 1434 | 1434 | undesirable since it could result in an only partially populated collection |
| 1435 | 1435 | in the referenced object. |
| 1436 | 1436 | $this->aInstance->addInputs($this); |
| 1437 | 1437 | */ |
| 1438 | - } |
|
| 1439 | - |
|
| 1440 | - return $this->aInstance; |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - |
|
| 1444 | - /** |
|
| 1445 | - * Initializes a collection based on the name of a relation. |
|
| 1446 | - * Avoids crafting an 'init[$relationName]s' method name |
|
| 1447 | - * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1448 | - * |
|
| 1449 | - * @param string $relationName The name of the relation to initialize |
|
| 1450 | - * @return void |
|
| 1451 | - */ |
|
| 1452 | - public function initRelation($relationName) |
|
| 1453 | - { |
|
| 1454 | - if ('Subscription' == $relationName) { |
|
| 1455 | - return $this->initSubscriptions(); |
|
| 1456 | - } |
|
| 1457 | - } |
|
| 1458 | - |
|
| 1459 | - /** |
|
| 1460 | - * Clears out the collSubscriptions collection |
|
| 1461 | - * |
|
| 1462 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1463 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1464 | - * |
|
| 1465 | - * @return void |
|
| 1466 | - * @see addSubscriptions() |
|
| 1467 | - */ |
|
| 1468 | - public function clearSubscriptions() |
|
| 1469 | - { |
|
| 1470 | - $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 1471 | - } |
|
| 1472 | - |
|
| 1473 | - /** |
|
| 1474 | - * Reset is the collSubscriptions collection loaded partially. |
|
| 1475 | - */ |
|
| 1476 | - public function resetPartialSubscriptions($v = true) |
|
| 1477 | - { |
|
| 1478 | - $this->collSubscriptionsPartial = $v; |
|
| 1479 | - } |
|
| 1480 | - |
|
| 1481 | - /** |
|
| 1482 | - * Initializes the collSubscriptions collection. |
|
| 1483 | - * |
|
| 1484 | - * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 1485 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1486 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1487 | - * |
|
| 1488 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1489 | - * the collection even if it is not empty |
|
| 1490 | - * |
|
| 1491 | - * @return void |
|
| 1492 | - */ |
|
| 1493 | - public function initSubscriptions($overrideExisting = true) |
|
| 1494 | - { |
|
| 1495 | - if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 1496 | - return; |
|
| 1497 | - } |
|
| 1498 | - |
|
| 1499 | - $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1500 | - |
|
| 1501 | - $this->collSubscriptions = new $collectionClassName; |
|
| 1502 | - $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 1503 | - } |
|
| 1504 | - |
|
| 1505 | - /** |
|
| 1506 | - * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 1507 | - * |
|
| 1508 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1509 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1510 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1511 | - * If this ChildInput is new, it will return |
|
| 1512 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1513 | - * |
|
| 1514 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1515 | - * @param ConnectionInterface $con optional connection object |
|
| 1516 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1517 | - * @throws PropelException |
|
| 1518 | - */ |
|
| 1519 | - public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1520 | - { |
|
| 1521 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1522 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1523 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1524 | - // return empty collection |
|
| 1525 | - $this->initSubscriptions(); |
|
| 1526 | - } else { |
|
| 1527 | - $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 1528 | - ->filterByInput($this) |
|
| 1529 | - ->find($con); |
|
| 1530 | - |
|
| 1531 | - if (null !== $criteria) { |
|
| 1532 | - if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 1533 | - $this->initSubscriptions(false); |
|
| 1534 | - |
|
| 1535 | - foreach ($collSubscriptions as $obj) { |
|
| 1536 | - if (false == $this->collSubscriptions->contains($obj)) { |
|
| 1537 | - $this->collSubscriptions->append($obj); |
|
| 1538 | - } |
|
| 1539 | - } |
|
| 1540 | - |
|
| 1541 | - $this->collSubscriptionsPartial = true; |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - return $collSubscriptions; |
|
| 1545 | - } |
|
| 1546 | - |
|
| 1547 | - if ($partial && $this->collSubscriptions) { |
|
| 1548 | - foreach ($this->collSubscriptions as $obj) { |
|
| 1549 | - if ($obj->isNew()) { |
|
| 1550 | - $collSubscriptions[] = $obj; |
|
| 1551 | - } |
|
| 1552 | - } |
|
| 1553 | - } |
|
| 1554 | - |
|
| 1555 | - $this->collSubscriptions = $collSubscriptions; |
|
| 1556 | - $this->collSubscriptionsPartial = false; |
|
| 1557 | - } |
|
| 1558 | - } |
|
| 1559 | - |
|
| 1560 | - return $this->collSubscriptions; |
|
| 1561 | - } |
|
| 1562 | - |
|
| 1563 | - /** |
|
| 1564 | - * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 1565 | - * to the current object. |
|
| 1566 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1567 | - * and new objects from the given Propel collection. |
|
| 1568 | - * |
|
| 1569 | - * @param Collection $subscriptions A Propel collection. |
|
| 1570 | - * @param ConnectionInterface $con Optional connection object |
|
| 1571 | - * @return $this|ChildInput The current object (for fluent API support) |
|
| 1572 | - */ |
|
| 1573 | - public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1574 | - { |
|
| 1575 | - /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 1576 | - $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 1577 | - |
|
| 1578 | - |
|
| 1579 | - $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 1580 | - |
|
| 1581 | - foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 1582 | - $subscriptionRemoved->setInput(null); |
|
| 1583 | - } |
|
| 1584 | - |
|
| 1585 | - $this->collSubscriptions = null; |
|
| 1586 | - foreach ($subscriptions as $subscription) { |
|
| 1587 | - $this->addSubscription($subscription); |
|
| 1588 | - } |
|
| 1589 | - |
|
| 1590 | - $this->collSubscriptions = $subscriptions; |
|
| 1591 | - $this->collSubscriptionsPartial = false; |
|
| 1592 | - |
|
| 1593 | - return $this; |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - /** |
|
| 1597 | - * Returns the number of related Subscription objects. |
|
| 1598 | - * |
|
| 1599 | - * @param Criteria $criteria |
|
| 1600 | - * @param boolean $distinct |
|
| 1601 | - * @param ConnectionInterface $con |
|
| 1602 | - * @return int Count of related Subscription objects. |
|
| 1603 | - * @throws PropelException |
|
| 1604 | - */ |
|
| 1605 | - public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1606 | - { |
|
| 1607 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1608 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1609 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1610 | - return 0; |
|
| 1611 | - } |
|
| 1612 | - |
|
| 1613 | - if ($partial && !$criteria) { |
|
| 1614 | - return count($this->getSubscriptions()); |
|
| 1615 | - } |
|
| 1616 | - |
|
| 1617 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1618 | - if ($distinct) { |
|
| 1619 | - $query->distinct(); |
|
| 1620 | - } |
|
| 1621 | - |
|
| 1622 | - return $query |
|
| 1623 | - ->filterByInput($this) |
|
| 1624 | - ->count($con); |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - return count($this->collSubscriptions); |
|
| 1628 | - } |
|
| 1629 | - |
|
| 1630 | - /** |
|
| 1631 | - * Method called to associate a ChildSubscription object to this object |
|
| 1632 | - * through the ChildSubscription foreign key attribute. |
|
| 1633 | - * |
|
| 1634 | - * @param ChildSubscription $l ChildSubscription |
|
| 1635 | - * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 1636 | - */ |
|
| 1637 | - public function addSubscription(ChildSubscription $l) |
|
| 1638 | - { |
|
| 1639 | - if ($this->collSubscriptions === null) { |
|
| 1640 | - $this->initSubscriptions(); |
|
| 1641 | - $this->collSubscriptionsPartial = true; |
|
| 1642 | - } |
|
| 1643 | - |
|
| 1644 | - if (!$this->collSubscriptions->contains($l)) { |
|
| 1645 | - $this->doAddSubscription($l); |
|
| 1646 | - |
|
| 1647 | - if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 1648 | - $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 1649 | - } |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - return $this; |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - /** |
|
| 1656 | - * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 1657 | - */ |
|
| 1658 | - protected function doAddSubscription(ChildSubscription $subscription) |
|
| 1659 | - { |
|
| 1660 | - $this->collSubscriptions[]= $subscription; |
|
| 1661 | - $subscription->setInput($this); |
|
| 1662 | - } |
|
| 1663 | - |
|
| 1664 | - /** |
|
| 1665 | - * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 1666 | - * @return $this|ChildInput The current object (for fluent API support) |
|
| 1667 | - */ |
|
| 1668 | - public function removeSubscription(ChildSubscription $subscription) |
|
| 1669 | - { |
|
| 1670 | - if ($this->getSubscriptions()->contains($subscription)) { |
|
| 1671 | - $pos = $this->collSubscriptions->search($subscription); |
|
| 1672 | - $this->collSubscriptions->remove($pos); |
|
| 1673 | - if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 1674 | - $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 1675 | - $this->subscriptionsScheduledForDeletion->clear(); |
|
| 1676 | - } |
|
| 1677 | - $this->subscriptionsScheduledForDeletion[]= $subscription; |
|
| 1678 | - $subscription->setInput(null); |
|
| 1679 | - } |
|
| 1680 | - |
|
| 1681 | - return $this; |
|
| 1682 | - } |
|
| 1683 | - |
|
| 1684 | - |
|
| 1685 | - /** |
|
| 1686 | - * If this collection has already been initialized with |
|
| 1687 | - * an identical criteria, it returns the collection. |
|
| 1688 | - * Otherwise if this Input is new, it will return |
|
| 1689 | - * an empty collection; or if this Input has previously |
|
| 1690 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1691 | - * |
|
| 1692 | - * This method is protected by default in order to keep the public |
|
| 1693 | - * api reasonable. You can provide public methods for those you |
|
| 1694 | - * actually need in Input. |
|
| 1695 | - * |
|
| 1696 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1697 | - * @param ConnectionInterface $con optional connection object |
|
| 1698 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1699 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1700 | - */ |
|
| 1701 | - public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1702 | - { |
|
| 1703 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1704 | - $query->joinWith('Instance', $joinBehavior); |
|
| 1705 | - |
|
| 1706 | - return $this->getSubscriptions($query, $con); |
|
| 1707 | - } |
|
| 1708 | - |
|
| 1709 | - |
|
| 1710 | - /** |
|
| 1711 | - * If this collection has already been initialized with |
|
| 1712 | - * an identical criteria, it returns the collection. |
|
| 1713 | - * Otherwise if this Input is new, it will return |
|
| 1714 | - * an empty collection; or if this Input has previously |
|
| 1715 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1716 | - * |
|
| 1717 | - * This method is protected by default in order to keep the public |
|
| 1718 | - * api reasonable. You can provide public methods for those you |
|
| 1719 | - * actually need in Input. |
|
| 1720 | - * |
|
| 1721 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1722 | - * @param ConnectionInterface $con optional connection object |
|
| 1723 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1724 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1725 | - */ |
|
| 1726 | - public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1727 | - { |
|
| 1728 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1729 | - $query->joinWith('User', $joinBehavior); |
|
| 1730 | - |
|
| 1731 | - return $this->getSubscriptions($query, $con); |
|
| 1732 | - } |
|
| 1733 | - |
|
| 1734 | - |
|
| 1735 | - /** |
|
| 1736 | - * If this collection has already been initialized with |
|
| 1737 | - * an identical criteria, it returns the collection. |
|
| 1738 | - * Otherwise if this Input is new, it will return |
|
| 1739 | - * an empty collection; or if this Input has previously |
|
| 1740 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1741 | - * |
|
| 1742 | - * This method is protected by default in order to keep the public |
|
| 1743 | - * api reasonable. You can provide public methods for those you |
|
| 1744 | - * actually need in Input. |
|
| 1745 | - * |
|
| 1746 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1747 | - * @param ConnectionInterface $con optional connection object |
|
| 1748 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1749 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1750 | - */ |
|
| 1751 | - public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1752 | - { |
|
| 1753 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1754 | - $query->joinWith('Channel', $joinBehavior); |
|
| 1755 | - |
|
| 1756 | - return $this->getSubscriptions($query, $con); |
|
| 1757 | - } |
|
| 1758 | - |
|
| 1759 | - /** |
|
| 1760 | - * Clears the current object, sets all attributes to their default values and removes |
|
| 1761 | - * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 1762 | - * change of those foreign objects when you call `save` there). |
|
| 1763 | - */ |
|
| 1764 | - public function clear() |
|
| 1765 | - { |
|
| 1766 | - if (null !== $this->aInstance) { |
|
| 1767 | - $this->aInstance->removeInput($this); |
|
| 1768 | - } |
|
| 1769 | - $this->uuid = null; |
|
| 1770 | - $this->instance_name = null; |
|
| 1771 | - $this->started = null; |
|
| 1772 | - $this->input = null; |
|
| 1773 | - $this->network = null; |
|
| 1774 | - $this->mux = null; |
|
| 1775 | - $this->weight = null; |
|
| 1776 | - $this->alreadyInSave = false; |
|
| 1777 | - $this->clearAllReferences(); |
|
| 1778 | - $this->resetModified(); |
|
| 1779 | - $this->setNew(true); |
|
| 1780 | - $this->setDeleted(false); |
|
| 1781 | - } |
|
| 1782 | - |
|
| 1783 | - /** |
|
| 1784 | - * Resets all references and back-references to other model objects or collections of model objects. |
|
| 1785 | - * |
|
| 1786 | - * This method is used to reset all php object references (not the actual reference in the database). |
|
| 1787 | - * Necessary for object serialisation. |
|
| 1788 | - * |
|
| 1789 | - * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 1790 | - */ |
|
| 1791 | - public function clearAllReferences($deep = false) |
|
| 1792 | - { |
|
| 1793 | - if ($deep) { |
|
| 1794 | - if ($this->collSubscriptions) { |
|
| 1795 | - foreach ($this->collSubscriptions as $o) { |
|
| 1796 | - $o->clearAllReferences($deep); |
|
| 1797 | - } |
|
| 1798 | - } |
|
| 1799 | - } // if ($deep) |
|
| 1800 | - |
|
| 1801 | - $this->collSubscriptions = null; |
|
| 1802 | - $this->aInstance = null; |
|
| 1803 | - } |
|
| 1804 | - |
|
| 1805 | - /** |
|
| 1806 | - * Return the string representation of this object |
|
| 1807 | - * |
|
| 1808 | - * @return string |
|
| 1809 | - */ |
|
| 1810 | - public function __toString() |
|
| 1811 | - { |
|
| 1812 | - return (string) $this->exportTo(InputTableMap::DEFAULT_STRING_FORMAT); |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - /** |
|
| 1816 | - * Code to be run before persisting the object |
|
| 1817 | - * @param ConnectionInterface $con |
|
| 1818 | - * @return boolean |
|
| 1819 | - */ |
|
| 1820 | - public function preSave(ConnectionInterface $con = null) |
|
| 1821 | - { |
|
| 1822 | - return true; |
|
| 1823 | - } |
|
| 1824 | - |
|
| 1825 | - /** |
|
| 1826 | - * Code to be run after persisting the object |
|
| 1827 | - * @param ConnectionInterface $con |
|
| 1828 | - */ |
|
| 1829 | - public function postSave(ConnectionInterface $con = null) |
|
| 1830 | - { |
|
| 1831 | - |
|
| 1832 | - } |
|
| 1833 | - |
|
| 1834 | - /** |
|
| 1835 | - * Code to be run before inserting to database |
|
| 1836 | - * @param ConnectionInterface $con |
|
| 1837 | - * @return boolean |
|
| 1838 | - */ |
|
| 1839 | - public function preInsert(ConnectionInterface $con = null) |
|
| 1840 | - { |
|
| 1841 | - return true; |
|
| 1842 | - } |
|
| 1843 | - |
|
| 1844 | - /** |
|
| 1845 | - * Code to be run after inserting to database |
|
| 1846 | - * @param ConnectionInterface $con |
|
| 1847 | - */ |
|
| 1848 | - public function postInsert(ConnectionInterface $con = null) |
|
| 1849 | - { |
|
| 1850 | - |
|
| 1851 | - } |
|
| 1852 | - |
|
| 1853 | - /** |
|
| 1854 | - * Code to be run before updating the object in database |
|
| 1855 | - * @param ConnectionInterface $con |
|
| 1856 | - * @return boolean |
|
| 1857 | - */ |
|
| 1858 | - public function preUpdate(ConnectionInterface $con = null) |
|
| 1859 | - { |
|
| 1860 | - return true; |
|
| 1861 | - } |
|
| 1862 | - |
|
| 1863 | - /** |
|
| 1864 | - * Code to be run after updating the object in database |
|
| 1865 | - * @param ConnectionInterface $con |
|
| 1866 | - */ |
|
| 1867 | - public function postUpdate(ConnectionInterface $con = null) |
|
| 1868 | - { |
|
| 1869 | - |
|
| 1870 | - } |
|
| 1871 | - |
|
| 1872 | - /** |
|
| 1873 | - * Code to be run before deleting the object in database |
|
| 1874 | - * @param ConnectionInterface $con |
|
| 1875 | - * @return boolean |
|
| 1876 | - */ |
|
| 1877 | - public function preDelete(ConnectionInterface $con = null) |
|
| 1878 | - { |
|
| 1879 | - return true; |
|
| 1880 | - } |
|
| 1881 | - |
|
| 1882 | - /** |
|
| 1883 | - * Code to be run after deleting the object in database |
|
| 1884 | - * @param ConnectionInterface $con |
|
| 1885 | - */ |
|
| 1886 | - public function postDelete(ConnectionInterface $con = null) |
|
| 1887 | - { |
|
| 1888 | - |
|
| 1889 | - } |
|
| 1890 | - |
|
| 1891 | - |
|
| 1892 | - /** |
|
| 1893 | - * Derived method to catches calls to undefined methods. |
|
| 1894 | - * |
|
| 1895 | - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 1896 | - * Allows to define default __call() behavior if you overwrite __call() |
|
| 1897 | - * |
|
| 1898 | - * @param string $name |
|
| 1899 | - * @param mixed $params |
|
| 1900 | - * |
|
| 1901 | - * @return array|string |
|
| 1902 | - */ |
|
| 1903 | - public function __call($name, $params) |
|
| 1904 | - { |
|
| 1905 | - if (0 === strpos($name, 'get')) { |
|
| 1906 | - $virtualColumn = substr($name, 3); |
|
| 1907 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1908 | - return $this->getVirtualColumn($virtualColumn); |
|
| 1909 | - } |
|
| 1910 | - |
|
| 1911 | - $virtualColumn = lcfirst($virtualColumn); |
|
| 1912 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1913 | - return $this->getVirtualColumn($virtualColumn); |
|
| 1914 | - } |
|
| 1915 | - } |
|
| 1916 | - |
|
| 1917 | - if (0 === strpos($name, 'from')) { |
|
| 1918 | - $format = substr($name, 4); |
|
| 1919 | - |
|
| 1920 | - return $this->importFrom($format, reset($params)); |
|
| 1921 | - } |
|
| 1922 | - |
|
| 1923 | - if (0 === strpos($name, 'to')) { |
|
| 1924 | - $format = substr($name, 2); |
|
| 1925 | - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 1926 | - |
|
| 1927 | - return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 1928 | - } |
|
| 1929 | - |
|
| 1930 | - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 1931 | - } |
|
| 1438 | + } |
|
| 1439 | + |
|
| 1440 | + return $this->aInstance; |
|
| 1441 | + } |
|
| 1442 | + |
|
| 1443 | + |
|
| 1444 | + /** |
|
| 1445 | + * Initializes a collection based on the name of a relation. |
|
| 1446 | + * Avoids crafting an 'init[$relationName]s' method name |
|
| 1447 | + * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1448 | + * |
|
| 1449 | + * @param string $relationName The name of the relation to initialize |
|
| 1450 | + * @return void |
|
| 1451 | + */ |
|
| 1452 | + public function initRelation($relationName) |
|
| 1453 | + { |
|
| 1454 | + if ('Subscription' == $relationName) { |
|
| 1455 | + return $this->initSubscriptions(); |
|
| 1456 | + } |
|
| 1457 | + } |
|
| 1458 | + |
|
| 1459 | + /** |
|
| 1460 | + * Clears out the collSubscriptions collection |
|
| 1461 | + * |
|
| 1462 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1463 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1464 | + * |
|
| 1465 | + * @return void |
|
| 1466 | + * @see addSubscriptions() |
|
| 1467 | + */ |
|
| 1468 | + public function clearSubscriptions() |
|
| 1469 | + { |
|
| 1470 | + $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 1471 | + } |
|
| 1472 | + |
|
| 1473 | + /** |
|
| 1474 | + * Reset is the collSubscriptions collection loaded partially. |
|
| 1475 | + */ |
|
| 1476 | + public function resetPartialSubscriptions($v = true) |
|
| 1477 | + { |
|
| 1478 | + $this->collSubscriptionsPartial = $v; |
|
| 1479 | + } |
|
| 1480 | + |
|
| 1481 | + /** |
|
| 1482 | + * Initializes the collSubscriptions collection. |
|
| 1483 | + * |
|
| 1484 | + * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 1485 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1486 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1487 | + * |
|
| 1488 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1489 | + * the collection even if it is not empty |
|
| 1490 | + * |
|
| 1491 | + * @return void |
|
| 1492 | + */ |
|
| 1493 | + public function initSubscriptions($overrideExisting = true) |
|
| 1494 | + { |
|
| 1495 | + if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 1496 | + return; |
|
| 1497 | + } |
|
| 1498 | + |
|
| 1499 | + $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1500 | + |
|
| 1501 | + $this->collSubscriptions = new $collectionClassName; |
|
| 1502 | + $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 1503 | + } |
|
| 1504 | + |
|
| 1505 | + /** |
|
| 1506 | + * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 1507 | + * |
|
| 1508 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1509 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1510 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1511 | + * If this ChildInput is new, it will return |
|
| 1512 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1513 | + * |
|
| 1514 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1515 | + * @param ConnectionInterface $con optional connection object |
|
| 1516 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1517 | + * @throws PropelException |
|
| 1518 | + */ |
|
| 1519 | + public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1520 | + { |
|
| 1521 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1522 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1523 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1524 | + // return empty collection |
|
| 1525 | + $this->initSubscriptions(); |
|
| 1526 | + } else { |
|
| 1527 | + $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 1528 | + ->filterByInput($this) |
|
| 1529 | + ->find($con); |
|
| 1530 | + |
|
| 1531 | + if (null !== $criteria) { |
|
| 1532 | + if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 1533 | + $this->initSubscriptions(false); |
|
| 1534 | + |
|
| 1535 | + foreach ($collSubscriptions as $obj) { |
|
| 1536 | + if (false == $this->collSubscriptions->contains($obj)) { |
|
| 1537 | + $this->collSubscriptions->append($obj); |
|
| 1538 | + } |
|
| 1539 | + } |
|
| 1540 | + |
|
| 1541 | + $this->collSubscriptionsPartial = true; |
|
| 1542 | + } |
|
| 1543 | + |
|
| 1544 | + return $collSubscriptions; |
|
| 1545 | + } |
|
| 1546 | + |
|
| 1547 | + if ($partial && $this->collSubscriptions) { |
|
| 1548 | + foreach ($this->collSubscriptions as $obj) { |
|
| 1549 | + if ($obj->isNew()) { |
|
| 1550 | + $collSubscriptions[] = $obj; |
|
| 1551 | + } |
|
| 1552 | + } |
|
| 1553 | + } |
|
| 1554 | + |
|
| 1555 | + $this->collSubscriptions = $collSubscriptions; |
|
| 1556 | + $this->collSubscriptionsPartial = false; |
|
| 1557 | + } |
|
| 1558 | + } |
|
| 1559 | + |
|
| 1560 | + return $this->collSubscriptions; |
|
| 1561 | + } |
|
| 1562 | + |
|
| 1563 | + /** |
|
| 1564 | + * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 1565 | + * to the current object. |
|
| 1566 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1567 | + * and new objects from the given Propel collection. |
|
| 1568 | + * |
|
| 1569 | + * @param Collection $subscriptions A Propel collection. |
|
| 1570 | + * @param ConnectionInterface $con Optional connection object |
|
| 1571 | + * @return $this|ChildInput The current object (for fluent API support) |
|
| 1572 | + */ |
|
| 1573 | + public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1574 | + { |
|
| 1575 | + /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 1576 | + $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 1577 | + |
|
| 1578 | + |
|
| 1579 | + $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 1580 | + |
|
| 1581 | + foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 1582 | + $subscriptionRemoved->setInput(null); |
|
| 1583 | + } |
|
| 1584 | + |
|
| 1585 | + $this->collSubscriptions = null; |
|
| 1586 | + foreach ($subscriptions as $subscription) { |
|
| 1587 | + $this->addSubscription($subscription); |
|
| 1588 | + } |
|
| 1589 | + |
|
| 1590 | + $this->collSubscriptions = $subscriptions; |
|
| 1591 | + $this->collSubscriptionsPartial = false; |
|
| 1592 | + |
|
| 1593 | + return $this; |
|
| 1594 | + } |
|
| 1595 | + |
|
| 1596 | + /** |
|
| 1597 | + * Returns the number of related Subscription objects. |
|
| 1598 | + * |
|
| 1599 | + * @param Criteria $criteria |
|
| 1600 | + * @param boolean $distinct |
|
| 1601 | + * @param ConnectionInterface $con |
|
| 1602 | + * @return int Count of related Subscription objects. |
|
| 1603 | + * @throws PropelException |
|
| 1604 | + */ |
|
| 1605 | + public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1606 | + { |
|
| 1607 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1608 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1609 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1610 | + return 0; |
|
| 1611 | + } |
|
| 1612 | + |
|
| 1613 | + if ($partial && !$criteria) { |
|
| 1614 | + return count($this->getSubscriptions()); |
|
| 1615 | + } |
|
| 1616 | + |
|
| 1617 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1618 | + if ($distinct) { |
|
| 1619 | + $query->distinct(); |
|
| 1620 | + } |
|
| 1621 | + |
|
| 1622 | + return $query |
|
| 1623 | + ->filterByInput($this) |
|
| 1624 | + ->count($con); |
|
| 1625 | + } |
|
| 1626 | + |
|
| 1627 | + return count($this->collSubscriptions); |
|
| 1628 | + } |
|
| 1629 | + |
|
| 1630 | + /** |
|
| 1631 | + * Method called to associate a ChildSubscription object to this object |
|
| 1632 | + * through the ChildSubscription foreign key attribute. |
|
| 1633 | + * |
|
| 1634 | + * @param ChildSubscription $l ChildSubscription |
|
| 1635 | + * @return $this|\Jalle19\StatusManager\Database\Input The current object (for fluent API support) |
|
| 1636 | + */ |
|
| 1637 | + public function addSubscription(ChildSubscription $l) |
|
| 1638 | + { |
|
| 1639 | + if ($this->collSubscriptions === null) { |
|
| 1640 | + $this->initSubscriptions(); |
|
| 1641 | + $this->collSubscriptionsPartial = true; |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + if (!$this->collSubscriptions->contains($l)) { |
|
| 1645 | + $this->doAddSubscription($l); |
|
| 1646 | + |
|
| 1647 | + if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 1648 | + $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 1649 | + } |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + return $this; |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + /** |
|
| 1656 | + * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 1657 | + */ |
|
| 1658 | + protected function doAddSubscription(ChildSubscription $subscription) |
|
| 1659 | + { |
|
| 1660 | + $this->collSubscriptions[]= $subscription; |
|
| 1661 | + $subscription->setInput($this); |
|
| 1662 | + } |
|
| 1663 | + |
|
| 1664 | + /** |
|
| 1665 | + * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 1666 | + * @return $this|ChildInput The current object (for fluent API support) |
|
| 1667 | + */ |
|
| 1668 | + public function removeSubscription(ChildSubscription $subscription) |
|
| 1669 | + { |
|
| 1670 | + if ($this->getSubscriptions()->contains($subscription)) { |
|
| 1671 | + $pos = $this->collSubscriptions->search($subscription); |
|
| 1672 | + $this->collSubscriptions->remove($pos); |
|
| 1673 | + if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 1674 | + $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 1675 | + $this->subscriptionsScheduledForDeletion->clear(); |
|
| 1676 | + } |
|
| 1677 | + $this->subscriptionsScheduledForDeletion[]= $subscription; |
|
| 1678 | + $subscription->setInput(null); |
|
| 1679 | + } |
|
| 1680 | + |
|
| 1681 | + return $this; |
|
| 1682 | + } |
|
| 1683 | + |
|
| 1684 | + |
|
| 1685 | + /** |
|
| 1686 | + * If this collection has already been initialized with |
|
| 1687 | + * an identical criteria, it returns the collection. |
|
| 1688 | + * Otherwise if this Input is new, it will return |
|
| 1689 | + * an empty collection; or if this Input has previously |
|
| 1690 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1691 | + * |
|
| 1692 | + * This method is protected by default in order to keep the public |
|
| 1693 | + * api reasonable. You can provide public methods for those you |
|
| 1694 | + * actually need in Input. |
|
| 1695 | + * |
|
| 1696 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1697 | + * @param ConnectionInterface $con optional connection object |
|
| 1698 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1699 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1700 | + */ |
|
| 1701 | + public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1702 | + { |
|
| 1703 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1704 | + $query->joinWith('Instance', $joinBehavior); |
|
| 1705 | + |
|
| 1706 | + return $this->getSubscriptions($query, $con); |
|
| 1707 | + } |
|
| 1708 | + |
|
| 1709 | + |
|
| 1710 | + /** |
|
| 1711 | + * If this collection has already been initialized with |
|
| 1712 | + * an identical criteria, it returns the collection. |
|
| 1713 | + * Otherwise if this Input is new, it will return |
|
| 1714 | + * an empty collection; or if this Input has previously |
|
| 1715 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1716 | + * |
|
| 1717 | + * This method is protected by default in order to keep the public |
|
| 1718 | + * api reasonable. You can provide public methods for those you |
|
| 1719 | + * actually need in Input. |
|
| 1720 | + * |
|
| 1721 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1722 | + * @param ConnectionInterface $con optional connection object |
|
| 1723 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1724 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1725 | + */ |
|
| 1726 | + public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1727 | + { |
|
| 1728 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1729 | + $query->joinWith('User', $joinBehavior); |
|
| 1730 | + |
|
| 1731 | + return $this->getSubscriptions($query, $con); |
|
| 1732 | + } |
|
| 1733 | + |
|
| 1734 | + |
|
| 1735 | + /** |
|
| 1736 | + * If this collection has already been initialized with |
|
| 1737 | + * an identical criteria, it returns the collection. |
|
| 1738 | + * Otherwise if this Input is new, it will return |
|
| 1739 | + * an empty collection; or if this Input has previously |
|
| 1740 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1741 | + * |
|
| 1742 | + * This method is protected by default in order to keep the public |
|
| 1743 | + * api reasonable. You can provide public methods for those you |
|
| 1744 | + * actually need in Input. |
|
| 1745 | + * |
|
| 1746 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1747 | + * @param ConnectionInterface $con optional connection object |
|
| 1748 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1749 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1750 | + */ |
|
| 1751 | + public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1752 | + { |
|
| 1753 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1754 | + $query->joinWith('Channel', $joinBehavior); |
|
| 1755 | + |
|
| 1756 | + return $this->getSubscriptions($query, $con); |
|
| 1757 | + } |
|
| 1758 | + |
|
| 1759 | + /** |
|
| 1760 | + * Clears the current object, sets all attributes to their default values and removes |
|
| 1761 | + * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 1762 | + * change of those foreign objects when you call `save` there). |
|
| 1763 | + */ |
|
| 1764 | + public function clear() |
|
| 1765 | + { |
|
| 1766 | + if (null !== $this->aInstance) { |
|
| 1767 | + $this->aInstance->removeInput($this); |
|
| 1768 | + } |
|
| 1769 | + $this->uuid = null; |
|
| 1770 | + $this->instance_name = null; |
|
| 1771 | + $this->started = null; |
|
| 1772 | + $this->input = null; |
|
| 1773 | + $this->network = null; |
|
| 1774 | + $this->mux = null; |
|
| 1775 | + $this->weight = null; |
|
| 1776 | + $this->alreadyInSave = false; |
|
| 1777 | + $this->clearAllReferences(); |
|
| 1778 | + $this->resetModified(); |
|
| 1779 | + $this->setNew(true); |
|
| 1780 | + $this->setDeleted(false); |
|
| 1781 | + } |
|
| 1782 | + |
|
| 1783 | + /** |
|
| 1784 | + * Resets all references and back-references to other model objects or collections of model objects. |
|
| 1785 | + * |
|
| 1786 | + * This method is used to reset all php object references (not the actual reference in the database). |
|
| 1787 | + * Necessary for object serialisation. |
|
| 1788 | + * |
|
| 1789 | + * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 1790 | + */ |
|
| 1791 | + public function clearAllReferences($deep = false) |
|
| 1792 | + { |
|
| 1793 | + if ($deep) { |
|
| 1794 | + if ($this->collSubscriptions) { |
|
| 1795 | + foreach ($this->collSubscriptions as $o) { |
|
| 1796 | + $o->clearAllReferences($deep); |
|
| 1797 | + } |
|
| 1798 | + } |
|
| 1799 | + } // if ($deep) |
|
| 1800 | + |
|
| 1801 | + $this->collSubscriptions = null; |
|
| 1802 | + $this->aInstance = null; |
|
| 1803 | + } |
|
| 1804 | + |
|
| 1805 | + /** |
|
| 1806 | + * Return the string representation of this object |
|
| 1807 | + * |
|
| 1808 | + * @return string |
|
| 1809 | + */ |
|
| 1810 | + public function __toString() |
|
| 1811 | + { |
|
| 1812 | + return (string) $this->exportTo(InputTableMap::DEFAULT_STRING_FORMAT); |
|
| 1813 | + } |
|
| 1814 | + |
|
| 1815 | + /** |
|
| 1816 | + * Code to be run before persisting the object |
|
| 1817 | + * @param ConnectionInterface $con |
|
| 1818 | + * @return boolean |
|
| 1819 | + */ |
|
| 1820 | + public function preSave(ConnectionInterface $con = null) |
|
| 1821 | + { |
|
| 1822 | + return true; |
|
| 1823 | + } |
|
| 1824 | + |
|
| 1825 | + /** |
|
| 1826 | + * Code to be run after persisting the object |
|
| 1827 | + * @param ConnectionInterface $con |
|
| 1828 | + */ |
|
| 1829 | + public function postSave(ConnectionInterface $con = null) |
|
| 1830 | + { |
|
| 1831 | + |
|
| 1832 | + } |
|
| 1833 | + |
|
| 1834 | + /** |
|
| 1835 | + * Code to be run before inserting to database |
|
| 1836 | + * @param ConnectionInterface $con |
|
| 1837 | + * @return boolean |
|
| 1838 | + */ |
|
| 1839 | + public function preInsert(ConnectionInterface $con = null) |
|
| 1840 | + { |
|
| 1841 | + return true; |
|
| 1842 | + } |
|
| 1843 | + |
|
| 1844 | + /** |
|
| 1845 | + * Code to be run after inserting to database |
|
| 1846 | + * @param ConnectionInterface $con |
|
| 1847 | + */ |
|
| 1848 | + public function postInsert(ConnectionInterface $con = null) |
|
| 1849 | + { |
|
| 1850 | + |
|
| 1851 | + } |
|
| 1852 | + |
|
| 1853 | + /** |
|
| 1854 | + * Code to be run before updating the object in database |
|
| 1855 | + * @param ConnectionInterface $con |
|
| 1856 | + * @return boolean |
|
| 1857 | + */ |
|
| 1858 | + public function preUpdate(ConnectionInterface $con = null) |
|
| 1859 | + { |
|
| 1860 | + return true; |
|
| 1861 | + } |
|
| 1862 | + |
|
| 1863 | + /** |
|
| 1864 | + * Code to be run after updating the object in database |
|
| 1865 | + * @param ConnectionInterface $con |
|
| 1866 | + */ |
|
| 1867 | + public function postUpdate(ConnectionInterface $con = null) |
|
| 1868 | + { |
|
| 1869 | + |
|
| 1870 | + } |
|
| 1871 | + |
|
| 1872 | + /** |
|
| 1873 | + * Code to be run before deleting the object in database |
|
| 1874 | + * @param ConnectionInterface $con |
|
| 1875 | + * @return boolean |
|
| 1876 | + */ |
|
| 1877 | + public function preDelete(ConnectionInterface $con = null) |
|
| 1878 | + { |
|
| 1879 | + return true; |
|
| 1880 | + } |
|
| 1881 | + |
|
| 1882 | + /** |
|
| 1883 | + * Code to be run after deleting the object in database |
|
| 1884 | + * @param ConnectionInterface $con |
|
| 1885 | + */ |
|
| 1886 | + public function postDelete(ConnectionInterface $con = null) |
|
| 1887 | + { |
|
| 1888 | + |
|
| 1889 | + } |
|
| 1890 | + |
|
| 1891 | + |
|
| 1892 | + /** |
|
| 1893 | + * Derived method to catches calls to undefined methods. |
|
| 1894 | + * |
|
| 1895 | + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 1896 | + * Allows to define default __call() behavior if you overwrite __call() |
|
| 1897 | + * |
|
| 1898 | + * @param string $name |
|
| 1899 | + * @param mixed $params |
|
| 1900 | + * |
|
| 1901 | + * @return array|string |
|
| 1902 | + */ |
|
| 1903 | + public function __call($name, $params) |
|
| 1904 | + { |
|
| 1905 | + if (0 === strpos($name, 'get')) { |
|
| 1906 | + $virtualColumn = substr($name, 3); |
|
| 1907 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1908 | + return $this->getVirtualColumn($virtualColumn); |
|
| 1909 | + } |
|
| 1910 | + |
|
| 1911 | + $virtualColumn = lcfirst($virtualColumn); |
|
| 1912 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1913 | + return $this->getVirtualColumn($virtualColumn); |
|
| 1914 | + } |
|
| 1915 | + } |
|
| 1916 | + |
|
| 1917 | + if (0 === strpos($name, 'from')) { |
|
| 1918 | + $format = substr($name, 4); |
|
| 1919 | + |
|
| 1920 | + return $this->importFrom($format, reset($params)); |
|
| 1921 | + } |
|
| 1922 | + |
|
| 1923 | + if (0 === strpos($name, 'to')) { |
|
| 1924 | + $format = substr($name, 2); |
|
| 1925 | + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 1926 | + |
|
| 1927 | + return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 1928 | + } |
|
| 1929 | + |
|
| 1930 | + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 1931 | + } |
|
| 1932 | 1932 | |
| 1933 | 1933 | } |
@@ -76,7 +76,6 @@ discard block |
||
| 76 | 76 | * @method ChildInput findOneByNetwork(string $network) Return the first ChildInput filtered by the network column |
| 77 | 77 | * @method ChildInput findOneByMux(string $mux) Return the first ChildInput filtered by the mux column |
| 78 | 78 | * @method ChildInput findOneByWeight(int $weight) Return the first ChildInput filtered by the weight column * |
| 79 | - |
|
| 80 | 79 | * @method ChildInput requirePk($key, ConnectionInterface $con = null) Return the ChildInput by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
| 81 | 80 | * @method ChildInput requireOne(ConnectionInterface $con = null) Return the first ChildInput matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
| 82 | 81 | * |
@@ -101,637 +100,637 @@ discard block |
||
| 101 | 100 | */ |
| 102 | 101 | abstract class InputQuery extends ModelCriteria |
| 103 | 102 | { |
| 104 | - protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Initializes internal state of \Jalle19\StatusManager\Database\Base\InputQuery object. |
|
| 108 | - * |
|
| 109 | - * @param string $dbName The database name |
|
| 110 | - * @param string $modelName The phpName of a model, e.g. 'Book' |
|
| 111 | - * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
| 112 | - */ |
|
| 113 | - public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Input', $modelAlias = null) |
|
| 114 | - { |
|
| 115 | - parent::__construct($dbName, $modelName, $modelAlias); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Returns a new ChildInputQuery object. |
|
| 120 | - * |
|
| 121 | - * @param string $modelAlias The alias of a model in the query |
|
| 122 | - * @param Criteria $criteria Optional Criteria to build the query from |
|
| 123 | - * |
|
| 124 | - * @return ChildInputQuery |
|
| 125 | - */ |
|
| 126 | - public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 127 | - { |
|
| 128 | - if ($criteria instanceof ChildInputQuery) { |
|
| 129 | - return $criteria; |
|
| 130 | - } |
|
| 131 | - $query = new ChildInputQuery(); |
|
| 132 | - if (null !== $modelAlias) { |
|
| 133 | - $query->setModelAlias($modelAlias); |
|
| 134 | - } |
|
| 135 | - if ($criteria instanceof Criteria) { |
|
| 136 | - $query->mergeWith($criteria); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return $query; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Find object by primary key. |
|
| 144 | - * Propel uses the instance pool to skip the database if the object exists. |
|
| 145 | - * Go fast if the query is untouched. |
|
| 146 | - * |
|
| 147 | - * <code> |
|
| 148 | - * $obj = $c->findPk(12, $con); |
|
| 149 | - * </code> |
|
| 150 | - * |
|
| 151 | - * @param mixed $key Primary key to use for the query |
|
| 152 | - * @param ConnectionInterface $con an optional connection object |
|
| 153 | - * |
|
| 154 | - * @return ChildInput|array|mixed the result, formatted by the current formatter |
|
| 155 | - */ |
|
| 156 | - public function findPk($key, ConnectionInterface $con = null) |
|
| 157 | - { |
|
| 158 | - if ($key === null) { |
|
| 159 | - return null; |
|
| 160 | - } |
|
| 161 | - if ((null !== ($obj = InputTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
| 162 | - // the object is already in the instance pool |
|
| 163 | - return $obj; |
|
| 164 | - } |
|
| 165 | - if ($con === null) { |
|
| 166 | - $con = Propel::getServiceContainer()->getReadConnection(InputTableMap::DATABASE_NAME); |
|
| 167 | - } |
|
| 168 | - $this->basePreSelect($con); |
|
| 169 | - if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
| 170 | - || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
| 171 | - || $this->map || $this->having || $this->joins) { |
|
| 172 | - return $this->findPkComplex($key, $con); |
|
| 173 | - } else { |
|
| 174 | - return $this->findPkSimple($key, $con); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Find object by primary key using raw SQL to go fast. |
|
| 180 | - * Bypass doSelect() and the object formatter by using generated code. |
|
| 181 | - * |
|
| 182 | - * @param mixed $key Primary key to use for the query |
|
| 183 | - * @param ConnectionInterface $con A connection object |
|
| 184 | - * |
|
| 185 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 186 | - * |
|
| 187 | - * @return ChildInput A model object, or null if the key is not found |
|
| 188 | - */ |
|
| 189 | - protected function findPkSimple($key, ConnectionInterface $con) |
|
| 190 | - { |
|
| 191 | - $sql = 'SELECT uuid, instance_name, started, input, network, mux, weight FROM input WHERE uuid = :p0'; |
|
| 192 | - try { |
|
| 193 | - $stmt = $con->prepare($sql); |
|
| 194 | - $stmt->bindValue(':p0', $key, PDO::PARAM_STR); |
|
| 195 | - $stmt->execute(); |
|
| 196 | - } catch (Exception $e) { |
|
| 197 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 198 | - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
| 199 | - } |
|
| 200 | - $obj = null; |
|
| 201 | - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
| 202 | - /** @var ChildInput $obj */ |
|
| 203 | - $obj = new ChildInput(); |
|
| 204 | - $obj->hydrate($row); |
|
| 205 | - InputTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
| 206 | - } |
|
| 207 | - $stmt->closeCursor(); |
|
| 208 | - |
|
| 209 | - return $obj; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Find object by primary key. |
|
| 214 | - * |
|
| 215 | - * @param mixed $key Primary key to use for the query |
|
| 216 | - * @param ConnectionInterface $con A connection object |
|
| 217 | - * |
|
| 218 | - * @return ChildInput|array|mixed the result, formatted by the current formatter |
|
| 219 | - */ |
|
| 220 | - protected function findPkComplex($key, ConnectionInterface $con) |
|
| 221 | - { |
|
| 222 | - // As the query uses a PK condition, no limit(1) is necessary. |
|
| 223 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 224 | - $dataFetcher = $criteria |
|
| 225 | - ->filterByPrimaryKey($key) |
|
| 226 | - ->doSelect($con); |
|
| 227 | - |
|
| 228 | - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Find objects by primary key |
|
| 233 | - * <code> |
|
| 234 | - * $objs = $c->findPks(array(12, 56, 832), $con); |
|
| 235 | - * </code> |
|
| 236 | - * @param array $keys Primary keys to use for the query |
|
| 237 | - * @param ConnectionInterface $con an optional connection object |
|
| 238 | - * |
|
| 239 | - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
| 240 | - */ |
|
| 241 | - public function findPks($keys, ConnectionInterface $con = null) |
|
| 242 | - { |
|
| 243 | - if (null === $con) { |
|
| 244 | - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
| 245 | - } |
|
| 246 | - $this->basePreSelect($con); |
|
| 247 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 248 | - $dataFetcher = $criteria |
|
| 249 | - ->filterByPrimaryKeys($keys) |
|
| 250 | - ->doSelect($con); |
|
| 251 | - |
|
| 252 | - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Filter the query by primary key |
|
| 257 | - * |
|
| 258 | - * @param mixed $key Primary key to use for the query |
|
| 259 | - * |
|
| 260 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 261 | - */ |
|
| 262 | - public function filterByPrimaryKey($key) |
|
| 263 | - { |
|
| 264 | - |
|
| 265 | - return $this->addUsingAlias(InputTableMap::COL_UUID, $key, Criteria::EQUAL); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * Filter the query by a list of primary keys |
|
| 270 | - * |
|
| 271 | - * @param array $keys The list of primary key to use for the query |
|
| 272 | - * |
|
| 273 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 274 | - */ |
|
| 275 | - public function filterByPrimaryKeys($keys) |
|
| 276 | - { |
|
| 277 | - |
|
| 278 | - return $this->addUsingAlias(InputTableMap::COL_UUID, $keys, Criteria::IN); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Filter the query on the uuid column |
|
| 283 | - * |
|
| 284 | - * Example usage: |
|
| 285 | - * <code> |
|
| 286 | - * $query->filterByUuid('fooValue'); // WHERE uuid = 'fooValue' |
|
| 287 | - * $query->filterByUuid('%fooValue%'); // WHERE uuid LIKE '%fooValue%' |
|
| 288 | - * </code> |
|
| 289 | - * |
|
| 290 | - * @param string $uuid The value to use as filter. |
|
| 291 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 292 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 293 | - * |
|
| 294 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 295 | - */ |
|
| 296 | - public function filterByUuid($uuid = null, $comparison = null) |
|
| 297 | - { |
|
| 298 | - if (null === $comparison) { |
|
| 299 | - if (is_array($uuid)) { |
|
| 300 | - $comparison = Criteria::IN; |
|
| 301 | - } elseif (preg_match('/[\%\*]/', $uuid)) { |
|
| 302 | - $uuid = str_replace('*', '%', $uuid); |
|
| 303 | - $comparison = Criteria::LIKE; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return $this->addUsingAlias(InputTableMap::COL_UUID, $uuid, $comparison); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Filter the query on the instance_name column |
|
| 312 | - * |
|
| 313 | - * Example usage: |
|
| 314 | - * <code> |
|
| 315 | - * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
| 316 | - * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
| 317 | - * </code> |
|
| 318 | - * |
|
| 319 | - * @param string $instanceName The value to use as filter. |
|
| 320 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 321 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 322 | - * |
|
| 323 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 324 | - */ |
|
| 325 | - public function filterByInstanceName($instanceName = null, $comparison = null) |
|
| 326 | - { |
|
| 327 | - if (null === $comparison) { |
|
| 328 | - if (is_array($instanceName)) { |
|
| 329 | - $comparison = Criteria::IN; |
|
| 330 | - } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
| 331 | - $instanceName = str_replace('*', '%', $instanceName); |
|
| 332 | - $comparison = Criteria::LIKE; |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - return $this->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Filter the query on the started column |
|
| 341 | - * |
|
| 342 | - * Example usage: |
|
| 343 | - * <code> |
|
| 344 | - * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
|
| 345 | - * $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
|
| 346 | - * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
|
| 347 | - * </code> |
|
| 348 | - * |
|
| 349 | - * @param mixed $started The value to use as filter. |
|
| 350 | - * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
| 351 | - * Empty strings are treated as NULL. |
|
| 352 | - * Use scalar values for equality. |
|
| 353 | - * Use array values for in_array() equivalent. |
|
| 354 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 355 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 356 | - * |
|
| 357 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 358 | - */ |
|
| 359 | - public function filterByStarted($started = null, $comparison = null) |
|
| 360 | - { |
|
| 361 | - if (is_array($started)) { |
|
| 362 | - $useMinMax = false; |
|
| 363 | - if (isset($started['min'])) { |
|
| 364 | - $this->addUsingAlias(InputTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
|
| 365 | - $useMinMax = true; |
|
| 366 | - } |
|
| 367 | - if (isset($started['max'])) { |
|
| 368 | - $this->addUsingAlias(InputTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
|
| 369 | - $useMinMax = true; |
|
| 370 | - } |
|
| 371 | - if ($useMinMax) { |
|
| 372 | - return $this; |
|
| 373 | - } |
|
| 374 | - if (null === $comparison) { |
|
| 375 | - $comparison = Criteria::IN; |
|
| 376 | - } |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - return $this->addUsingAlias(InputTableMap::COL_STARTED, $started, $comparison); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * Filter the query on the input column |
|
| 384 | - * |
|
| 385 | - * Example usage: |
|
| 386 | - * <code> |
|
| 387 | - * $query->filterByInput('fooValue'); // WHERE input = 'fooValue' |
|
| 388 | - * $query->filterByInput('%fooValue%'); // WHERE input LIKE '%fooValue%' |
|
| 389 | - * </code> |
|
| 390 | - * |
|
| 391 | - * @param string $input The value to use as filter. |
|
| 392 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 393 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 394 | - * |
|
| 395 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 396 | - */ |
|
| 397 | - public function filterByInput($input = null, $comparison = null) |
|
| 398 | - { |
|
| 399 | - if (null === $comparison) { |
|
| 400 | - if (is_array($input)) { |
|
| 401 | - $comparison = Criteria::IN; |
|
| 402 | - } elseif (preg_match('/[\%\*]/', $input)) { |
|
| 403 | - $input = str_replace('*', '%', $input); |
|
| 404 | - $comparison = Criteria::LIKE; |
|
| 405 | - } |
|
| 406 | - } |
|
| 407 | - |
|
| 408 | - return $this->addUsingAlias(InputTableMap::COL_INPUT, $input, $comparison); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * Filter the query on the network column |
|
| 413 | - * |
|
| 414 | - * Example usage: |
|
| 415 | - * <code> |
|
| 416 | - * $query->filterByNetwork('fooValue'); // WHERE network = 'fooValue' |
|
| 417 | - * $query->filterByNetwork('%fooValue%'); // WHERE network LIKE '%fooValue%' |
|
| 418 | - * </code> |
|
| 419 | - * |
|
| 420 | - * @param string $network The value to use as filter. |
|
| 421 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 422 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 423 | - * |
|
| 424 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 425 | - */ |
|
| 426 | - public function filterByNetwork($network = null, $comparison = null) |
|
| 427 | - { |
|
| 428 | - if (null === $comparison) { |
|
| 429 | - if (is_array($network)) { |
|
| 430 | - $comparison = Criteria::IN; |
|
| 431 | - } elseif (preg_match('/[\%\*]/', $network)) { |
|
| 432 | - $network = str_replace('*', '%', $network); |
|
| 433 | - $comparison = Criteria::LIKE; |
|
| 434 | - } |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - return $this->addUsingAlias(InputTableMap::COL_NETWORK, $network, $comparison); |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * Filter the query on the mux column |
|
| 442 | - * |
|
| 443 | - * Example usage: |
|
| 444 | - * <code> |
|
| 445 | - * $query->filterByMux('fooValue'); // WHERE mux = 'fooValue' |
|
| 446 | - * $query->filterByMux('%fooValue%'); // WHERE mux LIKE '%fooValue%' |
|
| 447 | - * </code> |
|
| 448 | - * |
|
| 449 | - * @param string $mux The value to use as filter. |
|
| 450 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 451 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 452 | - * |
|
| 453 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 454 | - */ |
|
| 455 | - public function filterByMux($mux = null, $comparison = null) |
|
| 456 | - { |
|
| 457 | - if (null === $comparison) { |
|
| 458 | - if (is_array($mux)) { |
|
| 459 | - $comparison = Criteria::IN; |
|
| 460 | - } elseif (preg_match('/[\%\*]/', $mux)) { |
|
| 461 | - $mux = str_replace('*', '%', $mux); |
|
| 462 | - $comparison = Criteria::LIKE; |
|
| 463 | - } |
|
| 464 | - } |
|
| 465 | - |
|
| 466 | - return $this->addUsingAlias(InputTableMap::COL_MUX, $mux, $comparison); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - /** |
|
| 470 | - * Filter the query on the weight column |
|
| 471 | - * |
|
| 472 | - * Example usage: |
|
| 473 | - * <code> |
|
| 474 | - * $query->filterByWeight(1234); // WHERE weight = 1234 |
|
| 475 | - * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34) |
|
| 476 | - * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 |
|
| 477 | - * </code> |
|
| 478 | - * |
|
| 479 | - * @param mixed $weight The value to use as filter. |
|
| 480 | - * Use scalar values for equality. |
|
| 481 | - * Use array values for in_array() equivalent. |
|
| 482 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 483 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 484 | - * |
|
| 485 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 486 | - */ |
|
| 487 | - public function filterByWeight($weight = null, $comparison = null) |
|
| 488 | - { |
|
| 489 | - if (is_array($weight)) { |
|
| 490 | - $useMinMax = false; |
|
| 491 | - if (isset($weight['min'])) { |
|
| 492 | - $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); |
|
| 493 | - $useMinMax = true; |
|
| 494 | - } |
|
| 495 | - if (isset($weight['max'])) { |
|
| 496 | - $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight['max'], Criteria::LESS_EQUAL); |
|
| 497 | - $useMinMax = true; |
|
| 498 | - } |
|
| 499 | - if ($useMinMax) { |
|
| 500 | - return $this; |
|
| 501 | - } |
|
| 502 | - if (null === $comparison) { |
|
| 503 | - $comparison = Criteria::IN; |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - |
|
| 507 | - return $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight, $comparison); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - /** |
|
| 511 | - * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
| 512 | - * |
|
| 513 | - * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
| 514 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 515 | - * |
|
| 516 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 517 | - * |
|
| 518 | - * @return ChildInputQuery The current query, for fluid interface |
|
| 519 | - */ |
|
| 520 | - public function filterByInstance($instance, $comparison = null) |
|
| 521 | - { |
|
| 522 | - if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
| 523 | - return $this |
|
| 524 | - ->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
| 525 | - } elseif ($instance instanceof ObjectCollection) { |
|
| 526 | - if (null === $comparison) { |
|
| 527 | - $comparison = Criteria::IN; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return $this |
|
| 531 | - ->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
| 532 | - } else { |
|
| 533 | - throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
| 534 | - } |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - /** |
|
| 538 | - * Adds a JOIN clause to the query using the Instance relation |
|
| 539 | - * |
|
| 540 | - * @param string $relationAlias optional alias for the relation |
|
| 541 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 542 | - * |
|
| 543 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 544 | - */ |
|
| 545 | - public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 546 | - { |
|
| 547 | - $tableMap = $this->getTableMap(); |
|
| 548 | - $relationMap = $tableMap->getRelation('Instance'); |
|
| 549 | - |
|
| 550 | - // create a ModelJoin object for this join |
|
| 551 | - $join = new ModelJoin(); |
|
| 552 | - $join->setJoinType($joinType); |
|
| 553 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 554 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 555 | - $join->setPreviousJoin($previousJoin); |
|
| 556 | - } |
|
| 557 | - |
|
| 558 | - // add the ModelJoin to the current object |
|
| 559 | - if ($relationAlias) { |
|
| 560 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 561 | - $this->addJoinObject($join, $relationAlias); |
|
| 562 | - } else { |
|
| 563 | - $this->addJoinObject($join, 'Instance'); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - return $this; |
|
| 567 | - } |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * Use the Instance relation Instance object |
|
| 571 | - * |
|
| 572 | - * @see useQuery() |
|
| 573 | - * |
|
| 574 | - * @param string $relationAlias optional alias for the relation, |
|
| 575 | - * to be used as main alias in the secondary query |
|
| 576 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 577 | - * |
|
| 578 | - * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
| 579 | - */ |
|
| 580 | - public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 581 | - { |
|
| 582 | - return $this |
|
| 583 | - ->joinInstance($relationAlias, $joinType) |
|
| 584 | - ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - /** |
|
| 588 | - * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
| 589 | - * |
|
| 590 | - * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
| 591 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 592 | - * |
|
| 593 | - * @return ChildInputQuery The current query, for fluid interface |
|
| 594 | - */ |
|
| 595 | - public function filterBySubscription($subscription, $comparison = null) |
|
| 596 | - { |
|
| 597 | - if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
| 598 | - return $this |
|
| 599 | - ->addUsingAlias(InputTableMap::COL_UUID, $subscription->getInputUuid(), $comparison); |
|
| 600 | - } elseif ($subscription instanceof ObjectCollection) { |
|
| 601 | - return $this |
|
| 602 | - ->useSubscriptionQuery() |
|
| 603 | - ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
| 604 | - ->endUse(); |
|
| 605 | - } else { |
|
| 606 | - throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - /** |
|
| 611 | - * Adds a JOIN clause to the query using the Subscription relation |
|
| 612 | - * |
|
| 613 | - * @param string $relationAlias optional alias for the relation |
|
| 614 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 615 | - * |
|
| 616 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 617 | - */ |
|
| 618 | - public function joinSubscription($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 619 | - { |
|
| 620 | - $tableMap = $this->getTableMap(); |
|
| 621 | - $relationMap = $tableMap->getRelation('Subscription'); |
|
| 622 | - |
|
| 623 | - // create a ModelJoin object for this join |
|
| 624 | - $join = new ModelJoin(); |
|
| 625 | - $join->setJoinType($joinType); |
|
| 626 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 627 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 628 | - $join->setPreviousJoin($previousJoin); |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - // add the ModelJoin to the current object |
|
| 632 | - if ($relationAlias) { |
|
| 633 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 634 | - $this->addJoinObject($join, $relationAlias); |
|
| 635 | - } else { |
|
| 636 | - $this->addJoinObject($join, 'Subscription'); |
|
| 637 | - } |
|
| 638 | - |
|
| 639 | - return $this; |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - /** |
|
| 643 | - * Use the Subscription relation Subscription object |
|
| 644 | - * |
|
| 645 | - * @see useQuery() |
|
| 646 | - * |
|
| 647 | - * @param string $relationAlias optional alias for the relation, |
|
| 648 | - * to be used as main alias in the secondary query |
|
| 649 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 650 | - * |
|
| 651 | - * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
| 652 | - */ |
|
| 653 | - public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 654 | - { |
|
| 655 | - return $this |
|
| 656 | - ->joinSubscription($relationAlias, $joinType) |
|
| 657 | - ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
| 658 | - } |
|
| 659 | - |
|
| 660 | - /** |
|
| 661 | - * Exclude object from result |
|
| 662 | - * |
|
| 663 | - * @param ChildInput $input Object to remove from the list of results |
|
| 664 | - * |
|
| 665 | - * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 666 | - */ |
|
| 667 | - public function prune($input = null) |
|
| 668 | - { |
|
| 669 | - if ($input) { |
|
| 670 | - $this->addUsingAlias(InputTableMap::COL_UUID, $input->getUuid(), Criteria::NOT_EQUAL); |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - return $this; |
|
| 674 | - } |
|
| 675 | - |
|
| 676 | - /** |
|
| 677 | - * Deletes all rows from the input table. |
|
| 678 | - * |
|
| 679 | - * @param ConnectionInterface $con the connection to use |
|
| 680 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
| 681 | - */ |
|
| 682 | - public function doDeleteAll(ConnectionInterface $con = null) |
|
| 683 | - { |
|
| 684 | - if (null === $con) { |
|
| 685 | - $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - // use transaction because $criteria could contain info |
|
| 689 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 690 | - return $con->transaction(function () use ($con) { |
|
| 691 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 692 | - $affectedRows += parent::doDeleteAll($con); |
|
| 693 | - // Because this db requires some delete cascade/set null emulation, we have to |
|
| 694 | - // clear the cached instance *after* the emulation has happened (since |
|
| 695 | - // instances get re-added by the select statement contained therein). |
|
| 696 | - InputTableMap::clearInstancePool(); |
|
| 697 | - InputTableMap::clearRelatedInstancePool(); |
|
| 698 | - |
|
| 699 | - return $affectedRows; |
|
| 700 | - }); |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - /** |
|
| 704 | - * Performs a DELETE on the database based on the current ModelCriteria |
|
| 705 | - * |
|
| 706 | - * @param ConnectionInterface $con the connection to use |
|
| 707 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
| 708 | - * if supported by native driver or if emulated using Propel. |
|
| 709 | - * @throws PropelException Any exceptions caught during processing will be |
|
| 710 | - * rethrown wrapped into a PropelException. |
|
| 711 | - */ |
|
| 712 | - public function delete(ConnectionInterface $con = null) |
|
| 713 | - { |
|
| 714 | - if (null === $con) { |
|
| 715 | - $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - $criteria = $this; |
|
| 719 | - |
|
| 720 | - // Set the correct dbName |
|
| 721 | - $criteria->setDbName(InputTableMap::DATABASE_NAME); |
|
| 722 | - |
|
| 723 | - // use transaction because $criteria could contain info |
|
| 724 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 725 | - return $con->transaction(function () use ($con, $criteria) { |
|
| 726 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 727 | - |
|
| 728 | - InputTableMap::removeInstanceFromPool($criteria); |
|
| 729 | - |
|
| 730 | - $affectedRows += ModelCriteria::delete($con); |
|
| 731 | - InputTableMap::clearRelatedInstancePool(); |
|
| 732 | - |
|
| 733 | - return $affectedRows; |
|
| 734 | - }); |
|
| 735 | - } |
|
| 103 | + protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Initializes internal state of \Jalle19\StatusManager\Database\Base\InputQuery object. |
|
| 107 | + * |
|
| 108 | + * @param string $dbName The database name |
|
| 109 | + * @param string $modelName The phpName of a model, e.g. 'Book' |
|
| 110 | + * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
| 111 | + */ |
|
| 112 | + public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Input', $modelAlias = null) |
|
| 113 | + { |
|
| 114 | + parent::__construct($dbName, $modelName, $modelAlias); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Returns a new ChildInputQuery object. |
|
| 119 | + * |
|
| 120 | + * @param string $modelAlias The alias of a model in the query |
|
| 121 | + * @param Criteria $criteria Optional Criteria to build the query from |
|
| 122 | + * |
|
| 123 | + * @return ChildInputQuery |
|
| 124 | + */ |
|
| 125 | + public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 126 | + { |
|
| 127 | + if ($criteria instanceof ChildInputQuery) { |
|
| 128 | + return $criteria; |
|
| 129 | + } |
|
| 130 | + $query = new ChildInputQuery(); |
|
| 131 | + if (null !== $modelAlias) { |
|
| 132 | + $query->setModelAlias($modelAlias); |
|
| 133 | + } |
|
| 134 | + if ($criteria instanceof Criteria) { |
|
| 135 | + $query->mergeWith($criteria); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $query; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Find object by primary key. |
|
| 143 | + * Propel uses the instance pool to skip the database if the object exists. |
|
| 144 | + * Go fast if the query is untouched. |
|
| 145 | + * |
|
| 146 | + * <code> |
|
| 147 | + * $obj = $c->findPk(12, $con); |
|
| 148 | + * </code> |
|
| 149 | + * |
|
| 150 | + * @param mixed $key Primary key to use for the query |
|
| 151 | + * @param ConnectionInterface $con an optional connection object |
|
| 152 | + * |
|
| 153 | + * @return ChildInput|array|mixed the result, formatted by the current formatter |
|
| 154 | + */ |
|
| 155 | + public function findPk($key, ConnectionInterface $con = null) |
|
| 156 | + { |
|
| 157 | + if ($key === null) { |
|
| 158 | + return null; |
|
| 159 | + } |
|
| 160 | + if ((null !== ($obj = InputTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
| 161 | + // the object is already in the instance pool |
|
| 162 | + return $obj; |
|
| 163 | + } |
|
| 164 | + if ($con === null) { |
|
| 165 | + $con = Propel::getServiceContainer()->getReadConnection(InputTableMap::DATABASE_NAME); |
|
| 166 | + } |
|
| 167 | + $this->basePreSelect($con); |
|
| 168 | + if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
| 169 | + || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
| 170 | + || $this->map || $this->having || $this->joins) { |
|
| 171 | + return $this->findPkComplex($key, $con); |
|
| 172 | + } else { |
|
| 173 | + return $this->findPkSimple($key, $con); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Find object by primary key using raw SQL to go fast. |
|
| 179 | + * Bypass doSelect() and the object formatter by using generated code. |
|
| 180 | + * |
|
| 181 | + * @param mixed $key Primary key to use for the query |
|
| 182 | + * @param ConnectionInterface $con A connection object |
|
| 183 | + * |
|
| 184 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 185 | + * |
|
| 186 | + * @return ChildInput A model object, or null if the key is not found |
|
| 187 | + */ |
|
| 188 | + protected function findPkSimple($key, ConnectionInterface $con) |
|
| 189 | + { |
|
| 190 | + $sql = 'SELECT uuid, instance_name, started, input, network, mux, weight FROM input WHERE uuid = :p0'; |
|
| 191 | + try { |
|
| 192 | + $stmt = $con->prepare($sql); |
|
| 193 | + $stmt->bindValue(':p0', $key, PDO::PARAM_STR); |
|
| 194 | + $stmt->execute(); |
|
| 195 | + } catch (Exception $e) { |
|
| 196 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 197 | + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
| 198 | + } |
|
| 199 | + $obj = null; |
|
| 200 | + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
| 201 | + /** @var ChildInput $obj */ |
|
| 202 | + $obj = new ChildInput(); |
|
| 203 | + $obj->hydrate($row); |
|
| 204 | + InputTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
| 205 | + } |
|
| 206 | + $stmt->closeCursor(); |
|
| 207 | + |
|
| 208 | + return $obj; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Find object by primary key. |
|
| 213 | + * |
|
| 214 | + * @param mixed $key Primary key to use for the query |
|
| 215 | + * @param ConnectionInterface $con A connection object |
|
| 216 | + * |
|
| 217 | + * @return ChildInput|array|mixed the result, formatted by the current formatter |
|
| 218 | + */ |
|
| 219 | + protected function findPkComplex($key, ConnectionInterface $con) |
|
| 220 | + { |
|
| 221 | + // As the query uses a PK condition, no limit(1) is necessary. |
|
| 222 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 223 | + $dataFetcher = $criteria |
|
| 224 | + ->filterByPrimaryKey($key) |
|
| 225 | + ->doSelect($con); |
|
| 226 | + |
|
| 227 | + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Find objects by primary key |
|
| 232 | + * <code> |
|
| 233 | + * $objs = $c->findPks(array(12, 56, 832), $con); |
|
| 234 | + * </code> |
|
| 235 | + * @param array $keys Primary keys to use for the query |
|
| 236 | + * @param ConnectionInterface $con an optional connection object |
|
| 237 | + * |
|
| 238 | + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
| 239 | + */ |
|
| 240 | + public function findPks($keys, ConnectionInterface $con = null) |
|
| 241 | + { |
|
| 242 | + if (null === $con) { |
|
| 243 | + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
| 244 | + } |
|
| 245 | + $this->basePreSelect($con); |
|
| 246 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 247 | + $dataFetcher = $criteria |
|
| 248 | + ->filterByPrimaryKeys($keys) |
|
| 249 | + ->doSelect($con); |
|
| 250 | + |
|
| 251 | + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Filter the query by primary key |
|
| 256 | + * |
|
| 257 | + * @param mixed $key Primary key to use for the query |
|
| 258 | + * |
|
| 259 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 260 | + */ |
|
| 261 | + public function filterByPrimaryKey($key) |
|
| 262 | + { |
|
| 263 | + |
|
| 264 | + return $this->addUsingAlias(InputTableMap::COL_UUID, $key, Criteria::EQUAL); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Filter the query by a list of primary keys |
|
| 269 | + * |
|
| 270 | + * @param array $keys The list of primary key to use for the query |
|
| 271 | + * |
|
| 272 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 273 | + */ |
|
| 274 | + public function filterByPrimaryKeys($keys) |
|
| 275 | + { |
|
| 276 | + |
|
| 277 | + return $this->addUsingAlias(InputTableMap::COL_UUID, $keys, Criteria::IN); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Filter the query on the uuid column |
|
| 282 | + * |
|
| 283 | + * Example usage: |
|
| 284 | + * <code> |
|
| 285 | + * $query->filterByUuid('fooValue'); // WHERE uuid = 'fooValue' |
|
| 286 | + * $query->filterByUuid('%fooValue%'); // WHERE uuid LIKE '%fooValue%' |
|
| 287 | + * </code> |
|
| 288 | + * |
|
| 289 | + * @param string $uuid The value to use as filter. |
|
| 290 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 291 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 292 | + * |
|
| 293 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 294 | + */ |
|
| 295 | + public function filterByUuid($uuid = null, $comparison = null) |
|
| 296 | + { |
|
| 297 | + if (null === $comparison) { |
|
| 298 | + if (is_array($uuid)) { |
|
| 299 | + $comparison = Criteria::IN; |
|
| 300 | + } elseif (preg_match('/[\%\*]/', $uuid)) { |
|
| 301 | + $uuid = str_replace('*', '%', $uuid); |
|
| 302 | + $comparison = Criteria::LIKE; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + return $this->addUsingAlias(InputTableMap::COL_UUID, $uuid, $comparison); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * Filter the query on the instance_name column |
|
| 311 | + * |
|
| 312 | + * Example usage: |
|
| 313 | + * <code> |
|
| 314 | + * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
| 315 | + * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
| 316 | + * </code> |
|
| 317 | + * |
|
| 318 | + * @param string $instanceName The value to use as filter. |
|
| 319 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 320 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 321 | + * |
|
| 322 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 323 | + */ |
|
| 324 | + public function filterByInstanceName($instanceName = null, $comparison = null) |
|
| 325 | + { |
|
| 326 | + if (null === $comparison) { |
|
| 327 | + if (is_array($instanceName)) { |
|
| 328 | + $comparison = Criteria::IN; |
|
| 329 | + } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
| 330 | + $instanceName = str_replace('*', '%', $instanceName); |
|
| 331 | + $comparison = Criteria::LIKE; |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + return $this->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * Filter the query on the started column |
|
| 340 | + * |
|
| 341 | + * Example usage: |
|
| 342 | + * <code> |
|
| 343 | + * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
|
| 344 | + * $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
|
| 345 | + * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
|
| 346 | + * </code> |
|
| 347 | + * |
|
| 348 | + * @param mixed $started The value to use as filter. |
|
| 349 | + * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
| 350 | + * Empty strings are treated as NULL. |
|
| 351 | + * Use scalar values for equality. |
|
| 352 | + * Use array values for in_array() equivalent. |
|
| 353 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 354 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 355 | + * |
|
| 356 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 357 | + */ |
|
| 358 | + public function filterByStarted($started = null, $comparison = null) |
|
| 359 | + { |
|
| 360 | + if (is_array($started)) { |
|
| 361 | + $useMinMax = false; |
|
| 362 | + if (isset($started['min'])) { |
|
| 363 | + $this->addUsingAlias(InputTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
|
| 364 | + $useMinMax = true; |
|
| 365 | + } |
|
| 366 | + if (isset($started['max'])) { |
|
| 367 | + $this->addUsingAlias(InputTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
|
| 368 | + $useMinMax = true; |
|
| 369 | + } |
|
| 370 | + if ($useMinMax) { |
|
| 371 | + return $this; |
|
| 372 | + } |
|
| 373 | + if (null === $comparison) { |
|
| 374 | + $comparison = Criteria::IN; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + return $this->addUsingAlias(InputTableMap::COL_STARTED, $started, $comparison); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + /** |
|
| 382 | + * Filter the query on the input column |
|
| 383 | + * |
|
| 384 | + * Example usage: |
|
| 385 | + * <code> |
|
| 386 | + * $query->filterByInput('fooValue'); // WHERE input = 'fooValue' |
|
| 387 | + * $query->filterByInput('%fooValue%'); // WHERE input LIKE '%fooValue%' |
|
| 388 | + * </code> |
|
| 389 | + * |
|
| 390 | + * @param string $input The value to use as filter. |
|
| 391 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 392 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 393 | + * |
|
| 394 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 395 | + */ |
|
| 396 | + public function filterByInput($input = null, $comparison = null) |
|
| 397 | + { |
|
| 398 | + if (null === $comparison) { |
|
| 399 | + if (is_array($input)) { |
|
| 400 | + $comparison = Criteria::IN; |
|
| 401 | + } elseif (preg_match('/[\%\*]/', $input)) { |
|
| 402 | + $input = str_replace('*', '%', $input); |
|
| 403 | + $comparison = Criteria::LIKE; |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + return $this->addUsingAlias(InputTableMap::COL_INPUT, $input, $comparison); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + /** |
|
| 411 | + * Filter the query on the network column |
|
| 412 | + * |
|
| 413 | + * Example usage: |
|
| 414 | + * <code> |
|
| 415 | + * $query->filterByNetwork('fooValue'); // WHERE network = 'fooValue' |
|
| 416 | + * $query->filterByNetwork('%fooValue%'); // WHERE network LIKE '%fooValue%' |
|
| 417 | + * </code> |
|
| 418 | + * |
|
| 419 | + * @param string $network The value to use as filter. |
|
| 420 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 421 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 422 | + * |
|
| 423 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 424 | + */ |
|
| 425 | + public function filterByNetwork($network = null, $comparison = null) |
|
| 426 | + { |
|
| 427 | + if (null === $comparison) { |
|
| 428 | + if (is_array($network)) { |
|
| 429 | + $comparison = Criteria::IN; |
|
| 430 | + } elseif (preg_match('/[\%\*]/', $network)) { |
|
| 431 | + $network = str_replace('*', '%', $network); |
|
| 432 | + $comparison = Criteria::LIKE; |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + return $this->addUsingAlias(InputTableMap::COL_NETWORK, $network, $comparison); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + /** |
|
| 440 | + * Filter the query on the mux column |
|
| 441 | + * |
|
| 442 | + * Example usage: |
|
| 443 | + * <code> |
|
| 444 | + * $query->filterByMux('fooValue'); // WHERE mux = 'fooValue' |
|
| 445 | + * $query->filterByMux('%fooValue%'); // WHERE mux LIKE '%fooValue%' |
|
| 446 | + * </code> |
|
| 447 | + * |
|
| 448 | + * @param string $mux The value to use as filter. |
|
| 449 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 450 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 451 | + * |
|
| 452 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 453 | + */ |
|
| 454 | + public function filterByMux($mux = null, $comparison = null) |
|
| 455 | + { |
|
| 456 | + if (null === $comparison) { |
|
| 457 | + if (is_array($mux)) { |
|
| 458 | + $comparison = Criteria::IN; |
|
| 459 | + } elseif (preg_match('/[\%\*]/', $mux)) { |
|
| 460 | + $mux = str_replace('*', '%', $mux); |
|
| 461 | + $comparison = Criteria::LIKE; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + return $this->addUsingAlias(InputTableMap::COL_MUX, $mux, $comparison); |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + /** |
|
| 469 | + * Filter the query on the weight column |
|
| 470 | + * |
|
| 471 | + * Example usage: |
|
| 472 | + * <code> |
|
| 473 | + * $query->filterByWeight(1234); // WHERE weight = 1234 |
|
| 474 | + * $query->filterByWeight(array(12, 34)); // WHERE weight IN (12, 34) |
|
| 475 | + * $query->filterByWeight(array('min' => 12)); // WHERE weight > 12 |
|
| 476 | + * </code> |
|
| 477 | + * |
|
| 478 | + * @param mixed $weight The value to use as filter. |
|
| 479 | + * Use scalar values for equality. |
|
| 480 | + * Use array values for in_array() equivalent. |
|
| 481 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 482 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 483 | + * |
|
| 484 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 485 | + */ |
|
| 486 | + public function filterByWeight($weight = null, $comparison = null) |
|
| 487 | + { |
|
| 488 | + if (is_array($weight)) { |
|
| 489 | + $useMinMax = false; |
|
| 490 | + if (isset($weight['min'])) { |
|
| 491 | + $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight['min'], Criteria::GREATER_EQUAL); |
|
| 492 | + $useMinMax = true; |
|
| 493 | + } |
|
| 494 | + if (isset($weight['max'])) { |
|
| 495 | + $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight['max'], Criteria::LESS_EQUAL); |
|
| 496 | + $useMinMax = true; |
|
| 497 | + } |
|
| 498 | + if ($useMinMax) { |
|
| 499 | + return $this; |
|
| 500 | + } |
|
| 501 | + if (null === $comparison) { |
|
| 502 | + $comparison = Criteria::IN; |
|
| 503 | + } |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + return $this->addUsingAlias(InputTableMap::COL_WEIGHT, $weight, $comparison); |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
| 511 | + * |
|
| 512 | + * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
| 513 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 514 | + * |
|
| 515 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 516 | + * |
|
| 517 | + * @return ChildInputQuery The current query, for fluid interface |
|
| 518 | + */ |
|
| 519 | + public function filterByInstance($instance, $comparison = null) |
|
| 520 | + { |
|
| 521 | + if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
| 522 | + return $this |
|
| 523 | + ->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
| 524 | + } elseif ($instance instanceof ObjectCollection) { |
|
| 525 | + if (null === $comparison) { |
|
| 526 | + $comparison = Criteria::IN; |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + return $this |
|
| 530 | + ->addUsingAlias(InputTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
| 531 | + } else { |
|
| 532 | + throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * Adds a JOIN clause to the query using the Instance relation |
|
| 538 | + * |
|
| 539 | + * @param string $relationAlias optional alias for the relation |
|
| 540 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 541 | + * |
|
| 542 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 543 | + */ |
|
| 544 | + public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 545 | + { |
|
| 546 | + $tableMap = $this->getTableMap(); |
|
| 547 | + $relationMap = $tableMap->getRelation('Instance'); |
|
| 548 | + |
|
| 549 | + // create a ModelJoin object for this join |
|
| 550 | + $join = new ModelJoin(); |
|
| 551 | + $join->setJoinType($joinType); |
|
| 552 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 553 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 554 | + $join->setPreviousJoin($previousJoin); |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + // add the ModelJoin to the current object |
|
| 558 | + if ($relationAlias) { |
|
| 559 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 560 | + $this->addJoinObject($join, $relationAlias); |
|
| 561 | + } else { |
|
| 562 | + $this->addJoinObject($join, 'Instance'); |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + return $this; |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + /** |
|
| 569 | + * Use the Instance relation Instance object |
|
| 570 | + * |
|
| 571 | + * @see useQuery() |
|
| 572 | + * |
|
| 573 | + * @param string $relationAlias optional alias for the relation, |
|
| 574 | + * to be used as main alias in the secondary query |
|
| 575 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 576 | + * |
|
| 577 | + * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
| 578 | + */ |
|
| 579 | + public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 580 | + { |
|
| 581 | + return $this |
|
| 582 | + ->joinInstance($relationAlias, $joinType) |
|
| 583 | + ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + /** |
|
| 587 | + * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
| 588 | + * |
|
| 589 | + * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
| 590 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 591 | + * |
|
| 592 | + * @return ChildInputQuery The current query, for fluid interface |
|
| 593 | + */ |
|
| 594 | + public function filterBySubscription($subscription, $comparison = null) |
|
| 595 | + { |
|
| 596 | + if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
| 597 | + return $this |
|
| 598 | + ->addUsingAlias(InputTableMap::COL_UUID, $subscription->getInputUuid(), $comparison); |
|
| 599 | + } elseif ($subscription instanceof ObjectCollection) { |
|
| 600 | + return $this |
|
| 601 | + ->useSubscriptionQuery() |
|
| 602 | + ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
| 603 | + ->endUse(); |
|
| 604 | + } else { |
|
| 605 | + throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
| 606 | + } |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * Adds a JOIN clause to the query using the Subscription relation |
|
| 611 | + * |
|
| 612 | + * @param string $relationAlias optional alias for the relation |
|
| 613 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 614 | + * |
|
| 615 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 616 | + */ |
|
| 617 | + public function joinSubscription($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 618 | + { |
|
| 619 | + $tableMap = $this->getTableMap(); |
|
| 620 | + $relationMap = $tableMap->getRelation('Subscription'); |
|
| 621 | + |
|
| 622 | + // create a ModelJoin object for this join |
|
| 623 | + $join = new ModelJoin(); |
|
| 624 | + $join->setJoinType($joinType); |
|
| 625 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 626 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 627 | + $join->setPreviousJoin($previousJoin); |
|
| 628 | + } |
|
| 629 | + |
|
| 630 | + // add the ModelJoin to the current object |
|
| 631 | + if ($relationAlias) { |
|
| 632 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 633 | + $this->addJoinObject($join, $relationAlias); |
|
| 634 | + } else { |
|
| 635 | + $this->addJoinObject($join, 'Subscription'); |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + return $this; |
|
| 639 | + } |
|
| 640 | + |
|
| 641 | + /** |
|
| 642 | + * Use the Subscription relation Subscription object |
|
| 643 | + * |
|
| 644 | + * @see useQuery() |
|
| 645 | + * |
|
| 646 | + * @param string $relationAlias optional alias for the relation, |
|
| 647 | + * to be used as main alias in the secondary query |
|
| 648 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 649 | + * |
|
| 650 | + * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
| 651 | + */ |
|
| 652 | + public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 653 | + { |
|
| 654 | + return $this |
|
| 655 | + ->joinSubscription($relationAlias, $joinType) |
|
| 656 | + ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
| 657 | + } |
|
| 658 | + |
|
| 659 | + /** |
|
| 660 | + * Exclude object from result |
|
| 661 | + * |
|
| 662 | + * @param ChildInput $input Object to remove from the list of results |
|
| 663 | + * |
|
| 664 | + * @return $this|ChildInputQuery The current query, for fluid interface |
|
| 665 | + */ |
|
| 666 | + public function prune($input = null) |
|
| 667 | + { |
|
| 668 | + if ($input) { |
|
| 669 | + $this->addUsingAlias(InputTableMap::COL_UUID, $input->getUuid(), Criteria::NOT_EQUAL); |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + return $this; |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + /** |
|
| 676 | + * Deletes all rows from the input table. |
|
| 677 | + * |
|
| 678 | + * @param ConnectionInterface $con the connection to use |
|
| 679 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
| 680 | + */ |
|
| 681 | + public function doDeleteAll(ConnectionInterface $con = null) |
|
| 682 | + { |
|
| 683 | + if (null === $con) { |
|
| 684 | + $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + // use transaction because $criteria could contain info |
|
| 688 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 689 | + return $con->transaction(function () use ($con) { |
|
| 690 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 691 | + $affectedRows += parent::doDeleteAll($con); |
|
| 692 | + // Because this db requires some delete cascade/set null emulation, we have to |
|
| 693 | + // clear the cached instance *after* the emulation has happened (since |
|
| 694 | + // instances get re-added by the select statement contained therein). |
|
| 695 | + InputTableMap::clearInstancePool(); |
|
| 696 | + InputTableMap::clearRelatedInstancePool(); |
|
| 697 | + |
|
| 698 | + return $affectedRows; |
|
| 699 | + }); |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + /** |
|
| 703 | + * Performs a DELETE on the database based on the current ModelCriteria |
|
| 704 | + * |
|
| 705 | + * @param ConnectionInterface $con the connection to use |
|
| 706 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
| 707 | + * if supported by native driver or if emulated using Propel. |
|
| 708 | + * @throws PropelException Any exceptions caught during processing will be |
|
| 709 | + * rethrown wrapped into a PropelException. |
|
| 710 | + */ |
|
| 711 | + public function delete(ConnectionInterface $con = null) |
|
| 712 | + { |
|
| 713 | + if (null === $con) { |
|
| 714 | + $con = Propel::getServiceContainer()->getWriteConnection(InputTableMap::DATABASE_NAME); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + $criteria = $this; |
|
| 718 | + |
|
| 719 | + // Set the correct dbName |
|
| 720 | + $criteria->setDbName(InputTableMap::DATABASE_NAME); |
|
| 721 | + |
|
| 722 | + // use transaction because $criteria could contain info |
|
| 723 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 724 | + return $con->transaction(function () use ($con, $criteria) { |
|
| 725 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 726 | + |
|
| 727 | + InputTableMap::removeInstanceFromPool($criteria); |
|
| 728 | + |
|
| 729 | + $affectedRows += ModelCriteria::delete($con); |
|
| 730 | + InputTableMap::clearRelatedInstancePool(); |
|
| 731 | + |
|
| 732 | + return $affectedRows; |
|
| 733 | + }); |
|
| 734 | + } |
|
| 736 | 735 | |
| 737 | 736 | } // InputQuery |
@@ -44,2591 +44,2591 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | abstract class Instance implements ActiveRecordInterface |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * TableMap class name |
|
| 49 | - */ |
|
| 50 | - const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\InstanceTableMap'; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * attribute to determine if this object has previously been saved. |
|
| 55 | - * @var boolean |
|
| 56 | - */ |
|
| 57 | - protected $new = true; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * attribute to determine whether this object has been deleted. |
|
| 61 | - * @var boolean |
|
| 62 | - */ |
|
| 63 | - protected $deleted = false; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * The columns that have been modified in current object. |
|
| 67 | - * Tracking modified columns allows us to only update modified columns. |
|
| 68 | - * @var array |
|
| 69 | - */ |
|
| 70 | - protected $modifiedColumns = array(); |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * The (virtual) columns that are added at runtime |
|
| 74 | - * The formatters can add supplementary columns based on a resultset |
|
| 75 | - * @var array |
|
| 76 | - */ |
|
| 77 | - protected $virtualColumns = array(); |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * The value for the name field. |
|
| 81 | - * |
|
| 82 | - * @var string |
|
| 83 | - */ |
|
| 84 | - protected $name; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @var ObjectCollection|ChildUser[] Collection to store aggregation of ChildUser objects. |
|
| 88 | - */ |
|
| 89 | - protected $collUsers; |
|
| 90 | - protected $collUsersPartial; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @var ObjectCollection|ChildConnection[] Collection to store aggregation of ChildConnection objects. |
|
| 94 | - */ |
|
| 95 | - protected $collConnections; |
|
| 96 | - protected $collConnectionsPartial; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @var ObjectCollection|ChildInput[] Collection to store aggregation of ChildInput objects. |
|
| 100 | - */ |
|
| 101 | - protected $collInputs; |
|
| 102 | - protected $collInputsPartial; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @var ObjectCollection|ChildChannel[] Collection to store aggregation of ChildChannel objects. |
|
| 106 | - */ |
|
| 107 | - protected $collChannels; |
|
| 108 | - protected $collChannelsPartial; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 112 | - */ |
|
| 113 | - protected $collSubscriptions; |
|
| 114 | - protected $collSubscriptionsPartial; |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * Flag to prevent endless save loop, if this object is referenced |
|
| 118 | - * by another object which falls in this transaction. |
|
| 119 | - * |
|
| 120 | - * @var boolean |
|
| 121 | - */ |
|
| 122 | - protected $alreadyInSave = false; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * An array of objects scheduled for deletion. |
|
| 126 | - * @var ObjectCollection|ChildUser[] |
|
| 127 | - */ |
|
| 128 | - protected $usersScheduledForDeletion = null; |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * An array of objects scheduled for deletion. |
|
| 132 | - * @var ObjectCollection|ChildConnection[] |
|
| 133 | - */ |
|
| 134 | - protected $connectionsScheduledForDeletion = null; |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * An array of objects scheduled for deletion. |
|
| 138 | - * @var ObjectCollection|ChildInput[] |
|
| 139 | - */ |
|
| 140 | - protected $inputsScheduledForDeletion = null; |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * An array of objects scheduled for deletion. |
|
| 144 | - * @var ObjectCollection|ChildChannel[] |
|
| 145 | - */ |
|
| 146 | - protected $channelsScheduledForDeletion = null; |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * An array of objects scheduled for deletion. |
|
| 150 | - * @var ObjectCollection|ChildSubscription[] |
|
| 151 | - */ |
|
| 152 | - protected $subscriptionsScheduledForDeletion = null; |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Initializes internal state of Jalle19\StatusManager\Database\Base\Instance object. |
|
| 156 | - */ |
|
| 157 | - public function __construct() |
|
| 158 | - { |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * Returns whether the object has been modified. |
|
| 163 | - * |
|
| 164 | - * @return boolean True if the object has been modified. |
|
| 165 | - */ |
|
| 166 | - public function isModified() |
|
| 167 | - { |
|
| 168 | - return !!$this->modifiedColumns; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - /** |
|
| 172 | - * Has specified column been modified? |
|
| 173 | - * |
|
| 174 | - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 175 | - * @return boolean True if $col has been modified. |
|
| 176 | - */ |
|
| 177 | - public function isColumnModified($col) |
|
| 178 | - { |
|
| 179 | - return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - /** |
|
| 183 | - * Get the columns that have been modified in this object. |
|
| 184 | - * @return array A unique list of the modified column names for this object. |
|
| 185 | - */ |
|
| 186 | - public function getModifiedColumns() |
|
| 187 | - { |
|
| 188 | - return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Returns whether the object has ever been saved. This will |
|
| 193 | - * be false, if the object was retrieved from storage or was created |
|
| 194 | - * and then saved. |
|
| 195 | - * |
|
| 196 | - * @return boolean true, if the object has never been persisted. |
|
| 197 | - */ |
|
| 198 | - public function isNew() |
|
| 199 | - { |
|
| 200 | - return $this->new; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Setter for the isNew attribute. This method will be called |
|
| 205 | - * by Propel-generated children and objects. |
|
| 206 | - * |
|
| 207 | - * @param boolean $b the state of the object. |
|
| 208 | - */ |
|
| 209 | - public function setNew($b) |
|
| 210 | - { |
|
| 211 | - $this->new = (boolean) $b; |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * Whether this object has been deleted. |
|
| 216 | - * @return boolean The deleted state of this object. |
|
| 217 | - */ |
|
| 218 | - public function isDeleted() |
|
| 219 | - { |
|
| 220 | - return $this->deleted; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * Specify whether this object has been deleted. |
|
| 225 | - * @param boolean $b The deleted state of this object. |
|
| 226 | - * @return void |
|
| 227 | - */ |
|
| 228 | - public function setDeleted($b) |
|
| 229 | - { |
|
| 230 | - $this->deleted = (boolean) $b; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - /** |
|
| 234 | - * Sets the modified state for the object to be false. |
|
| 235 | - * @param string $col If supplied, only the specified column is reset. |
|
| 236 | - * @return void |
|
| 237 | - */ |
|
| 238 | - public function resetModified($col = null) |
|
| 239 | - { |
|
| 240 | - if (null !== $col) { |
|
| 241 | - if (isset($this->modifiedColumns[$col])) { |
|
| 242 | - unset($this->modifiedColumns[$col]); |
|
| 243 | - } |
|
| 244 | - } else { |
|
| 245 | - $this->modifiedColumns = array(); |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * Compares this with another <code>Instance</code> instance. If |
|
| 251 | - * <code>obj</code> is an instance of <code>Instance</code>, delegates to |
|
| 252 | - * <code>equals(Instance)</code>. Otherwise, returns <code>false</code>. |
|
| 253 | - * |
|
| 254 | - * @param mixed $obj The object to compare to. |
|
| 255 | - * @return boolean Whether equal to the object specified. |
|
| 256 | - */ |
|
| 257 | - public function equals($obj) |
|
| 258 | - { |
|
| 259 | - if (!$obj instanceof static) { |
|
| 260 | - return false; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - if ($this === $obj) { |
|
| 264 | - return true; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 268 | - return false; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * Get the associative array of the virtual columns in this object |
|
| 276 | - * |
|
| 277 | - * @return array |
|
| 278 | - */ |
|
| 279 | - public function getVirtualColumns() |
|
| 280 | - { |
|
| 281 | - return $this->virtualColumns; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Checks the existence of a virtual column in this object |
|
| 286 | - * |
|
| 287 | - * @param string $name The virtual column name |
|
| 288 | - * @return boolean |
|
| 289 | - */ |
|
| 290 | - public function hasVirtualColumn($name) |
|
| 291 | - { |
|
| 292 | - return array_key_exists($name, $this->virtualColumns); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * Get the value of a virtual column in this object |
|
| 297 | - * |
|
| 298 | - * @param string $name The virtual column name |
|
| 299 | - * @return mixed |
|
| 300 | - * |
|
| 301 | - * @throws PropelException |
|
| 302 | - */ |
|
| 303 | - public function getVirtualColumn($name) |
|
| 304 | - { |
|
| 305 | - if (!$this->hasVirtualColumn($name)) { |
|
| 306 | - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - return $this->virtualColumns[$name]; |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Set the value of a virtual column in this object |
|
| 314 | - * |
|
| 315 | - * @param string $name The virtual column name |
|
| 316 | - * @param mixed $value The value to give to the virtual column |
|
| 317 | - * |
|
| 318 | - * @return $this|Instance The current object, for fluid interface |
|
| 319 | - */ |
|
| 320 | - public function setVirtualColumn($name, $value) |
|
| 321 | - { |
|
| 322 | - $this->virtualColumns[$name] = $value; |
|
| 323 | - |
|
| 324 | - return $this; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - /** |
|
| 328 | - * Logs a message using Propel::log(). |
|
| 329 | - * |
|
| 330 | - * @param string $msg |
|
| 331 | - * @param int $priority One of the Propel::LOG_* logging levels |
|
| 332 | - * @return boolean |
|
| 333 | - */ |
|
| 334 | - protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 335 | - { |
|
| 336 | - return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * Export the current object properties to a string, using a given parser format |
|
| 341 | - * <code> |
|
| 342 | - * $book = BookQuery::create()->findPk(9012); |
|
| 343 | - * echo $book->exportTo('JSON'); |
|
| 344 | - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 345 | - * </code> |
|
| 346 | - * |
|
| 347 | - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 348 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 349 | - * @return string The exported data |
|
| 350 | - */ |
|
| 351 | - public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 352 | - { |
|
| 353 | - if (!$parser instanceof AbstractParser) { |
|
| 354 | - $parser = AbstractParser::getParser($parser); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - /** |
|
| 361 | - * Clean up internal collections prior to serializing |
|
| 362 | - * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 363 | - */ |
|
| 364 | - public function __sleep() |
|
| 365 | - { |
|
| 366 | - $this->clearAllReferences(); |
|
| 367 | - |
|
| 368 | - $cls = new \ReflectionClass($this); |
|
| 369 | - $propertyNames = []; |
|
| 370 | - $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 371 | - |
|
| 372 | - foreach($serializableProperties as $property) { |
|
| 373 | - $propertyNames[] = $property->getName(); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $propertyNames; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - /** |
|
| 380 | - * Get the [name] column value. |
|
| 381 | - * |
|
| 382 | - * @return string |
|
| 383 | - */ |
|
| 384 | - public function getName() |
|
| 385 | - { |
|
| 386 | - return $this->name; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Set the value of [name] column. |
|
| 391 | - * |
|
| 392 | - * @param string $v new value |
|
| 393 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 394 | - */ |
|
| 395 | - public function setName($v) |
|
| 396 | - { |
|
| 397 | - if ($v !== null) { |
|
| 398 | - $v = (string) $v; |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - if ($this->name !== $v) { |
|
| 402 | - $this->name = $v; |
|
| 403 | - $this->modifiedColumns[InstanceTableMap::COL_NAME] = true; |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $this; |
|
| 407 | - } // setName() |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * Indicates whether the columns in this object are only set to default values. |
|
| 411 | - * |
|
| 412 | - * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 413 | - * modified _and_ has some values set which are non-default. |
|
| 414 | - * |
|
| 415 | - * @return boolean Whether the columns in this object are only been set with default values. |
|
| 416 | - */ |
|
| 417 | - public function hasOnlyDefaultValues() |
|
| 418 | - { |
|
| 419 | - // otherwise, everything was equal, so return TRUE |
|
| 420 | - return true; |
|
| 421 | - } // hasOnlyDefaultValues() |
|
| 422 | - |
|
| 423 | - /** |
|
| 424 | - * Hydrates (populates) the object variables with values from the database resultset. |
|
| 425 | - * |
|
| 426 | - * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 427 | - * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 428 | - * for results of JOIN queries where the resultset row includes columns from two or |
|
| 429 | - * more tables. |
|
| 430 | - * |
|
| 431 | - * @param array $row The row returned by DataFetcher->fetch(). |
|
| 432 | - * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 433 | - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 434 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 47 | + /** |
|
| 48 | + * TableMap class name |
|
| 49 | + */ |
|
| 50 | + const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\InstanceTableMap'; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * attribute to determine if this object has previously been saved. |
|
| 55 | + * @var boolean |
|
| 56 | + */ |
|
| 57 | + protected $new = true; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * attribute to determine whether this object has been deleted. |
|
| 61 | + * @var boolean |
|
| 62 | + */ |
|
| 63 | + protected $deleted = false; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * The columns that have been modified in current object. |
|
| 67 | + * Tracking modified columns allows us to only update modified columns. |
|
| 68 | + * @var array |
|
| 69 | + */ |
|
| 70 | + protected $modifiedColumns = array(); |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * The (virtual) columns that are added at runtime |
|
| 74 | + * The formatters can add supplementary columns based on a resultset |
|
| 75 | + * @var array |
|
| 76 | + */ |
|
| 77 | + protected $virtualColumns = array(); |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * The value for the name field. |
|
| 81 | + * |
|
| 82 | + * @var string |
|
| 83 | + */ |
|
| 84 | + protected $name; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @var ObjectCollection|ChildUser[] Collection to store aggregation of ChildUser objects. |
|
| 88 | + */ |
|
| 89 | + protected $collUsers; |
|
| 90 | + protected $collUsersPartial; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @var ObjectCollection|ChildConnection[] Collection to store aggregation of ChildConnection objects. |
|
| 94 | + */ |
|
| 95 | + protected $collConnections; |
|
| 96 | + protected $collConnectionsPartial; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @var ObjectCollection|ChildInput[] Collection to store aggregation of ChildInput objects. |
|
| 100 | + */ |
|
| 101 | + protected $collInputs; |
|
| 102 | + protected $collInputsPartial; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @var ObjectCollection|ChildChannel[] Collection to store aggregation of ChildChannel objects. |
|
| 106 | + */ |
|
| 107 | + protected $collChannels; |
|
| 108 | + protected $collChannelsPartial; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 112 | + */ |
|
| 113 | + protected $collSubscriptions; |
|
| 114 | + protected $collSubscriptionsPartial; |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * Flag to prevent endless save loop, if this object is referenced |
|
| 118 | + * by another object which falls in this transaction. |
|
| 119 | + * |
|
| 120 | + * @var boolean |
|
| 121 | + */ |
|
| 122 | + protected $alreadyInSave = false; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * An array of objects scheduled for deletion. |
|
| 126 | + * @var ObjectCollection|ChildUser[] |
|
| 127 | + */ |
|
| 128 | + protected $usersScheduledForDeletion = null; |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * An array of objects scheduled for deletion. |
|
| 132 | + * @var ObjectCollection|ChildConnection[] |
|
| 133 | + */ |
|
| 134 | + protected $connectionsScheduledForDeletion = null; |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * An array of objects scheduled for deletion. |
|
| 138 | + * @var ObjectCollection|ChildInput[] |
|
| 139 | + */ |
|
| 140 | + protected $inputsScheduledForDeletion = null; |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * An array of objects scheduled for deletion. |
|
| 144 | + * @var ObjectCollection|ChildChannel[] |
|
| 145 | + */ |
|
| 146 | + protected $channelsScheduledForDeletion = null; |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * An array of objects scheduled for deletion. |
|
| 150 | + * @var ObjectCollection|ChildSubscription[] |
|
| 151 | + */ |
|
| 152 | + protected $subscriptionsScheduledForDeletion = null; |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Initializes internal state of Jalle19\StatusManager\Database\Base\Instance object. |
|
| 156 | + */ |
|
| 157 | + public function __construct() |
|
| 158 | + { |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * Returns whether the object has been modified. |
|
| 163 | + * |
|
| 164 | + * @return boolean True if the object has been modified. |
|
| 165 | + */ |
|
| 166 | + public function isModified() |
|
| 167 | + { |
|
| 168 | + return !!$this->modifiedColumns; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + /** |
|
| 172 | + * Has specified column been modified? |
|
| 173 | + * |
|
| 174 | + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 175 | + * @return boolean True if $col has been modified. |
|
| 176 | + */ |
|
| 177 | + public function isColumnModified($col) |
|
| 178 | + { |
|
| 179 | + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + /** |
|
| 183 | + * Get the columns that have been modified in this object. |
|
| 184 | + * @return array A unique list of the modified column names for this object. |
|
| 185 | + */ |
|
| 186 | + public function getModifiedColumns() |
|
| 187 | + { |
|
| 188 | + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Returns whether the object has ever been saved. This will |
|
| 193 | + * be false, if the object was retrieved from storage or was created |
|
| 194 | + * and then saved. |
|
| 195 | + * |
|
| 196 | + * @return boolean true, if the object has never been persisted. |
|
| 197 | + */ |
|
| 198 | + public function isNew() |
|
| 199 | + { |
|
| 200 | + return $this->new; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Setter for the isNew attribute. This method will be called |
|
| 205 | + * by Propel-generated children and objects. |
|
| 206 | + * |
|
| 207 | + * @param boolean $b the state of the object. |
|
| 208 | + */ |
|
| 209 | + public function setNew($b) |
|
| 210 | + { |
|
| 211 | + $this->new = (boolean) $b; |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * Whether this object has been deleted. |
|
| 216 | + * @return boolean The deleted state of this object. |
|
| 217 | + */ |
|
| 218 | + public function isDeleted() |
|
| 219 | + { |
|
| 220 | + return $this->deleted; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * Specify whether this object has been deleted. |
|
| 225 | + * @param boolean $b The deleted state of this object. |
|
| 226 | + * @return void |
|
| 227 | + */ |
|
| 228 | + public function setDeleted($b) |
|
| 229 | + { |
|
| 230 | + $this->deleted = (boolean) $b; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + /** |
|
| 234 | + * Sets the modified state for the object to be false. |
|
| 235 | + * @param string $col If supplied, only the specified column is reset. |
|
| 236 | + * @return void |
|
| 237 | + */ |
|
| 238 | + public function resetModified($col = null) |
|
| 239 | + { |
|
| 240 | + if (null !== $col) { |
|
| 241 | + if (isset($this->modifiedColumns[$col])) { |
|
| 242 | + unset($this->modifiedColumns[$col]); |
|
| 243 | + } |
|
| 244 | + } else { |
|
| 245 | + $this->modifiedColumns = array(); |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Compares this with another <code>Instance</code> instance. If |
|
| 251 | + * <code>obj</code> is an instance of <code>Instance</code>, delegates to |
|
| 252 | + * <code>equals(Instance)</code>. Otherwise, returns <code>false</code>. |
|
| 253 | + * |
|
| 254 | + * @param mixed $obj The object to compare to. |
|
| 255 | + * @return boolean Whether equal to the object specified. |
|
| 256 | + */ |
|
| 257 | + public function equals($obj) |
|
| 258 | + { |
|
| 259 | + if (!$obj instanceof static) { |
|
| 260 | + return false; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + if ($this === $obj) { |
|
| 264 | + return true; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 268 | + return false; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * Get the associative array of the virtual columns in this object |
|
| 276 | + * |
|
| 277 | + * @return array |
|
| 278 | + */ |
|
| 279 | + public function getVirtualColumns() |
|
| 280 | + { |
|
| 281 | + return $this->virtualColumns; |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Checks the existence of a virtual column in this object |
|
| 286 | + * |
|
| 287 | + * @param string $name The virtual column name |
|
| 288 | + * @return boolean |
|
| 289 | + */ |
|
| 290 | + public function hasVirtualColumn($name) |
|
| 291 | + { |
|
| 292 | + return array_key_exists($name, $this->virtualColumns); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * Get the value of a virtual column in this object |
|
| 297 | + * |
|
| 298 | + * @param string $name The virtual column name |
|
| 299 | + * @return mixed |
|
| 300 | + * |
|
| 301 | + * @throws PropelException |
|
| 302 | + */ |
|
| 303 | + public function getVirtualColumn($name) |
|
| 304 | + { |
|
| 305 | + if (!$this->hasVirtualColumn($name)) { |
|
| 306 | + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + return $this->virtualColumns[$name]; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Set the value of a virtual column in this object |
|
| 314 | + * |
|
| 315 | + * @param string $name The virtual column name |
|
| 316 | + * @param mixed $value The value to give to the virtual column |
|
| 317 | + * |
|
| 318 | + * @return $this|Instance The current object, for fluid interface |
|
| 319 | + */ |
|
| 320 | + public function setVirtualColumn($name, $value) |
|
| 321 | + { |
|
| 322 | + $this->virtualColumns[$name] = $value; |
|
| 323 | + |
|
| 324 | + return $this; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + /** |
|
| 328 | + * Logs a message using Propel::log(). |
|
| 329 | + * |
|
| 330 | + * @param string $msg |
|
| 331 | + * @param int $priority One of the Propel::LOG_* logging levels |
|
| 332 | + * @return boolean |
|
| 333 | + */ |
|
| 334 | + protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 335 | + { |
|
| 336 | + return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * Export the current object properties to a string, using a given parser format |
|
| 341 | + * <code> |
|
| 342 | + * $book = BookQuery::create()->findPk(9012); |
|
| 343 | + * echo $book->exportTo('JSON'); |
|
| 344 | + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 345 | + * </code> |
|
| 346 | + * |
|
| 347 | + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 348 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 349 | + * @return string The exported data |
|
| 350 | + */ |
|
| 351 | + public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 352 | + { |
|
| 353 | + if (!$parser instanceof AbstractParser) { |
|
| 354 | + $parser = AbstractParser::getParser($parser); |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + /** |
|
| 361 | + * Clean up internal collections prior to serializing |
|
| 362 | + * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 363 | + */ |
|
| 364 | + public function __sleep() |
|
| 365 | + { |
|
| 366 | + $this->clearAllReferences(); |
|
| 367 | + |
|
| 368 | + $cls = new \ReflectionClass($this); |
|
| 369 | + $propertyNames = []; |
|
| 370 | + $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 371 | + |
|
| 372 | + foreach($serializableProperties as $property) { |
|
| 373 | + $propertyNames[] = $property->getName(); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $propertyNames; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + /** |
|
| 380 | + * Get the [name] column value. |
|
| 381 | + * |
|
| 382 | + * @return string |
|
| 383 | + */ |
|
| 384 | + public function getName() |
|
| 385 | + { |
|
| 386 | + return $this->name; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Set the value of [name] column. |
|
| 391 | + * |
|
| 392 | + * @param string $v new value |
|
| 393 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 394 | + */ |
|
| 395 | + public function setName($v) |
|
| 396 | + { |
|
| 397 | + if ($v !== null) { |
|
| 398 | + $v = (string) $v; |
|
| 399 | + } |
|
| 400 | + |
|
| 401 | + if ($this->name !== $v) { |
|
| 402 | + $this->name = $v; |
|
| 403 | + $this->modifiedColumns[InstanceTableMap::COL_NAME] = true; |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $this; |
|
| 407 | + } // setName() |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * Indicates whether the columns in this object are only set to default values. |
|
| 411 | + * |
|
| 412 | + * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 413 | + * modified _and_ has some values set which are non-default. |
|
| 414 | + * |
|
| 415 | + * @return boolean Whether the columns in this object are only been set with default values. |
|
| 416 | + */ |
|
| 417 | + public function hasOnlyDefaultValues() |
|
| 418 | + { |
|
| 419 | + // otherwise, everything was equal, so return TRUE |
|
| 420 | + return true; |
|
| 421 | + } // hasOnlyDefaultValues() |
|
| 422 | + |
|
| 423 | + /** |
|
| 424 | + * Hydrates (populates) the object variables with values from the database resultset. |
|
| 425 | + * |
|
| 426 | + * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 427 | + * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 428 | + * for results of JOIN queries where the resultset row includes columns from two or |
|
| 429 | + * more tables. |
|
| 430 | + * |
|
| 431 | + * @param array $row The row returned by DataFetcher->fetch(). |
|
| 432 | + * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 433 | + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 434 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 435 | 435 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
| 436 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 437 | - * |
|
| 438 | - * @return int next starting column |
|
| 439 | - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 440 | - */ |
|
| 441 | - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 442 | - { |
|
| 443 | - try { |
|
| 444 | - |
|
| 445 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : InstanceTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 446 | - $this->name = (null !== $col) ? (string) $col : null; |
|
| 447 | - $this->resetModified(); |
|
| 448 | - |
|
| 449 | - $this->setNew(false); |
|
| 450 | - |
|
| 451 | - if ($rehydrate) { |
|
| 452 | - $this->ensureConsistency(); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - return $startcol + 1; // 1 = InstanceTableMap::NUM_HYDRATE_COLUMNS. |
|
| 456 | - |
|
| 457 | - } catch (Exception $e) { |
|
| 458 | - throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Instance'), 0, $e); |
|
| 459 | - } |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - /** |
|
| 463 | - * Checks and repairs the internal consistency of the object. |
|
| 464 | - * |
|
| 465 | - * This method is executed after an already-instantiated object is re-hydrated |
|
| 466 | - * from the database. It exists to check any foreign keys to make sure that |
|
| 467 | - * the objects related to the current object are correct based on foreign key. |
|
| 468 | - * |
|
| 469 | - * You can override this method in the stub class, but you should always invoke |
|
| 470 | - * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 471 | - * in case your model changes. |
|
| 472 | - * |
|
| 473 | - * @throws PropelException |
|
| 474 | - */ |
|
| 475 | - public function ensureConsistency() |
|
| 476 | - { |
|
| 477 | - } // ensureConsistency |
|
| 478 | - |
|
| 479 | - /** |
|
| 480 | - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 481 | - * |
|
| 482 | - * This will only work if the object has been saved and has a valid primary key set. |
|
| 483 | - * |
|
| 484 | - * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 485 | - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 486 | - * @return void |
|
| 487 | - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 488 | - */ |
|
| 489 | - public function reload($deep = false, ConnectionInterface $con = null) |
|
| 490 | - { |
|
| 491 | - if ($this->isDeleted()) { |
|
| 492 | - throw new PropelException("Cannot reload a deleted object."); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - if ($this->isNew()) { |
|
| 496 | - throw new PropelException("Cannot reload an unsaved object."); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - if ($con === null) { |
|
| 500 | - $con = Propel::getServiceContainer()->getReadConnection(InstanceTableMap::DATABASE_NAME); |
|
| 501 | - } |
|
| 502 | - |
|
| 503 | - // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 504 | - // already in the pool. |
|
| 505 | - |
|
| 506 | - $dataFetcher = ChildInstanceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 507 | - $row = $dataFetcher->fetch(); |
|
| 508 | - $dataFetcher->close(); |
|
| 509 | - if (!$row) { |
|
| 510 | - throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 511 | - } |
|
| 512 | - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 513 | - |
|
| 514 | - if ($deep) { // also de-associate any related objects? |
|
| 515 | - |
|
| 516 | - $this->collUsers = null; |
|
| 517 | - |
|
| 518 | - $this->collConnections = null; |
|
| 519 | - |
|
| 520 | - $this->collInputs = null; |
|
| 521 | - |
|
| 522 | - $this->collChannels = null; |
|
| 523 | - |
|
| 524 | - $this->collSubscriptions = null; |
|
| 525 | - |
|
| 526 | - } // if (deep) |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Removes this object from datastore and sets delete attribute. |
|
| 531 | - * |
|
| 532 | - * @param ConnectionInterface $con |
|
| 533 | - * @return void |
|
| 534 | - * @throws PropelException |
|
| 535 | - * @see Instance::setDeleted() |
|
| 536 | - * @see Instance::isDeleted() |
|
| 537 | - */ |
|
| 538 | - public function delete(ConnectionInterface $con = null) |
|
| 539 | - { |
|
| 540 | - if ($this->isDeleted()) { |
|
| 541 | - throw new PropelException("This object has already been deleted."); |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - if ($con === null) { |
|
| 545 | - $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - $con->transaction(function () use ($con) { |
|
| 549 | - $deleteQuery = ChildInstanceQuery::create() |
|
| 550 | - ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 551 | - $ret = $this->preDelete($con); |
|
| 552 | - if ($ret) { |
|
| 553 | - $deleteQuery->delete($con); |
|
| 554 | - $this->postDelete($con); |
|
| 555 | - $this->setDeleted(true); |
|
| 556 | - } |
|
| 557 | - }); |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - /** |
|
| 561 | - * Persists this object to the database. |
|
| 562 | - * |
|
| 563 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 564 | - * All modified related objects will also be persisted in the doSave() |
|
| 565 | - * method. This method wraps all precipitate database operations in a |
|
| 566 | - * single transaction. |
|
| 567 | - * |
|
| 568 | - * @param ConnectionInterface $con |
|
| 569 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 570 | - * @throws PropelException |
|
| 571 | - * @see doSave() |
|
| 572 | - */ |
|
| 573 | - public function save(ConnectionInterface $con = null) |
|
| 574 | - { |
|
| 575 | - if ($this->isDeleted()) { |
|
| 576 | - throw new PropelException("You cannot save an object that has been deleted."); |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - if ($con === null) { |
|
| 580 | - $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - return $con->transaction(function () use ($con) { |
|
| 584 | - $isInsert = $this->isNew(); |
|
| 585 | - $ret = $this->preSave($con); |
|
| 586 | - if ($isInsert) { |
|
| 587 | - $ret = $ret && $this->preInsert($con); |
|
| 588 | - } else { |
|
| 589 | - $ret = $ret && $this->preUpdate($con); |
|
| 590 | - } |
|
| 591 | - if ($ret) { |
|
| 592 | - $affectedRows = $this->doSave($con); |
|
| 593 | - if ($isInsert) { |
|
| 594 | - $this->postInsert($con); |
|
| 595 | - } else { |
|
| 596 | - $this->postUpdate($con); |
|
| 597 | - } |
|
| 598 | - $this->postSave($con); |
|
| 599 | - InstanceTableMap::addInstanceToPool($this); |
|
| 600 | - } else { |
|
| 601 | - $affectedRows = 0; |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - return $affectedRows; |
|
| 605 | - }); |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - /** |
|
| 609 | - * Performs the work of inserting or updating the row in the database. |
|
| 610 | - * |
|
| 611 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 612 | - * All related objects are also updated in this method. |
|
| 613 | - * |
|
| 614 | - * @param ConnectionInterface $con |
|
| 615 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 616 | - * @throws PropelException |
|
| 617 | - * @see save() |
|
| 618 | - */ |
|
| 619 | - protected function doSave(ConnectionInterface $con) |
|
| 620 | - { |
|
| 621 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 622 | - if (!$this->alreadyInSave) { |
|
| 623 | - $this->alreadyInSave = true; |
|
| 624 | - |
|
| 625 | - if ($this->isNew() || $this->isModified()) { |
|
| 626 | - // persist changes |
|
| 627 | - if ($this->isNew()) { |
|
| 628 | - $this->doInsert($con); |
|
| 629 | - $affectedRows += 1; |
|
| 630 | - } else { |
|
| 631 | - $affectedRows += $this->doUpdate($con); |
|
| 632 | - } |
|
| 633 | - $this->resetModified(); |
|
| 634 | - } |
|
| 635 | - |
|
| 636 | - if ($this->usersScheduledForDeletion !== null) { |
|
| 637 | - if (!$this->usersScheduledForDeletion->isEmpty()) { |
|
| 638 | - \Jalle19\StatusManager\Database\UserQuery::create() |
|
| 639 | - ->filterByPrimaryKeys($this->usersScheduledForDeletion->getPrimaryKeys(false)) |
|
| 640 | - ->delete($con); |
|
| 641 | - $this->usersScheduledForDeletion = null; |
|
| 642 | - } |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - if ($this->collUsers !== null) { |
|
| 646 | - foreach ($this->collUsers as $referrerFK) { |
|
| 647 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 648 | - $affectedRows += $referrerFK->save($con); |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - if ($this->connectionsScheduledForDeletion !== null) { |
|
| 654 | - if (!$this->connectionsScheduledForDeletion->isEmpty()) { |
|
| 655 | - \Jalle19\StatusManager\Database\ConnectionQuery::create() |
|
| 656 | - ->filterByPrimaryKeys($this->connectionsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 657 | - ->delete($con); |
|
| 658 | - $this->connectionsScheduledForDeletion = null; |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - |
|
| 662 | - if ($this->collConnections !== null) { |
|
| 663 | - foreach ($this->collConnections as $referrerFK) { |
|
| 664 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 665 | - $affectedRows += $referrerFK->save($con); |
|
| 666 | - } |
|
| 667 | - } |
|
| 668 | - } |
|
| 669 | - |
|
| 670 | - if ($this->inputsScheduledForDeletion !== null) { |
|
| 671 | - if (!$this->inputsScheduledForDeletion->isEmpty()) { |
|
| 672 | - \Jalle19\StatusManager\Database\InputQuery::create() |
|
| 673 | - ->filterByPrimaryKeys($this->inputsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 674 | - ->delete($con); |
|
| 675 | - $this->inputsScheduledForDeletion = null; |
|
| 676 | - } |
|
| 677 | - } |
|
| 678 | - |
|
| 679 | - if ($this->collInputs !== null) { |
|
| 680 | - foreach ($this->collInputs as $referrerFK) { |
|
| 681 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 682 | - $affectedRows += $referrerFK->save($con); |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - } |
|
| 686 | - |
|
| 687 | - if ($this->channelsScheduledForDeletion !== null) { |
|
| 688 | - if (!$this->channelsScheduledForDeletion->isEmpty()) { |
|
| 689 | - \Jalle19\StatusManager\Database\ChannelQuery::create() |
|
| 690 | - ->filterByPrimaryKeys($this->channelsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 691 | - ->delete($con); |
|
| 692 | - $this->channelsScheduledForDeletion = null; |
|
| 693 | - } |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - if ($this->collChannels !== null) { |
|
| 697 | - foreach ($this->collChannels as $referrerFK) { |
|
| 698 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 699 | - $affectedRows += $referrerFK->save($con); |
|
| 700 | - } |
|
| 701 | - } |
|
| 702 | - } |
|
| 703 | - |
|
| 704 | - if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 705 | - if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 706 | - \Jalle19\StatusManager\Database\SubscriptionQuery::create() |
|
| 707 | - ->filterByPrimaryKeys($this->subscriptionsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 708 | - ->delete($con); |
|
| 709 | - $this->subscriptionsScheduledForDeletion = null; |
|
| 710 | - } |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - if ($this->collSubscriptions !== null) { |
|
| 714 | - foreach ($this->collSubscriptions as $referrerFK) { |
|
| 715 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 716 | - $affectedRows += $referrerFK->save($con); |
|
| 717 | - } |
|
| 718 | - } |
|
| 719 | - } |
|
| 720 | - |
|
| 721 | - $this->alreadyInSave = false; |
|
| 722 | - |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - return $affectedRows; |
|
| 726 | - } // doSave() |
|
| 727 | - |
|
| 728 | - /** |
|
| 729 | - * Insert the row in the database. |
|
| 730 | - * |
|
| 731 | - * @param ConnectionInterface $con |
|
| 732 | - * |
|
| 733 | - * @throws PropelException |
|
| 734 | - * @see doSave() |
|
| 735 | - */ |
|
| 736 | - protected function doInsert(ConnectionInterface $con) |
|
| 737 | - { |
|
| 738 | - $modifiedColumns = array(); |
|
| 739 | - $index = 0; |
|
| 740 | - |
|
| 741 | - |
|
| 742 | - // check the columns in natural order for more readable SQL queries |
|
| 743 | - if ($this->isColumnModified(InstanceTableMap::COL_NAME)) { |
|
| 744 | - $modifiedColumns[':p' . $index++] = 'name'; |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - $sql = sprintf( |
|
| 748 | - 'INSERT INTO instance (%s) VALUES (%s)', |
|
| 749 | - implode(', ', $modifiedColumns), |
|
| 750 | - implode(', ', array_keys($modifiedColumns)) |
|
| 751 | - ); |
|
| 752 | - |
|
| 753 | - try { |
|
| 754 | - $stmt = $con->prepare($sql); |
|
| 755 | - foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 756 | - switch ($columnName) { |
|
| 757 | - case 'name': |
|
| 758 | - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
|
| 759 | - break; |
|
| 760 | - } |
|
| 761 | - } |
|
| 762 | - $stmt->execute(); |
|
| 763 | - } catch (Exception $e) { |
|
| 764 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 765 | - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 766 | - } |
|
| 767 | - |
|
| 768 | - $this->setNew(false); |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - /** |
|
| 772 | - * Update the row in the database. |
|
| 773 | - * |
|
| 774 | - * @param ConnectionInterface $con |
|
| 775 | - * |
|
| 776 | - * @return Integer Number of updated rows |
|
| 777 | - * @see doSave() |
|
| 778 | - */ |
|
| 779 | - protected function doUpdate(ConnectionInterface $con) |
|
| 780 | - { |
|
| 781 | - $selectCriteria = $this->buildPkeyCriteria(); |
|
| 782 | - $valuesCriteria = $this->buildCriteria(); |
|
| 783 | - |
|
| 784 | - return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 785 | - } |
|
| 786 | - |
|
| 787 | - /** |
|
| 788 | - * Retrieves a field from the object by name passed in as a string. |
|
| 789 | - * |
|
| 790 | - * @param string $name name |
|
| 791 | - * @param string $type The type of fieldname the $name is of: |
|
| 792 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 793 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 794 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 795 | - * @return mixed Value of field. |
|
| 796 | - */ |
|
| 797 | - public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 798 | - { |
|
| 799 | - $pos = InstanceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 800 | - $field = $this->getByPosition($pos); |
|
| 801 | - |
|
| 802 | - return $field; |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - /** |
|
| 806 | - * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 807 | - * Zero-based. |
|
| 808 | - * |
|
| 809 | - * @param int $pos position in xml schema |
|
| 810 | - * @return mixed Value of field at $pos |
|
| 811 | - */ |
|
| 812 | - public function getByPosition($pos) |
|
| 813 | - { |
|
| 814 | - switch ($pos) { |
|
| 815 | - case 0: |
|
| 816 | - return $this->getName(); |
|
| 817 | - break; |
|
| 818 | - default: |
|
| 819 | - return null; |
|
| 820 | - break; |
|
| 821 | - } // switch() |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - /** |
|
| 825 | - * Exports the object as an array. |
|
| 826 | - * |
|
| 827 | - * You can specify the key type of the array by passing one of the class |
|
| 828 | - * type constants. |
|
| 829 | - * |
|
| 830 | - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 831 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 832 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 833 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 834 | - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 835 | - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 836 | - * |
|
| 837 | - * @return array an associative array containing the field names (as keys) and field values |
|
| 838 | - */ |
|
| 839 | - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 840 | - { |
|
| 841 | - |
|
| 842 | - if (isset($alreadyDumpedObjects['Instance'][$this->hashCode()])) { |
|
| 843 | - return '*RECURSION*'; |
|
| 844 | - } |
|
| 845 | - $alreadyDumpedObjects['Instance'][$this->hashCode()] = true; |
|
| 846 | - $keys = InstanceTableMap::getFieldNames($keyType); |
|
| 847 | - $result = array( |
|
| 848 | - $keys[0] => $this->getName(), |
|
| 849 | - ); |
|
| 850 | - $virtualColumns = $this->virtualColumns; |
|
| 851 | - foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 852 | - $result[$key] = $virtualColumn; |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - if ($includeForeignObjects) { |
|
| 856 | - if (null !== $this->collUsers) { |
|
| 857 | - |
|
| 858 | - switch ($keyType) { |
|
| 859 | - case TableMap::TYPE_CAMELNAME: |
|
| 860 | - $key = 'users'; |
|
| 861 | - break; |
|
| 862 | - case TableMap::TYPE_FIELDNAME: |
|
| 863 | - $key = 'users'; |
|
| 864 | - break; |
|
| 865 | - default: |
|
| 866 | - $key = 'Users'; |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - $result[$key] = $this->collUsers->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 870 | - } |
|
| 871 | - if (null !== $this->collConnections) { |
|
| 872 | - |
|
| 873 | - switch ($keyType) { |
|
| 874 | - case TableMap::TYPE_CAMELNAME: |
|
| 875 | - $key = 'connections'; |
|
| 876 | - break; |
|
| 877 | - case TableMap::TYPE_FIELDNAME: |
|
| 878 | - $key = 'connections'; |
|
| 879 | - break; |
|
| 880 | - default: |
|
| 881 | - $key = 'Connections'; |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - $result[$key] = $this->collConnections->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 885 | - } |
|
| 886 | - if (null !== $this->collInputs) { |
|
| 887 | - |
|
| 888 | - switch ($keyType) { |
|
| 889 | - case TableMap::TYPE_CAMELNAME: |
|
| 890 | - $key = 'inputs'; |
|
| 891 | - break; |
|
| 892 | - case TableMap::TYPE_FIELDNAME: |
|
| 893 | - $key = 'inputs'; |
|
| 894 | - break; |
|
| 895 | - default: |
|
| 896 | - $key = 'Inputs'; |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - $result[$key] = $this->collInputs->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 900 | - } |
|
| 901 | - if (null !== $this->collChannels) { |
|
| 902 | - |
|
| 903 | - switch ($keyType) { |
|
| 904 | - case TableMap::TYPE_CAMELNAME: |
|
| 905 | - $key = 'channels'; |
|
| 906 | - break; |
|
| 907 | - case TableMap::TYPE_FIELDNAME: |
|
| 908 | - $key = 'channels'; |
|
| 909 | - break; |
|
| 910 | - default: |
|
| 911 | - $key = 'Channels'; |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - $result[$key] = $this->collChannels->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 915 | - } |
|
| 916 | - if (null !== $this->collSubscriptions) { |
|
| 917 | - |
|
| 918 | - switch ($keyType) { |
|
| 919 | - case TableMap::TYPE_CAMELNAME: |
|
| 920 | - $key = 'subscriptions'; |
|
| 921 | - break; |
|
| 922 | - case TableMap::TYPE_FIELDNAME: |
|
| 923 | - $key = 'subscriptions'; |
|
| 924 | - break; |
|
| 925 | - default: |
|
| 926 | - $key = 'Subscriptions'; |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 930 | - } |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - return $result; |
|
| 934 | - } |
|
| 935 | - |
|
| 936 | - /** |
|
| 937 | - * Sets a field from the object by name passed in as a string. |
|
| 938 | - * |
|
| 939 | - * @param string $name |
|
| 940 | - * @param mixed $value field value |
|
| 941 | - * @param string $type The type of fieldname the $name is of: |
|
| 942 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 943 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 944 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 945 | - * @return $this|\Jalle19\StatusManager\Database\Instance |
|
| 946 | - */ |
|
| 947 | - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 948 | - { |
|
| 949 | - $pos = InstanceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 950 | - |
|
| 951 | - return $this->setByPosition($pos, $value); |
|
| 952 | - } |
|
| 953 | - |
|
| 954 | - /** |
|
| 955 | - * Sets a field from the object by Position as specified in the xml schema. |
|
| 956 | - * Zero-based. |
|
| 957 | - * |
|
| 958 | - * @param int $pos position in xml schema |
|
| 959 | - * @param mixed $value field value |
|
| 960 | - * @return $this|\Jalle19\StatusManager\Database\Instance |
|
| 961 | - */ |
|
| 962 | - public function setByPosition($pos, $value) |
|
| 963 | - { |
|
| 964 | - switch ($pos) { |
|
| 965 | - case 0: |
|
| 966 | - $this->setName($value); |
|
| 967 | - break; |
|
| 968 | - } // switch() |
|
| 969 | - |
|
| 970 | - return $this; |
|
| 971 | - } |
|
| 972 | - |
|
| 973 | - /** |
|
| 974 | - * Populates the object using an array. |
|
| 975 | - * |
|
| 976 | - * This is particularly useful when populating an object from one of the |
|
| 977 | - * request arrays (e.g. $_POST). This method goes through the column |
|
| 978 | - * names, checking to see whether a matching key exists in populated |
|
| 979 | - * array. If so the setByName() method is called for that column. |
|
| 980 | - * |
|
| 981 | - * You can specify the key type of the array by additionally passing one |
|
| 982 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 983 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 984 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 985 | - * |
|
| 986 | - * @param array $arr An array to populate the object from. |
|
| 987 | - * @param string $keyType The type of keys the array uses. |
|
| 988 | - * @return void |
|
| 989 | - */ |
|
| 990 | - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 991 | - { |
|
| 992 | - $keys = InstanceTableMap::getFieldNames($keyType); |
|
| 993 | - |
|
| 994 | - if (array_key_exists($keys[0], $arr)) { |
|
| 995 | - $this->setName($arr[$keys[0]]); |
|
| 996 | - } |
|
| 997 | - } |
|
| 998 | - |
|
| 999 | - /** |
|
| 1000 | - * Populate the current object from a string, using a given parser format |
|
| 1001 | - * <code> |
|
| 1002 | - * $book = new Book(); |
|
| 1003 | - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 1004 | - * </code> |
|
| 1005 | - * |
|
| 1006 | - * You can specify the key type of the array by additionally passing one |
|
| 1007 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1008 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1009 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1010 | - * |
|
| 1011 | - * @param mixed $parser A AbstractParser instance, |
|
| 1012 | - * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 1013 | - * @param string $data The source data to import from |
|
| 1014 | - * @param string $keyType The type of keys the array uses. |
|
| 1015 | - * |
|
| 1016 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object, for fluid interface |
|
| 1017 | - */ |
|
| 1018 | - public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1019 | - { |
|
| 1020 | - if (!$parser instanceof AbstractParser) { |
|
| 1021 | - $parser = AbstractParser::getParser($parser); |
|
| 1022 | - } |
|
| 1023 | - |
|
| 1024 | - $this->fromArray($parser->toArray($data), $keyType); |
|
| 1025 | - |
|
| 1026 | - return $this; |
|
| 1027 | - } |
|
| 1028 | - |
|
| 1029 | - /** |
|
| 1030 | - * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1031 | - * |
|
| 1032 | - * @return Criteria The Criteria object containing all modified values. |
|
| 1033 | - */ |
|
| 1034 | - public function buildCriteria() |
|
| 1035 | - { |
|
| 1036 | - $criteria = new Criteria(InstanceTableMap::DATABASE_NAME); |
|
| 1037 | - |
|
| 1038 | - if ($this->isColumnModified(InstanceTableMap::COL_NAME)) { |
|
| 1039 | - $criteria->add(InstanceTableMap::COL_NAME, $this->name); |
|
| 1040 | - } |
|
| 1041 | - |
|
| 1042 | - return $criteria; |
|
| 1043 | - } |
|
| 1044 | - |
|
| 1045 | - /** |
|
| 1046 | - * Builds a Criteria object containing the primary key for this object. |
|
| 1047 | - * |
|
| 1048 | - * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1049 | - * of whether or not they have been modified. |
|
| 1050 | - * |
|
| 1051 | - * @throws LogicException if no primary key is defined |
|
| 1052 | - * |
|
| 1053 | - * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1054 | - */ |
|
| 1055 | - public function buildPkeyCriteria() |
|
| 1056 | - { |
|
| 1057 | - $criteria = ChildInstanceQuery::create(); |
|
| 1058 | - $criteria->add(InstanceTableMap::COL_NAME, $this->name); |
|
| 1059 | - |
|
| 1060 | - return $criteria; |
|
| 1061 | - } |
|
| 1062 | - |
|
| 1063 | - /** |
|
| 1064 | - * If the primary key is not null, return the hashcode of the |
|
| 1065 | - * primary key. Otherwise, return the hash code of the object. |
|
| 1066 | - * |
|
| 1067 | - * @return int Hashcode |
|
| 1068 | - */ |
|
| 1069 | - public function hashCode() |
|
| 1070 | - { |
|
| 1071 | - $validPk = null !== $this->getName(); |
|
| 1072 | - |
|
| 1073 | - $validPrimaryKeyFKs = 0; |
|
| 1074 | - $primaryKeyFKs = []; |
|
| 1075 | - |
|
| 1076 | - if ($validPk) { |
|
| 1077 | - return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1078 | - } elseif ($validPrimaryKeyFKs) { |
|
| 1079 | - return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - return spl_object_hash($this); |
|
| 1083 | - } |
|
| 1084 | - |
|
| 1085 | - /** |
|
| 1086 | - * Returns the primary key for this object (row). |
|
| 1087 | - * @return string |
|
| 1088 | - */ |
|
| 1089 | - public function getPrimaryKey() |
|
| 1090 | - { |
|
| 1091 | - return $this->getName(); |
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - /** |
|
| 1095 | - * Generic method to set the primary key (name column). |
|
| 1096 | - * |
|
| 1097 | - * @param string $key Primary key. |
|
| 1098 | - * @return void |
|
| 1099 | - */ |
|
| 1100 | - public function setPrimaryKey($key) |
|
| 1101 | - { |
|
| 1102 | - $this->setName($key); |
|
| 1103 | - } |
|
| 1104 | - |
|
| 1105 | - /** |
|
| 1106 | - * Returns true if the primary key for this object is null. |
|
| 1107 | - * @return boolean |
|
| 1108 | - */ |
|
| 1109 | - public function isPrimaryKeyNull() |
|
| 1110 | - { |
|
| 1111 | - return null === $this->getName(); |
|
| 1112 | - } |
|
| 1113 | - |
|
| 1114 | - /** |
|
| 1115 | - * Sets contents of passed object to values from current object. |
|
| 1116 | - * |
|
| 1117 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1118 | - * objects. |
|
| 1119 | - * |
|
| 1120 | - * @param object $copyObj An object of \Jalle19\StatusManager\Database\Instance (or compatible) type. |
|
| 1121 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1122 | - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1123 | - * @throws PropelException |
|
| 1124 | - */ |
|
| 1125 | - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1126 | - { |
|
| 1127 | - $copyObj->setName($this->getName()); |
|
| 1128 | - |
|
| 1129 | - if ($deepCopy) { |
|
| 1130 | - // important: temporarily setNew(false) because this affects the behavior of |
|
| 1131 | - // the getter/setter methods for fkey referrer objects. |
|
| 1132 | - $copyObj->setNew(false); |
|
| 1133 | - |
|
| 1134 | - foreach ($this->getUsers() as $relObj) { |
|
| 1135 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1136 | - $copyObj->addUser($relObj->copy($deepCopy)); |
|
| 1137 | - } |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - foreach ($this->getConnections() as $relObj) { |
|
| 1141 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1142 | - $copyObj->addConnection($relObj->copy($deepCopy)); |
|
| 1143 | - } |
|
| 1144 | - } |
|
| 1145 | - |
|
| 1146 | - foreach ($this->getInputs() as $relObj) { |
|
| 1147 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1148 | - $copyObj->addInput($relObj->copy($deepCopy)); |
|
| 1149 | - } |
|
| 1150 | - } |
|
| 1151 | - |
|
| 1152 | - foreach ($this->getChannels() as $relObj) { |
|
| 1153 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1154 | - $copyObj->addChannel($relObj->copy($deepCopy)); |
|
| 1155 | - } |
|
| 1156 | - } |
|
| 1157 | - |
|
| 1158 | - foreach ($this->getSubscriptions() as $relObj) { |
|
| 1159 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1160 | - $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1161 | - } |
|
| 1162 | - } |
|
| 1163 | - |
|
| 1164 | - } // if ($deepCopy) |
|
| 1165 | - |
|
| 1166 | - if ($makeNew) { |
|
| 1167 | - $copyObj->setNew(true); |
|
| 1168 | - } |
|
| 1169 | - } |
|
| 1170 | - |
|
| 1171 | - /** |
|
| 1172 | - * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1173 | - * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1174 | - * keys that are defined for the table. |
|
| 1175 | - * |
|
| 1176 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1177 | - * objects. |
|
| 1178 | - * |
|
| 1179 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1180 | - * @return \Jalle19\StatusManager\Database\Instance Clone of current object. |
|
| 1181 | - * @throws PropelException |
|
| 1182 | - */ |
|
| 1183 | - public function copy($deepCopy = false) |
|
| 1184 | - { |
|
| 1185 | - // we use get_class(), because this might be a subclass |
|
| 1186 | - $clazz = get_class($this); |
|
| 1187 | - $copyObj = new $clazz(); |
|
| 1188 | - $this->copyInto($copyObj, $deepCopy); |
|
| 1189 | - |
|
| 1190 | - return $copyObj; |
|
| 1191 | - } |
|
| 1192 | - |
|
| 1193 | - |
|
| 1194 | - /** |
|
| 1195 | - * Initializes a collection based on the name of a relation. |
|
| 1196 | - * Avoids crafting an 'init[$relationName]s' method name |
|
| 1197 | - * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1198 | - * |
|
| 1199 | - * @param string $relationName The name of the relation to initialize |
|
| 1200 | - * @return void |
|
| 1201 | - */ |
|
| 1202 | - public function initRelation($relationName) |
|
| 1203 | - { |
|
| 1204 | - if ('User' == $relationName) { |
|
| 1205 | - return $this->initUsers(); |
|
| 1206 | - } |
|
| 1207 | - if ('Connection' == $relationName) { |
|
| 1208 | - return $this->initConnections(); |
|
| 1209 | - } |
|
| 1210 | - if ('Input' == $relationName) { |
|
| 1211 | - return $this->initInputs(); |
|
| 1212 | - } |
|
| 1213 | - if ('Channel' == $relationName) { |
|
| 1214 | - return $this->initChannels(); |
|
| 1215 | - } |
|
| 1216 | - if ('Subscription' == $relationName) { |
|
| 1217 | - return $this->initSubscriptions(); |
|
| 1218 | - } |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - /** |
|
| 1222 | - * Clears out the collUsers collection |
|
| 1223 | - * |
|
| 1224 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1225 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1226 | - * |
|
| 1227 | - * @return void |
|
| 1228 | - * @see addUsers() |
|
| 1229 | - */ |
|
| 1230 | - public function clearUsers() |
|
| 1231 | - { |
|
| 1232 | - $this->collUsers = null; // important to set this to NULL since that means it is uninitialized |
|
| 1233 | - } |
|
| 1234 | - |
|
| 1235 | - /** |
|
| 1236 | - * Reset is the collUsers collection loaded partially. |
|
| 1237 | - */ |
|
| 1238 | - public function resetPartialUsers($v = true) |
|
| 1239 | - { |
|
| 1240 | - $this->collUsersPartial = $v; |
|
| 1241 | - } |
|
| 1242 | - |
|
| 1243 | - /** |
|
| 1244 | - * Initializes the collUsers collection. |
|
| 1245 | - * |
|
| 1246 | - * By default this just sets the collUsers collection to an empty array (like clearcollUsers()); |
|
| 1247 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1248 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1249 | - * |
|
| 1250 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1251 | - * the collection even if it is not empty |
|
| 1252 | - * |
|
| 1253 | - * @return void |
|
| 1254 | - */ |
|
| 1255 | - public function initUsers($overrideExisting = true) |
|
| 1256 | - { |
|
| 1257 | - if (null !== $this->collUsers && !$overrideExisting) { |
|
| 1258 | - return; |
|
| 1259 | - } |
|
| 1260 | - |
|
| 1261 | - $collectionClassName = UserTableMap::getTableMap()->getCollectionClassName(); |
|
| 1262 | - |
|
| 1263 | - $this->collUsers = new $collectionClassName; |
|
| 1264 | - $this->collUsers->setModel('\Jalle19\StatusManager\Database\User'); |
|
| 1265 | - } |
|
| 1266 | - |
|
| 1267 | - /** |
|
| 1268 | - * Gets an array of ChildUser objects which contain a foreign key that references this object. |
|
| 1269 | - * |
|
| 1270 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1271 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1272 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1273 | - * If this ChildInstance is new, it will return |
|
| 1274 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1275 | - * |
|
| 1276 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1277 | - * @param ConnectionInterface $con optional connection object |
|
| 1278 | - * @return ObjectCollection|ChildUser[] List of ChildUser objects |
|
| 1279 | - * @throws PropelException |
|
| 1280 | - */ |
|
| 1281 | - public function getUsers(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1282 | - { |
|
| 1283 | - $partial = $this->collUsersPartial && !$this->isNew(); |
|
| 1284 | - if (null === $this->collUsers || null !== $criteria || $partial) { |
|
| 1285 | - if ($this->isNew() && null === $this->collUsers) { |
|
| 1286 | - // return empty collection |
|
| 1287 | - $this->initUsers(); |
|
| 1288 | - } else { |
|
| 1289 | - $collUsers = ChildUserQuery::create(null, $criteria) |
|
| 1290 | - ->filterByInstance($this) |
|
| 1291 | - ->find($con); |
|
| 1292 | - |
|
| 1293 | - if (null !== $criteria) { |
|
| 1294 | - if (false !== $this->collUsersPartial && count($collUsers)) { |
|
| 1295 | - $this->initUsers(false); |
|
| 1296 | - |
|
| 1297 | - foreach ($collUsers as $obj) { |
|
| 1298 | - if (false == $this->collUsers->contains($obj)) { |
|
| 1299 | - $this->collUsers->append($obj); |
|
| 1300 | - } |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - $this->collUsersPartial = true; |
|
| 1304 | - } |
|
| 1305 | - |
|
| 1306 | - return $collUsers; |
|
| 1307 | - } |
|
| 1308 | - |
|
| 1309 | - if ($partial && $this->collUsers) { |
|
| 1310 | - foreach ($this->collUsers as $obj) { |
|
| 1311 | - if ($obj->isNew()) { |
|
| 1312 | - $collUsers[] = $obj; |
|
| 1313 | - } |
|
| 1314 | - } |
|
| 1315 | - } |
|
| 1316 | - |
|
| 1317 | - $this->collUsers = $collUsers; |
|
| 1318 | - $this->collUsersPartial = false; |
|
| 1319 | - } |
|
| 1320 | - } |
|
| 1321 | - |
|
| 1322 | - return $this->collUsers; |
|
| 1323 | - } |
|
| 1324 | - |
|
| 1325 | - /** |
|
| 1326 | - * Sets a collection of ChildUser objects related by a one-to-many relationship |
|
| 1327 | - * to the current object. |
|
| 1328 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1329 | - * and new objects from the given Propel collection. |
|
| 1330 | - * |
|
| 1331 | - * @param Collection $users A Propel collection. |
|
| 1332 | - * @param ConnectionInterface $con Optional connection object |
|
| 1333 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1334 | - */ |
|
| 1335 | - public function setUsers(Collection $users, ConnectionInterface $con = null) |
|
| 1336 | - { |
|
| 1337 | - /** @var ChildUser[] $usersToDelete */ |
|
| 1338 | - $usersToDelete = $this->getUsers(new Criteria(), $con)->diff($users); |
|
| 1339 | - |
|
| 1340 | - |
|
| 1341 | - $this->usersScheduledForDeletion = $usersToDelete; |
|
| 1342 | - |
|
| 1343 | - foreach ($usersToDelete as $userRemoved) { |
|
| 1344 | - $userRemoved->setInstance(null); |
|
| 1345 | - } |
|
| 1346 | - |
|
| 1347 | - $this->collUsers = null; |
|
| 1348 | - foreach ($users as $user) { |
|
| 1349 | - $this->addUser($user); |
|
| 1350 | - } |
|
| 1351 | - |
|
| 1352 | - $this->collUsers = $users; |
|
| 1353 | - $this->collUsersPartial = false; |
|
| 1354 | - |
|
| 1355 | - return $this; |
|
| 1356 | - } |
|
| 1357 | - |
|
| 1358 | - /** |
|
| 1359 | - * Returns the number of related User objects. |
|
| 1360 | - * |
|
| 1361 | - * @param Criteria $criteria |
|
| 1362 | - * @param boolean $distinct |
|
| 1363 | - * @param ConnectionInterface $con |
|
| 1364 | - * @return int Count of related User objects. |
|
| 1365 | - * @throws PropelException |
|
| 1366 | - */ |
|
| 1367 | - public function countUsers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1368 | - { |
|
| 1369 | - $partial = $this->collUsersPartial && !$this->isNew(); |
|
| 1370 | - if (null === $this->collUsers || null !== $criteria || $partial) { |
|
| 1371 | - if ($this->isNew() && null === $this->collUsers) { |
|
| 1372 | - return 0; |
|
| 1373 | - } |
|
| 1374 | - |
|
| 1375 | - if ($partial && !$criteria) { |
|
| 1376 | - return count($this->getUsers()); |
|
| 1377 | - } |
|
| 1378 | - |
|
| 1379 | - $query = ChildUserQuery::create(null, $criteria); |
|
| 1380 | - if ($distinct) { |
|
| 1381 | - $query->distinct(); |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - return $query |
|
| 1385 | - ->filterByInstance($this) |
|
| 1386 | - ->count($con); |
|
| 1387 | - } |
|
| 1388 | - |
|
| 1389 | - return count($this->collUsers); |
|
| 1390 | - } |
|
| 1391 | - |
|
| 1392 | - /** |
|
| 1393 | - * Method called to associate a ChildUser object to this object |
|
| 1394 | - * through the ChildUser foreign key attribute. |
|
| 1395 | - * |
|
| 1396 | - * @param ChildUser $l ChildUser |
|
| 1397 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 1398 | - */ |
|
| 1399 | - public function addUser(ChildUser $l) |
|
| 1400 | - { |
|
| 1401 | - if ($this->collUsers === null) { |
|
| 1402 | - $this->initUsers(); |
|
| 1403 | - $this->collUsersPartial = true; |
|
| 1404 | - } |
|
| 1405 | - |
|
| 1406 | - if (!$this->collUsers->contains($l)) { |
|
| 1407 | - $this->doAddUser($l); |
|
| 1408 | - |
|
| 1409 | - if ($this->usersScheduledForDeletion and $this->usersScheduledForDeletion->contains($l)) { |
|
| 1410 | - $this->usersScheduledForDeletion->remove($this->usersScheduledForDeletion->search($l)); |
|
| 1411 | - } |
|
| 1412 | - } |
|
| 1413 | - |
|
| 1414 | - return $this; |
|
| 1415 | - } |
|
| 1416 | - |
|
| 1417 | - /** |
|
| 1418 | - * @param ChildUser $user The ChildUser object to add. |
|
| 1419 | - */ |
|
| 1420 | - protected function doAddUser(ChildUser $user) |
|
| 1421 | - { |
|
| 1422 | - $this->collUsers[]= $user; |
|
| 1423 | - $user->setInstance($this); |
|
| 1424 | - } |
|
| 1425 | - |
|
| 1426 | - /** |
|
| 1427 | - * @param ChildUser $user The ChildUser object to remove. |
|
| 1428 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1429 | - */ |
|
| 1430 | - public function removeUser(ChildUser $user) |
|
| 1431 | - { |
|
| 1432 | - if ($this->getUsers()->contains($user)) { |
|
| 1433 | - $pos = $this->collUsers->search($user); |
|
| 1434 | - $this->collUsers->remove($pos); |
|
| 1435 | - if (null === $this->usersScheduledForDeletion) { |
|
| 1436 | - $this->usersScheduledForDeletion = clone $this->collUsers; |
|
| 1437 | - $this->usersScheduledForDeletion->clear(); |
|
| 1438 | - } |
|
| 1439 | - $this->usersScheduledForDeletion[]= clone $user; |
|
| 1440 | - $user->setInstance(null); |
|
| 1441 | - } |
|
| 1442 | - |
|
| 1443 | - return $this; |
|
| 1444 | - } |
|
| 1445 | - |
|
| 1446 | - /** |
|
| 1447 | - * Clears out the collConnections collection |
|
| 1448 | - * |
|
| 1449 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1450 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1451 | - * |
|
| 1452 | - * @return void |
|
| 1453 | - * @see addConnections() |
|
| 1454 | - */ |
|
| 1455 | - public function clearConnections() |
|
| 1456 | - { |
|
| 1457 | - $this->collConnections = null; // important to set this to NULL since that means it is uninitialized |
|
| 1458 | - } |
|
| 1459 | - |
|
| 1460 | - /** |
|
| 1461 | - * Reset is the collConnections collection loaded partially. |
|
| 1462 | - */ |
|
| 1463 | - public function resetPartialConnections($v = true) |
|
| 1464 | - { |
|
| 1465 | - $this->collConnectionsPartial = $v; |
|
| 1466 | - } |
|
| 1467 | - |
|
| 1468 | - /** |
|
| 1469 | - * Initializes the collConnections collection. |
|
| 1470 | - * |
|
| 1471 | - * By default this just sets the collConnections collection to an empty array (like clearcollConnections()); |
|
| 1472 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1473 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1474 | - * |
|
| 1475 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1476 | - * the collection even if it is not empty |
|
| 1477 | - * |
|
| 1478 | - * @return void |
|
| 1479 | - */ |
|
| 1480 | - public function initConnections($overrideExisting = true) |
|
| 1481 | - { |
|
| 1482 | - if (null !== $this->collConnections && !$overrideExisting) { |
|
| 1483 | - return; |
|
| 1484 | - } |
|
| 1485 | - |
|
| 1486 | - $collectionClassName = ConnectionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1487 | - |
|
| 1488 | - $this->collConnections = new $collectionClassName; |
|
| 1489 | - $this->collConnections->setModel('\Jalle19\StatusManager\Database\Connection'); |
|
| 1490 | - } |
|
| 1491 | - |
|
| 1492 | - /** |
|
| 1493 | - * Gets an array of ChildConnection objects which contain a foreign key that references this object. |
|
| 1494 | - * |
|
| 1495 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1496 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1497 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1498 | - * If this ChildInstance is new, it will return |
|
| 1499 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1500 | - * |
|
| 1501 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1502 | - * @param ConnectionInterface $con optional connection object |
|
| 1503 | - * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1504 | - * @throws PropelException |
|
| 1505 | - */ |
|
| 1506 | - public function getConnections(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1507 | - { |
|
| 1508 | - $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1509 | - if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1510 | - if ($this->isNew() && null === $this->collConnections) { |
|
| 1511 | - // return empty collection |
|
| 1512 | - $this->initConnections(); |
|
| 1513 | - } else { |
|
| 1514 | - $collConnections = ChildConnectionQuery::create(null, $criteria) |
|
| 1515 | - ->filterByInstance($this) |
|
| 1516 | - ->find($con); |
|
| 1517 | - |
|
| 1518 | - if (null !== $criteria) { |
|
| 1519 | - if (false !== $this->collConnectionsPartial && count($collConnections)) { |
|
| 1520 | - $this->initConnections(false); |
|
| 1521 | - |
|
| 1522 | - foreach ($collConnections as $obj) { |
|
| 1523 | - if (false == $this->collConnections->contains($obj)) { |
|
| 1524 | - $this->collConnections->append($obj); |
|
| 1525 | - } |
|
| 1526 | - } |
|
| 1527 | - |
|
| 1528 | - $this->collConnectionsPartial = true; |
|
| 1529 | - } |
|
| 1530 | - |
|
| 1531 | - return $collConnections; |
|
| 1532 | - } |
|
| 1533 | - |
|
| 1534 | - if ($partial && $this->collConnections) { |
|
| 1535 | - foreach ($this->collConnections as $obj) { |
|
| 1536 | - if ($obj->isNew()) { |
|
| 1537 | - $collConnections[] = $obj; |
|
| 1538 | - } |
|
| 1539 | - } |
|
| 1540 | - } |
|
| 1541 | - |
|
| 1542 | - $this->collConnections = $collConnections; |
|
| 1543 | - $this->collConnectionsPartial = false; |
|
| 1544 | - } |
|
| 1545 | - } |
|
| 1546 | - |
|
| 1547 | - return $this->collConnections; |
|
| 1548 | - } |
|
| 1549 | - |
|
| 1550 | - /** |
|
| 1551 | - * Sets a collection of ChildConnection objects related by a one-to-many relationship |
|
| 1552 | - * to the current object. |
|
| 1553 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1554 | - * and new objects from the given Propel collection. |
|
| 1555 | - * |
|
| 1556 | - * @param Collection $connections A Propel collection. |
|
| 1557 | - * @param ConnectionInterface $con Optional connection object |
|
| 1558 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1559 | - */ |
|
| 1560 | - public function setConnections(Collection $connections, ConnectionInterface $con = null) |
|
| 1561 | - { |
|
| 1562 | - /** @var ChildConnection[] $connectionsToDelete */ |
|
| 1563 | - $connectionsToDelete = $this->getConnections(new Criteria(), $con)->diff($connections); |
|
| 1564 | - |
|
| 1565 | - |
|
| 1566 | - $this->connectionsScheduledForDeletion = $connectionsToDelete; |
|
| 1567 | - |
|
| 1568 | - foreach ($connectionsToDelete as $connectionRemoved) { |
|
| 1569 | - $connectionRemoved->setInstance(null); |
|
| 1570 | - } |
|
| 1571 | - |
|
| 1572 | - $this->collConnections = null; |
|
| 1573 | - foreach ($connections as $connection) { |
|
| 1574 | - $this->addConnection($connection); |
|
| 1575 | - } |
|
| 1576 | - |
|
| 1577 | - $this->collConnections = $connections; |
|
| 1578 | - $this->collConnectionsPartial = false; |
|
| 1579 | - |
|
| 1580 | - return $this; |
|
| 1581 | - } |
|
| 1582 | - |
|
| 1583 | - /** |
|
| 1584 | - * Returns the number of related Connection objects. |
|
| 1585 | - * |
|
| 1586 | - * @param Criteria $criteria |
|
| 1587 | - * @param boolean $distinct |
|
| 1588 | - * @param ConnectionInterface $con |
|
| 1589 | - * @return int Count of related Connection objects. |
|
| 1590 | - * @throws PropelException |
|
| 1591 | - */ |
|
| 1592 | - public function countConnections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1593 | - { |
|
| 1594 | - $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1595 | - if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1596 | - if ($this->isNew() && null === $this->collConnections) { |
|
| 1597 | - return 0; |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - if ($partial && !$criteria) { |
|
| 1601 | - return count($this->getConnections()); |
|
| 1602 | - } |
|
| 1603 | - |
|
| 1604 | - $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1605 | - if ($distinct) { |
|
| 1606 | - $query->distinct(); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - return $query |
|
| 1610 | - ->filterByInstance($this) |
|
| 1611 | - ->count($con); |
|
| 1612 | - } |
|
| 1613 | - |
|
| 1614 | - return count($this->collConnections); |
|
| 1615 | - } |
|
| 1616 | - |
|
| 1617 | - /** |
|
| 1618 | - * Method called to associate a ChildConnection object to this object |
|
| 1619 | - * through the ChildConnection foreign key attribute. |
|
| 1620 | - * |
|
| 1621 | - * @param ChildConnection $l ChildConnection |
|
| 1622 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 1623 | - */ |
|
| 1624 | - public function addConnection(ChildConnection $l) |
|
| 1625 | - { |
|
| 1626 | - if ($this->collConnections === null) { |
|
| 1627 | - $this->initConnections(); |
|
| 1628 | - $this->collConnectionsPartial = true; |
|
| 1629 | - } |
|
| 1630 | - |
|
| 1631 | - if (!$this->collConnections->contains($l)) { |
|
| 1632 | - $this->doAddConnection($l); |
|
| 1633 | - |
|
| 1634 | - if ($this->connectionsScheduledForDeletion and $this->connectionsScheduledForDeletion->contains($l)) { |
|
| 1635 | - $this->connectionsScheduledForDeletion->remove($this->connectionsScheduledForDeletion->search($l)); |
|
| 1636 | - } |
|
| 1637 | - } |
|
| 1638 | - |
|
| 1639 | - return $this; |
|
| 1640 | - } |
|
| 1641 | - |
|
| 1642 | - /** |
|
| 1643 | - * @param ChildConnection $connection The ChildConnection object to add. |
|
| 1644 | - */ |
|
| 1645 | - protected function doAddConnection(ChildConnection $connection) |
|
| 1646 | - { |
|
| 1647 | - $this->collConnections[]= $connection; |
|
| 1648 | - $connection->setInstance($this); |
|
| 1649 | - } |
|
| 1650 | - |
|
| 1651 | - /** |
|
| 1652 | - * @param ChildConnection $connection The ChildConnection object to remove. |
|
| 1653 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1654 | - */ |
|
| 1655 | - public function removeConnection(ChildConnection $connection) |
|
| 1656 | - { |
|
| 1657 | - if ($this->getConnections()->contains($connection)) { |
|
| 1658 | - $pos = $this->collConnections->search($connection); |
|
| 1659 | - $this->collConnections->remove($pos); |
|
| 1660 | - if (null === $this->connectionsScheduledForDeletion) { |
|
| 1661 | - $this->connectionsScheduledForDeletion = clone $this->collConnections; |
|
| 1662 | - $this->connectionsScheduledForDeletion->clear(); |
|
| 1663 | - } |
|
| 1664 | - $this->connectionsScheduledForDeletion[]= clone $connection; |
|
| 1665 | - $connection->setInstance(null); |
|
| 1666 | - } |
|
| 1667 | - |
|
| 1668 | - return $this; |
|
| 1669 | - } |
|
| 1670 | - |
|
| 1671 | - |
|
| 1672 | - /** |
|
| 1673 | - * If this collection has already been initialized with |
|
| 1674 | - * an identical criteria, it returns the collection. |
|
| 1675 | - * Otherwise if this Instance is new, it will return |
|
| 1676 | - * an empty collection; or if this Instance has previously |
|
| 1677 | - * been saved, it will retrieve related Connections from storage. |
|
| 1678 | - * |
|
| 1679 | - * This method is protected by default in order to keep the public |
|
| 1680 | - * api reasonable. You can provide public methods for those you |
|
| 1681 | - * actually need in Instance. |
|
| 1682 | - * |
|
| 1683 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1684 | - * @param ConnectionInterface $con optional connection object |
|
| 1685 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1686 | - * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1687 | - */ |
|
| 1688 | - public function getConnectionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1689 | - { |
|
| 1690 | - $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1691 | - $query->joinWith('User', $joinBehavior); |
|
| 1692 | - |
|
| 1693 | - return $this->getConnections($query, $con); |
|
| 1694 | - } |
|
| 1695 | - |
|
| 1696 | - /** |
|
| 1697 | - * Clears out the collInputs collection |
|
| 1698 | - * |
|
| 1699 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1700 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1701 | - * |
|
| 1702 | - * @return void |
|
| 1703 | - * @see addInputs() |
|
| 1704 | - */ |
|
| 1705 | - public function clearInputs() |
|
| 1706 | - { |
|
| 1707 | - $this->collInputs = null; // important to set this to NULL since that means it is uninitialized |
|
| 1708 | - } |
|
| 1709 | - |
|
| 1710 | - /** |
|
| 1711 | - * Reset is the collInputs collection loaded partially. |
|
| 1712 | - */ |
|
| 1713 | - public function resetPartialInputs($v = true) |
|
| 1714 | - { |
|
| 1715 | - $this->collInputsPartial = $v; |
|
| 1716 | - } |
|
| 1717 | - |
|
| 1718 | - /** |
|
| 1719 | - * Initializes the collInputs collection. |
|
| 1720 | - * |
|
| 1721 | - * By default this just sets the collInputs collection to an empty array (like clearcollInputs()); |
|
| 1722 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1723 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1724 | - * |
|
| 1725 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1726 | - * the collection even if it is not empty |
|
| 1727 | - * |
|
| 1728 | - * @return void |
|
| 1729 | - */ |
|
| 1730 | - public function initInputs($overrideExisting = true) |
|
| 1731 | - { |
|
| 1732 | - if (null !== $this->collInputs && !$overrideExisting) { |
|
| 1733 | - return; |
|
| 1734 | - } |
|
| 1735 | - |
|
| 1736 | - $collectionClassName = InputTableMap::getTableMap()->getCollectionClassName(); |
|
| 1737 | - |
|
| 1738 | - $this->collInputs = new $collectionClassName; |
|
| 1739 | - $this->collInputs->setModel('\Jalle19\StatusManager\Database\Input'); |
|
| 1740 | - } |
|
| 1741 | - |
|
| 1742 | - /** |
|
| 1743 | - * Gets an array of ChildInput objects which contain a foreign key that references this object. |
|
| 1744 | - * |
|
| 1745 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1746 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1747 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1748 | - * If this ChildInstance is new, it will return |
|
| 1749 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1750 | - * |
|
| 1751 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1752 | - * @param ConnectionInterface $con optional connection object |
|
| 1753 | - * @return ObjectCollection|ChildInput[] List of ChildInput objects |
|
| 1754 | - * @throws PropelException |
|
| 1755 | - */ |
|
| 1756 | - public function getInputs(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1757 | - { |
|
| 1758 | - $partial = $this->collInputsPartial && !$this->isNew(); |
|
| 1759 | - if (null === $this->collInputs || null !== $criteria || $partial) { |
|
| 1760 | - if ($this->isNew() && null === $this->collInputs) { |
|
| 1761 | - // return empty collection |
|
| 1762 | - $this->initInputs(); |
|
| 1763 | - } else { |
|
| 1764 | - $collInputs = ChildInputQuery::create(null, $criteria) |
|
| 1765 | - ->filterByInstance($this) |
|
| 1766 | - ->find($con); |
|
| 1767 | - |
|
| 1768 | - if (null !== $criteria) { |
|
| 1769 | - if (false !== $this->collInputsPartial && count($collInputs)) { |
|
| 1770 | - $this->initInputs(false); |
|
| 1771 | - |
|
| 1772 | - foreach ($collInputs as $obj) { |
|
| 1773 | - if (false == $this->collInputs->contains($obj)) { |
|
| 1774 | - $this->collInputs->append($obj); |
|
| 1775 | - } |
|
| 1776 | - } |
|
| 1777 | - |
|
| 1778 | - $this->collInputsPartial = true; |
|
| 1779 | - } |
|
| 1780 | - |
|
| 1781 | - return $collInputs; |
|
| 1782 | - } |
|
| 1783 | - |
|
| 1784 | - if ($partial && $this->collInputs) { |
|
| 1785 | - foreach ($this->collInputs as $obj) { |
|
| 1786 | - if ($obj->isNew()) { |
|
| 1787 | - $collInputs[] = $obj; |
|
| 1788 | - } |
|
| 1789 | - } |
|
| 1790 | - } |
|
| 1791 | - |
|
| 1792 | - $this->collInputs = $collInputs; |
|
| 1793 | - $this->collInputsPartial = false; |
|
| 1794 | - } |
|
| 1795 | - } |
|
| 1796 | - |
|
| 1797 | - return $this->collInputs; |
|
| 1798 | - } |
|
| 1799 | - |
|
| 1800 | - /** |
|
| 1801 | - * Sets a collection of ChildInput objects related by a one-to-many relationship |
|
| 1802 | - * to the current object. |
|
| 1803 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1804 | - * and new objects from the given Propel collection. |
|
| 1805 | - * |
|
| 1806 | - * @param Collection $inputs A Propel collection. |
|
| 1807 | - * @param ConnectionInterface $con Optional connection object |
|
| 1808 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1809 | - */ |
|
| 1810 | - public function setInputs(Collection $inputs, ConnectionInterface $con = null) |
|
| 1811 | - { |
|
| 1812 | - /** @var ChildInput[] $inputsToDelete */ |
|
| 1813 | - $inputsToDelete = $this->getInputs(new Criteria(), $con)->diff($inputs); |
|
| 1814 | - |
|
| 1815 | - |
|
| 1816 | - $this->inputsScheduledForDeletion = $inputsToDelete; |
|
| 1817 | - |
|
| 1818 | - foreach ($inputsToDelete as $inputRemoved) { |
|
| 1819 | - $inputRemoved->setInstance(null); |
|
| 1820 | - } |
|
| 1821 | - |
|
| 1822 | - $this->collInputs = null; |
|
| 1823 | - foreach ($inputs as $input) { |
|
| 1824 | - $this->addInput($input); |
|
| 1825 | - } |
|
| 1826 | - |
|
| 1827 | - $this->collInputs = $inputs; |
|
| 1828 | - $this->collInputsPartial = false; |
|
| 1829 | - |
|
| 1830 | - return $this; |
|
| 1831 | - } |
|
| 1832 | - |
|
| 1833 | - /** |
|
| 1834 | - * Returns the number of related Input objects. |
|
| 1835 | - * |
|
| 1836 | - * @param Criteria $criteria |
|
| 1837 | - * @param boolean $distinct |
|
| 1838 | - * @param ConnectionInterface $con |
|
| 1839 | - * @return int Count of related Input objects. |
|
| 1840 | - * @throws PropelException |
|
| 1841 | - */ |
|
| 1842 | - public function countInputs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1843 | - { |
|
| 1844 | - $partial = $this->collInputsPartial && !$this->isNew(); |
|
| 1845 | - if (null === $this->collInputs || null !== $criteria || $partial) { |
|
| 1846 | - if ($this->isNew() && null === $this->collInputs) { |
|
| 1847 | - return 0; |
|
| 1848 | - } |
|
| 1849 | - |
|
| 1850 | - if ($partial && !$criteria) { |
|
| 1851 | - return count($this->getInputs()); |
|
| 1852 | - } |
|
| 1853 | - |
|
| 1854 | - $query = ChildInputQuery::create(null, $criteria); |
|
| 1855 | - if ($distinct) { |
|
| 1856 | - $query->distinct(); |
|
| 1857 | - } |
|
| 1858 | - |
|
| 1859 | - return $query |
|
| 1860 | - ->filterByInstance($this) |
|
| 1861 | - ->count($con); |
|
| 1862 | - } |
|
| 1863 | - |
|
| 1864 | - return count($this->collInputs); |
|
| 1865 | - } |
|
| 1866 | - |
|
| 1867 | - /** |
|
| 1868 | - * Method called to associate a ChildInput object to this object |
|
| 1869 | - * through the ChildInput foreign key attribute. |
|
| 1870 | - * |
|
| 1871 | - * @param ChildInput $l ChildInput |
|
| 1872 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 1873 | - */ |
|
| 1874 | - public function addInput(ChildInput $l) |
|
| 1875 | - { |
|
| 1876 | - if ($this->collInputs === null) { |
|
| 1877 | - $this->initInputs(); |
|
| 1878 | - $this->collInputsPartial = true; |
|
| 1879 | - } |
|
| 1880 | - |
|
| 1881 | - if (!$this->collInputs->contains($l)) { |
|
| 1882 | - $this->doAddInput($l); |
|
| 1883 | - |
|
| 1884 | - if ($this->inputsScheduledForDeletion and $this->inputsScheduledForDeletion->contains($l)) { |
|
| 1885 | - $this->inputsScheduledForDeletion->remove($this->inputsScheduledForDeletion->search($l)); |
|
| 1886 | - } |
|
| 1887 | - } |
|
| 1888 | - |
|
| 1889 | - return $this; |
|
| 1890 | - } |
|
| 1891 | - |
|
| 1892 | - /** |
|
| 1893 | - * @param ChildInput $input The ChildInput object to add. |
|
| 1894 | - */ |
|
| 1895 | - protected function doAddInput(ChildInput $input) |
|
| 1896 | - { |
|
| 1897 | - $this->collInputs[]= $input; |
|
| 1898 | - $input->setInstance($this); |
|
| 1899 | - } |
|
| 1900 | - |
|
| 1901 | - /** |
|
| 1902 | - * @param ChildInput $input The ChildInput object to remove. |
|
| 1903 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1904 | - */ |
|
| 1905 | - public function removeInput(ChildInput $input) |
|
| 1906 | - { |
|
| 1907 | - if ($this->getInputs()->contains($input)) { |
|
| 1908 | - $pos = $this->collInputs->search($input); |
|
| 1909 | - $this->collInputs->remove($pos); |
|
| 1910 | - if (null === $this->inputsScheduledForDeletion) { |
|
| 1911 | - $this->inputsScheduledForDeletion = clone $this->collInputs; |
|
| 1912 | - $this->inputsScheduledForDeletion->clear(); |
|
| 1913 | - } |
|
| 1914 | - $this->inputsScheduledForDeletion[]= clone $input; |
|
| 1915 | - $input->setInstance(null); |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - return $this; |
|
| 1919 | - } |
|
| 1920 | - |
|
| 1921 | - /** |
|
| 1922 | - * Clears out the collChannels collection |
|
| 1923 | - * |
|
| 1924 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1925 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1926 | - * |
|
| 1927 | - * @return void |
|
| 1928 | - * @see addChannels() |
|
| 1929 | - */ |
|
| 1930 | - public function clearChannels() |
|
| 1931 | - { |
|
| 1932 | - $this->collChannels = null; // important to set this to NULL since that means it is uninitialized |
|
| 1933 | - } |
|
| 1934 | - |
|
| 1935 | - /** |
|
| 1936 | - * Reset is the collChannels collection loaded partially. |
|
| 1937 | - */ |
|
| 1938 | - public function resetPartialChannels($v = true) |
|
| 1939 | - { |
|
| 1940 | - $this->collChannelsPartial = $v; |
|
| 1941 | - } |
|
| 1942 | - |
|
| 1943 | - /** |
|
| 1944 | - * Initializes the collChannels collection. |
|
| 1945 | - * |
|
| 1946 | - * By default this just sets the collChannels collection to an empty array (like clearcollChannels()); |
|
| 1947 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1948 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1949 | - * |
|
| 1950 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1951 | - * the collection even if it is not empty |
|
| 1952 | - * |
|
| 1953 | - * @return void |
|
| 1954 | - */ |
|
| 1955 | - public function initChannels($overrideExisting = true) |
|
| 1956 | - { |
|
| 1957 | - if (null !== $this->collChannels && !$overrideExisting) { |
|
| 1958 | - return; |
|
| 1959 | - } |
|
| 1960 | - |
|
| 1961 | - $collectionClassName = ChannelTableMap::getTableMap()->getCollectionClassName(); |
|
| 1962 | - |
|
| 1963 | - $this->collChannels = new $collectionClassName; |
|
| 1964 | - $this->collChannels->setModel('\Jalle19\StatusManager\Database\Channel'); |
|
| 1965 | - } |
|
| 1966 | - |
|
| 1967 | - /** |
|
| 1968 | - * Gets an array of ChildChannel objects which contain a foreign key that references this object. |
|
| 1969 | - * |
|
| 1970 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1971 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1972 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1973 | - * If this ChildInstance is new, it will return |
|
| 1974 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1975 | - * |
|
| 1976 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1977 | - * @param ConnectionInterface $con optional connection object |
|
| 1978 | - * @return ObjectCollection|ChildChannel[] List of ChildChannel objects |
|
| 1979 | - * @throws PropelException |
|
| 1980 | - */ |
|
| 1981 | - public function getChannels(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1982 | - { |
|
| 1983 | - $partial = $this->collChannelsPartial && !$this->isNew(); |
|
| 1984 | - if (null === $this->collChannels || null !== $criteria || $partial) { |
|
| 1985 | - if ($this->isNew() && null === $this->collChannels) { |
|
| 1986 | - // return empty collection |
|
| 1987 | - $this->initChannels(); |
|
| 1988 | - } else { |
|
| 1989 | - $collChannels = ChildChannelQuery::create(null, $criteria) |
|
| 1990 | - ->filterByInstance($this) |
|
| 1991 | - ->find($con); |
|
| 1992 | - |
|
| 1993 | - if (null !== $criteria) { |
|
| 1994 | - if (false !== $this->collChannelsPartial && count($collChannels)) { |
|
| 1995 | - $this->initChannels(false); |
|
| 1996 | - |
|
| 1997 | - foreach ($collChannels as $obj) { |
|
| 1998 | - if (false == $this->collChannels->contains($obj)) { |
|
| 1999 | - $this->collChannels->append($obj); |
|
| 2000 | - } |
|
| 2001 | - } |
|
| 2002 | - |
|
| 2003 | - $this->collChannelsPartial = true; |
|
| 2004 | - } |
|
| 2005 | - |
|
| 2006 | - return $collChannels; |
|
| 2007 | - } |
|
| 2008 | - |
|
| 2009 | - if ($partial && $this->collChannels) { |
|
| 2010 | - foreach ($this->collChannels as $obj) { |
|
| 2011 | - if ($obj->isNew()) { |
|
| 2012 | - $collChannels[] = $obj; |
|
| 2013 | - } |
|
| 2014 | - } |
|
| 2015 | - } |
|
| 2016 | - |
|
| 2017 | - $this->collChannels = $collChannels; |
|
| 2018 | - $this->collChannelsPartial = false; |
|
| 2019 | - } |
|
| 2020 | - } |
|
| 2021 | - |
|
| 2022 | - return $this->collChannels; |
|
| 2023 | - } |
|
| 2024 | - |
|
| 2025 | - /** |
|
| 2026 | - * Sets a collection of ChildChannel objects related by a one-to-many relationship |
|
| 2027 | - * to the current object. |
|
| 2028 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 2029 | - * and new objects from the given Propel collection. |
|
| 2030 | - * |
|
| 2031 | - * @param Collection $channels A Propel collection. |
|
| 2032 | - * @param ConnectionInterface $con Optional connection object |
|
| 2033 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2034 | - */ |
|
| 2035 | - public function setChannels(Collection $channels, ConnectionInterface $con = null) |
|
| 2036 | - { |
|
| 2037 | - /** @var ChildChannel[] $channelsToDelete */ |
|
| 2038 | - $channelsToDelete = $this->getChannels(new Criteria(), $con)->diff($channels); |
|
| 2039 | - |
|
| 2040 | - |
|
| 2041 | - $this->channelsScheduledForDeletion = $channelsToDelete; |
|
| 2042 | - |
|
| 2043 | - foreach ($channelsToDelete as $channelRemoved) { |
|
| 2044 | - $channelRemoved->setInstance(null); |
|
| 2045 | - } |
|
| 2046 | - |
|
| 2047 | - $this->collChannels = null; |
|
| 2048 | - foreach ($channels as $channel) { |
|
| 2049 | - $this->addChannel($channel); |
|
| 2050 | - } |
|
| 2051 | - |
|
| 2052 | - $this->collChannels = $channels; |
|
| 2053 | - $this->collChannelsPartial = false; |
|
| 2054 | - |
|
| 2055 | - return $this; |
|
| 2056 | - } |
|
| 2057 | - |
|
| 2058 | - /** |
|
| 2059 | - * Returns the number of related Channel objects. |
|
| 2060 | - * |
|
| 2061 | - * @param Criteria $criteria |
|
| 2062 | - * @param boolean $distinct |
|
| 2063 | - * @param ConnectionInterface $con |
|
| 2064 | - * @return int Count of related Channel objects. |
|
| 2065 | - * @throws PropelException |
|
| 2066 | - */ |
|
| 2067 | - public function countChannels(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 2068 | - { |
|
| 2069 | - $partial = $this->collChannelsPartial && !$this->isNew(); |
|
| 2070 | - if (null === $this->collChannels || null !== $criteria || $partial) { |
|
| 2071 | - if ($this->isNew() && null === $this->collChannels) { |
|
| 2072 | - return 0; |
|
| 2073 | - } |
|
| 2074 | - |
|
| 2075 | - if ($partial && !$criteria) { |
|
| 2076 | - return count($this->getChannels()); |
|
| 2077 | - } |
|
| 2078 | - |
|
| 2079 | - $query = ChildChannelQuery::create(null, $criteria); |
|
| 2080 | - if ($distinct) { |
|
| 2081 | - $query->distinct(); |
|
| 2082 | - } |
|
| 2083 | - |
|
| 2084 | - return $query |
|
| 2085 | - ->filterByInstance($this) |
|
| 2086 | - ->count($con); |
|
| 2087 | - } |
|
| 2088 | - |
|
| 2089 | - return count($this->collChannels); |
|
| 2090 | - } |
|
| 2091 | - |
|
| 2092 | - /** |
|
| 2093 | - * Method called to associate a ChildChannel object to this object |
|
| 2094 | - * through the ChildChannel foreign key attribute. |
|
| 2095 | - * |
|
| 2096 | - * @param ChildChannel $l ChildChannel |
|
| 2097 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 2098 | - */ |
|
| 2099 | - public function addChannel(ChildChannel $l) |
|
| 2100 | - { |
|
| 2101 | - if ($this->collChannels === null) { |
|
| 2102 | - $this->initChannels(); |
|
| 2103 | - $this->collChannelsPartial = true; |
|
| 2104 | - } |
|
| 2105 | - |
|
| 2106 | - if (!$this->collChannels->contains($l)) { |
|
| 2107 | - $this->doAddChannel($l); |
|
| 2108 | - |
|
| 2109 | - if ($this->channelsScheduledForDeletion and $this->channelsScheduledForDeletion->contains($l)) { |
|
| 2110 | - $this->channelsScheduledForDeletion->remove($this->channelsScheduledForDeletion->search($l)); |
|
| 2111 | - } |
|
| 2112 | - } |
|
| 2113 | - |
|
| 2114 | - return $this; |
|
| 2115 | - } |
|
| 2116 | - |
|
| 2117 | - /** |
|
| 2118 | - * @param ChildChannel $channel The ChildChannel object to add. |
|
| 2119 | - */ |
|
| 2120 | - protected function doAddChannel(ChildChannel $channel) |
|
| 2121 | - { |
|
| 2122 | - $this->collChannels[]= $channel; |
|
| 2123 | - $channel->setInstance($this); |
|
| 2124 | - } |
|
| 2125 | - |
|
| 2126 | - /** |
|
| 2127 | - * @param ChildChannel $channel The ChildChannel object to remove. |
|
| 2128 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2129 | - */ |
|
| 2130 | - public function removeChannel(ChildChannel $channel) |
|
| 2131 | - { |
|
| 2132 | - if ($this->getChannels()->contains($channel)) { |
|
| 2133 | - $pos = $this->collChannels->search($channel); |
|
| 2134 | - $this->collChannels->remove($pos); |
|
| 2135 | - if (null === $this->channelsScheduledForDeletion) { |
|
| 2136 | - $this->channelsScheduledForDeletion = clone $this->collChannels; |
|
| 2137 | - $this->channelsScheduledForDeletion->clear(); |
|
| 2138 | - } |
|
| 2139 | - $this->channelsScheduledForDeletion[]= clone $channel; |
|
| 2140 | - $channel->setInstance(null); |
|
| 2141 | - } |
|
| 2142 | - |
|
| 2143 | - return $this; |
|
| 2144 | - } |
|
| 2145 | - |
|
| 2146 | - /** |
|
| 2147 | - * Clears out the collSubscriptions collection |
|
| 2148 | - * |
|
| 2149 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 2150 | - * them to be refetched by subsequent calls to accessor method. |
|
| 2151 | - * |
|
| 2152 | - * @return void |
|
| 2153 | - * @see addSubscriptions() |
|
| 2154 | - */ |
|
| 2155 | - public function clearSubscriptions() |
|
| 2156 | - { |
|
| 2157 | - $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 2158 | - } |
|
| 2159 | - |
|
| 2160 | - /** |
|
| 2161 | - * Reset is the collSubscriptions collection loaded partially. |
|
| 2162 | - */ |
|
| 2163 | - public function resetPartialSubscriptions($v = true) |
|
| 2164 | - { |
|
| 2165 | - $this->collSubscriptionsPartial = $v; |
|
| 2166 | - } |
|
| 2167 | - |
|
| 2168 | - /** |
|
| 2169 | - * Initializes the collSubscriptions collection. |
|
| 2170 | - * |
|
| 2171 | - * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 2172 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 2173 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 2174 | - * |
|
| 2175 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 2176 | - * the collection even if it is not empty |
|
| 2177 | - * |
|
| 2178 | - * @return void |
|
| 2179 | - */ |
|
| 2180 | - public function initSubscriptions($overrideExisting = true) |
|
| 2181 | - { |
|
| 2182 | - if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 2183 | - return; |
|
| 2184 | - } |
|
| 2185 | - |
|
| 2186 | - $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 2187 | - |
|
| 2188 | - $this->collSubscriptions = new $collectionClassName; |
|
| 2189 | - $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 2190 | - } |
|
| 2191 | - |
|
| 2192 | - /** |
|
| 2193 | - * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 2194 | - * |
|
| 2195 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 2196 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 2197 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 2198 | - * If this ChildInstance is new, it will return |
|
| 2199 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 2200 | - * |
|
| 2201 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2202 | - * @param ConnectionInterface $con optional connection object |
|
| 2203 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2204 | - * @throws PropelException |
|
| 2205 | - */ |
|
| 2206 | - public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 2207 | - { |
|
| 2208 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 2209 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 2210 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 2211 | - // return empty collection |
|
| 2212 | - $this->initSubscriptions(); |
|
| 2213 | - } else { |
|
| 2214 | - $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 2215 | - ->filterByInstance($this) |
|
| 2216 | - ->find($con); |
|
| 2217 | - |
|
| 2218 | - if (null !== $criteria) { |
|
| 2219 | - if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 2220 | - $this->initSubscriptions(false); |
|
| 2221 | - |
|
| 2222 | - foreach ($collSubscriptions as $obj) { |
|
| 2223 | - if (false == $this->collSubscriptions->contains($obj)) { |
|
| 2224 | - $this->collSubscriptions->append($obj); |
|
| 2225 | - } |
|
| 2226 | - } |
|
| 2227 | - |
|
| 2228 | - $this->collSubscriptionsPartial = true; |
|
| 2229 | - } |
|
| 2230 | - |
|
| 2231 | - return $collSubscriptions; |
|
| 2232 | - } |
|
| 2233 | - |
|
| 2234 | - if ($partial && $this->collSubscriptions) { |
|
| 2235 | - foreach ($this->collSubscriptions as $obj) { |
|
| 2236 | - if ($obj->isNew()) { |
|
| 2237 | - $collSubscriptions[] = $obj; |
|
| 2238 | - } |
|
| 2239 | - } |
|
| 2240 | - } |
|
| 2241 | - |
|
| 2242 | - $this->collSubscriptions = $collSubscriptions; |
|
| 2243 | - $this->collSubscriptionsPartial = false; |
|
| 2244 | - } |
|
| 2245 | - } |
|
| 2246 | - |
|
| 2247 | - return $this->collSubscriptions; |
|
| 2248 | - } |
|
| 2249 | - |
|
| 2250 | - /** |
|
| 2251 | - * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 2252 | - * to the current object. |
|
| 2253 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 2254 | - * and new objects from the given Propel collection. |
|
| 2255 | - * |
|
| 2256 | - * @param Collection $subscriptions A Propel collection. |
|
| 2257 | - * @param ConnectionInterface $con Optional connection object |
|
| 2258 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2259 | - */ |
|
| 2260 | - public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 2261 | - { |
|
| 2262 | - /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 2263 | - $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 2264 | - |
|
| 2265 | - |
|
| 2266 | - $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 2267 | - |
|
| 2268 | - foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 2269 | - $subscriptionRemoved->setInstance(null); |
|
| 2270 | - } |
|
| 2271 | - |
|
| 2272 | - $this->collSubscriptions = null; |
|
| 2273 | - foreach ($subscriptions as $subscription) { |
|
| 2274 | - $this->addSubscription($subscription); |
|
| 2275 | - } |
|
| 2276 | - |
|
| 2277 | - $this->collSubscriptions = $subscriptions; |
|
| 2278 | - $this->collSubscriptionsPartial = false; |
|
| 2279 | - |
|
| 2280 | - return $this; |
|
| 2281 | - } |
|
| 2282 | - |
|
| 2283 | - /** |
|
| 2284 | - * Returns the number of related Subscription objects. |
|
| 2285 | - * |
|
| 2286 | - * @param Criteria $criteria |
|
| 2287 | - * @param boolean $distinct |
|
| 2288 | - * @param ConnectionInterface $con |
|
| 2289 | - * @return int Count of related Subscription objects. |
|
| 2290 | - * @throws PropelException |
|
| 2291 | - */ |
|
| 2292 | - public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 2293 | - { |
|
| 2294 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 2295 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 2296 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 2297 | - return 0; |
|
| 2298 | - } |
|
| 2299 | - |
|
| 2300 | - if ($partial && !$criteria) { |
|
| 2301 | - return count($this->getSubscriptions()); |
|
| 2302 | - } |
|
| 2303 | - |
|
| 2304 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2305 | - if ($distinct) { |
|
| 2306 | - $query->distinct(); |
|
| 2307 | - } |
|
| 2308 | - |
|
| 2309 | - return $query |
|
| 2310 | - ->filterByInstance($this) |
|
| 2311 | - ->count($con); |
|
| 2312 | - } |
|
| 2313 | - |
|
| 2314 | - return count($this->collSubscriptions); |
|
| 2315 | - } |
|
| 2316 | - |
|
| 2317 | - /** |
|
| 2318 | - * Method called to associate a ChildSubscription object to this object |
|
| 2319 | - * through the ChildSubscription foreign key attribute. |
|
| 2320 | - * |
|
| 2321 | - * @param ChildSubscription $l ChildSubscription |
|
| 2322 | - * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 2323 | - */ |
|
| 2324 | - public function addSubscription(ChildSubscription $l) |
|
| 2325 | - { |
|
| 2326 | - if ($this->collSubscriptions === null) { |
|
| 2327 | - $this->initSubscriptions(); |
|
| 2328 | - $this->collSubscriptionsPartial = true; |
|
| 2329 | - } |
|
| 2330 | - |
|
| 2331 | - if (!$this->collSubscriptions->contains($l)) { |
|
| 2332 | - $this->doAddSubscription($l); |
|
| 2333 | - |
|
| 2334 | - if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 2335 | - $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 2336 | - } |
|
| 2337 | - } |
|
| 2338 | - |
|
| 2339 | - return $this; |
|
| 2340 | - } |
|
| 2341 | - |
|
| 2342 | - /** |
|
| 2343 | - * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 2344 | - */ |
|
| 2345 | - protected function doAddSubscription(ChildSubscription $subscription) |
|
| 2346 | - { |
|
| 2347 | - $this->collSubscriptions[]= $subscription; |
|
| 2348 | - $subscription->setInstance($this); |
|
| 2349 | - } |
|
| 2350 | - |
|
| 2351 | - /** |
|
| 2352 | - * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 2353 | - * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2354 | - */ |
|
| 2355 | - public function removeSubscription(ChildSubscription $subscription) |
|
| 2356 | - { |
|
| 2357 | - if ($this->getSubscriptions()->contains($subscription)) { |
|
| 2358 | - $pos = $this->collSubscriptions->search($subscription); |
|
| 2359 | - $this->collSubscriptions->remove($pos); |
|
| 2360 | - if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 2361 | - $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 2362 | - $this->subscriptionsScheduledForDeletion->clear(); |
|
| 2363 | - } |
|
| 2364 | - $this->subscriptionsScheduledForDeletion[]= clone $subscription; |
|
| 2365 | - $subscription->setInstance(null); |
|
| 2366 | - } |
|
| 2367 | - |
|
| 2368 | - return $this; |
|
| 2369 | - } |
|
| 2370 | - |
|
| 2371 | - |
|
| 2372 | - /** |
|
| 2373 | - * If this collection has already been initialized with |
|
| 2374 | - * an identical criteria, it returns the collection. |
|
| 2375 | - * Otherwise if this Instance is new, it will return |
|
| 2376 | - * an empty collection; or if this Instance has previously |
|
| 2377 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 2378 | - * |
|
| 2379 | - * This method is protected by default in order to keep the public |
|
| 2380 | - * api reasonable. You can provide public methods for those you |
|
| 2381 | - * actually need in Instance. |
|
| 2382 | - * |
|
| 2383 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2384 | - * @param ConnectionInterface $con optional connection object |
|
| 2385 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 2386 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2387 | - */ |
|
| 2388 | - public function getSubscriptionsJoinInput(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 2389 | - { |
|
| 2390 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2391 | - $query->joinWith('Input', $joinBehavior); |
|
| 2392 | - |
|
| 2393 | - return $this->getSubscriptions($query, $con); |
|
| 2394 | - } |
|
| 2395 | - |
|
| 2396 | - |
|
| 2397 | - /** |
|
| 2398 | - * If this collection has already been initialized with |
|
| 2399 | - * an identical criteria, it returns the collection. |
|
| 2400 | - * Otherwise if this Instance is new, it will return |
|
| 2401 | - * an empty collection; or if this Instance has previously |
|
| 2402 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 2403 | - * |
|
| 2404 | - * This method is protected by default in order to keep the public |
|
| 2405 | - * api reasonable. You can provide public methods for those you |
|
| 2406 | - * actually need in Instance. |
|
| 2407 | - * |
|
| 2408 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2409 | - * @param ConnectionInterface $con optional connection object |
|
| 2410 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 2411 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2412 | - */ |
|
| 2413 | - public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 2414 | - { |
|
| 2415 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2416 | - $query->joinWith('User', $joinBehavior); |
|
| 2417 | - |
|
| 2418 | - return $this->getSubscriptions($query, $con); |
|
| 2419 | - } |
|
| 2420 | - |
|
| 2421 | - |
|
| 2422 | - /** |
|
| 2423 | - * If this collection has already been initialized with |
|
| 2424 | - * an identical criteria, it returns the collection. |
|
| 2425 | - * Otherwise if this Instance is new, it will return |
|
| 2426 | - * an empty collection; or if this Instance has previously |
|
| 2427 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 2428 | - * |
|
| 2429 | - * This method is protected by default in order to keep the public |
|
| 2430 | - * api reasonable. You can provide public methods for those you |
|
| 2431 | - * actually need in Instance. |
|
| 2432 | - * |
|
| 2433 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2434 | - * @param ConnectionInterface $con optional connection object |
|
| 2435 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 2436 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2437 | - */ |
|
| 2438 | - public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 2439 | - { |
|
| 2440 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2441 | - $query->joinWith('Channel', $joinBehavior); |
|
| 2442 | - |
|
| 2443 | - return $this->getSubscriptions($query, $con); |
|
| 2444 | - } |
|
| 2445 | - |
|
| 2446 | - /** |
|
| 2447 | - * Clears the current object, sets all attributes to their default values and removes |
|
| 2448 | - * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 2449 | - * change of those foreign objects when you call `save` there). |
|
| 2450 | - */ |
|
| 2451 | - public function clear() |
|
| 2452 | - { |
|
| 2453 | - $this->name = null; |
|
| 2454 | - $this->alreadyInSave = false; |
|
| 2455 | - $this->clearAllReferences(); |
|
| 2456 | - $this->resetModified(); |
|
| 2457 | - $this->setNew(true); |
|
| 2458 | - $this->setDeleted(false); |
|
| 2459 | - } |
|
| 2460 | - |
|
| 2461 | - /** |
|
| 2462 | - * Resets all references and back-references to other model objects or collections of model objects. |
|
| 2463 | - * |
|
| 2464 | - * This method is used to reset all php object references (not the actual reference in the database). |
|
| 2465 | - * Necessary for object serialisation. |
|
| 2466 | - * |
|
| 2467 | - * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 2468 | - */ |
|
| 2469 | - public function clearAllReferences($deep = false) |
|
| 2470 | - { |
|
| 2471 | - if ($deep) { |
|
| 2472 | - if ($this->collUsers) { |
|
| 2473 | - foreach ($this->collUsers as $o) { |
|
| 2474 | - $o->clearAllReferences($deep); |
|
| 2475 | - } |
|
| 2476 | - } |
|
| 2477 | - if ($this->collConnections) { |
|
| 2478 | - foreach ($this->collConnections as $o) { |
|
| 2479 | - $o->clearAllReferences($deep); |
|
| 2480 | - } |
|
| 2481 | - } |
|
| 2482 | - if ($this->collInputs) { |
|
| 2483 | - foreach ($this->collInputs as $o) { |
|
| 2484 | - $o->clearAllReferences($deep); |
|
| 2485 | - } |
|
| 2486 | - } |
|
| 2487 | - if ($this->collChannels) { |
|
| 2488 | - foreach ($this->collChannels as $o) { |
|
| 2489 | - $o->clearAllReferences($deep); |
|
| 2490 | - } |
|
| 2491 | - } |
|
| 2492 | - if ($this->collSubscriptions) { |
|
| 2493 | - foreach ($this->collSubscriptions as $o) { |
|
| 2494 | - $o->clearAllReferences($deep); |
|
| 2495 | - } |
|
| 2496 | - } |
|
| 2497 | - } // if ($deep) |
|
| 2498 | - |
|
| 2499 | - $this->collUsers = null; |
|
| 2500 | - $this->collConnections = null; |
|
| 2501 | - $this->collInputs = null; |
|
| 2502 | - $this->collChannels = null; |
|
| 2503 | - $this->collSubscriptions = null; |
|
| 2504 | - } |
|
| 2505 | - |
|
| 2506 | - /** |
|
| 2507 | - * Return the string representation of this object |
|
| 2508 | - * |
|
| 2509 | - * @return string |
|
| 2510 | - */ |
|
| 2511 | - public function __toString() |
|
| 2512 | - { |
|
| 2513 | - return (string) $this->exportTo(InstanceTableMap::DEFAULT_STRING_FORMAT); |
|
| 2514 | - } |
|
| 2515 | - |
|
| 2516 | - /** |
|
| 2517 | - * Code to be run before persisting the object |
|
| 2518 | - * @param ConnectionInterface $con |
|
| 2519 | - * @return boolean |
|
| 2520 | - */ |
|
| 2521 | - public function preSave(ConnectionInterface $con = null) |
|
| 2522 | - { |
|
| 2523 | - return true; |
|
| 2524 | - } |
|
| 2525 | - |
|
| 2526 | - /** |
|
| 2527 | - * Code to be run after persisting the object |
|
| 2528 | - * @param ConnectionInterface $con |
|
| 2529 | - */ |
|
| 2530 | - public function postSave(ConnectionInterface $con = null) |
|
| 2531 | - { |
|
| 2532 | - |
|
| 2533 | - } |
|
| 2534 | - |
|
| 2535 | - /** |
|
| 2536 | - * Code to be run before inserting to database |
|
| 2537 | - * @param ConnectionInterface $con |
|
| 2538 | - * @return boolean |
|
| 2539 | - */ |
|
| 2540 | - public function preInsert(ConnectionInterface $con = null) |
|
| 2541 | - { |
|
| 2542 | - return true; |
|
| 2543 | - } |
|
| 2544 | - |
|
| 2545 | - /** |
|
| 2546 | - * Code to be run after inserting to database |
|
| 2547 | - * @param ConnectionInterface $con |
|
| 2548 | - */ |
|
| 2549 | - public function postInsert(ConnectionInterface $con = null) |
|
| 2550 | - { |
|
| 2551 | - |
|
| 2552 | - } |
|
| 2553 | - |
|
| 2554 | - /** |
|
| 2555 | - * Code to be run before updating the object in database |
|
| 2556 | - * @param ConnectionInterface $con |
|
| 2557 | - * @return boolean |
|
| 2558 | - */ |
|
| 2559 | - public function preUpdate(ConnectionInterface $con = null) |
|
| 2560 | - { |
|
| 2561 | - return true; |
|
| 2562 | - } |
|
| 2563 | - |
|
| 2564 | - /** |
|
| 2565 | - * Code to be run after updating the object in database |
|
| 2566 | - * @param ConnectionInterface $con |
|
| 2567 | - */ |
|
| 2568 | - public function postUpdate(ConnectionInterface $con = null) |
|
| 2569 | - { |
|
| 2570 | - |
|
| 2571 | - } |
|
| 2572 | - |
|
| 2573 | - /** |
|
| 2574 | - * Code to be run before deleting the object in database |
|
| 2575 | - * @param ConnectionInterface $con |
|
| 2576 | - * @return boolean |
|
| 2577 | - */ |
|
| 2578 | - public function preDelete(ConnectionInterface $con = null) |
|
| 2579 | - { |
|
| 2580 | - return true; |
|
| 2581 | - } |
|
| 2582 | - |
|
| 2583 | - /** |
|
| 2584 | - * Code to be run after deleting the object in database |
|
| 2585 | - * @param ConnectionInterface $con |
|
| 2586 | - */ |
|
| 2587 | - public function postDelete(ConnectionInterface $con = null) |
|
| 2588 | - { |
|
| 2589 | - |
|
| 2590 | - } |
|
| 2591 | - |
|
| 2592 | - |
|
| 2593 | - /** |
|
| 2594 | - * Derived method to catches calls to undefined methods. |
|
| 2595 | - * |
|
| 2596 | - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 2597 | - * Allows to define default __call() behavior if you overwrite __call() |
|
| 2598 | - * |
|
| 2599 | - * @param string $name |
|
| 2600 | - * @param mixed $params |
|
| 2601 | - * |
|
| 2602 | - * @return array|string |
|
| 2603 | - */ |
|
| 2604 | - public function __call($name, $params) |
|
| 2605 | - { |
|
| 2606 | - if (0 === strpos($name, 'get')) { |
|
| 2607 | - $virtualColumn = substr($name, 3); |
|
| 2608 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 2609 | - return $this->getVirtualColumn($virtualColumn); |
|
| 2610 | - } |
|
| 2611 | - |
|
| 2612 | - $virtualColumn = lcfirst($virtualColumn); |
|
| 2613 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 2614 | - return $this->getVirtualColumn($virtualColumn); |
|
| 2615 | - } |
|
| 2616 | - } |
|
| 2617 | - |
|
| 2618 | - if (0 === strpos($name, 'from')) { |
|
| 2619 | - $format = substr($name, 4); |
|
| 2620 | - |
|
| 2621 | - return $this->importFrom($format, reset($params)); |
|
| 2622 | - } |
|
| 2623 | - |
|
| 2624 | - if (0 === strpos($name, 'to')) { |
|
| 2625 | - $format = substr($name, 2); |
|
| 2626 | - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 2627 | - |
|
| 2628 | - return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 2629 | - } |
|
| 2630 | - |
|
| 2631 | - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 2632 | - } |
|
| 436 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 437 | + * |
|
| 438 | + * @return int next starting column |
|
| 439 | + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 440 | + */ |
|
| 441 | + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 442 | + { |
|
| 443 | + try { |
|
| 444 | + |
|
| 445 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : InstanceTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 446 | + $this->name = (null !== $col) ? (string) $col : null; |
|
| 447 | + $this->resetModified(); |
|
| 448 | + |
|
| 449 | + $this->setNew(false); |
|
| 450 | + |
|
| 451 | + if ($rehydrate) { |
|
| 452 | + $this->ensureConsistency(); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + return $startcol + 1; // 1 = InstanceTableMap::NUM_HYDRATE_COLUMNS. |
|
| 456 | + |
|
| 457 | + } catch (Exception $e) { |
|
| 458 | + throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\Instance'), 0, $e); |
|
| 459 | + } |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + /** |
|
| 463 | + * Checks and repairs the internal consistency of the object. |
|
| 464 | + * |
|
| 465 | + * This method is executed after an already-instantiated object is re-hydrated |
|
| 466 | + * from the database. It exists to check any foreign keys to make sure that |
|
| 467 | + * the objects related to the current object are correct based on foreign key. |
|
| 468 | + * |
|
| 469 | + * You can override this method in the stub class, but you should always invoke |
|
| 470 | + * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 471 | + * in case your model changes. |
|
| 472 | + * |
|
| 473 | + * @throws PropelException |
|
| 474 | + */ |
|
| 475 | + public function ensureConsistency() |
|
| 476 | + { |
|
| 477 | + } // ensureConsistency |
|
| 478 | + |
|
| 479 | + /** |
|
| 480 | + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 481 | + * |
|
| 482 | + * This will only work if the object has been saved and has a valid primary key set. |
|
| 483 | + * |
|
| 484 | + * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 485 | + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 486 | + * @return void |
|
| 487 | + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 488 | + */ |
|
| 489 | + public function reload($deep = false, ConnectionInterface $con = null) |
|
| 490 | + { |
|
| 491 | + if ($this->isDeleted()) { |
|
| 492 | + throw new PropelException("Cannot reload a deleted object."); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + if ($this->isNew()) { |
|
| 496 | + throw new PropelException("Cannot reload an unsaved object."); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + if ($con === null) { |
|
| 500 | + $con = Propel::getServiceContainer()->getReadConnection(InstanceTableMap::DATABASE_NAME); |
|
| 501 | + } |
|
| 502 | + |
|
| 503 | + // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 504 | + // already in the pool. |
|
| 505 | + |
|
| 506 | + $dataFetcher = ChildInstanceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 507 | + $row = $dataFetcher->fetch(); |
|
| 508 | + $dataFetcher->close(); |
|
| 509 | + if (!$row) { |
|
| 510 | + throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 511 | + } |
|
| 512 | + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 513 | + |
|
| 514 | + if ($deep) { // also de-associate any related objects? |
|
| 515 | + |
|
| 516 | + $this->collUsers = null; |
|
| 517 | + |
|
| 518 | + $this->collConnections = null; |
|
| 519 | + |
|
| 520 | + $this->collInputs = null; |
|
| 521 | + |
|
| 522 | + $this->collChannels = null; |
|
| 523 | + |
|
| 524 | + $this->collSubscriptions = null; |
|
| 525 | + |
|
| 526 | + } // if (deep) |
|
| 527 | + } |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * Removes this object from datastore and sets delete attribute. |
|
| 531 | + * |
|
| 532 | + * @param ConnectionInterface $con |
|
| 533 | + * @return void |
|
| 534 | + * @throws PropelException |
|
| 535 | + * @see Instance::setDeleted() |
|
| 536 | + * @see Instance::isDeleted() |
|
| 537 | + */ |
|
| 538 | + public function delete(ConnectionInterface $con = null) |
|
| 539 | + { |
|
| 540 | + if ($this->isDeleted()) { |
|
| 541 | + throw new PropelException("This object has already been deleted."); |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + if ($con === null) { |
|
| 545 | + $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + $con->transaction(function () use ($con) { |
|
| 549 | + $deleteQuery = ChildInstanceQuery::create() |
|
| 550 | + ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 551 | + $ret = $this->preDelete($con); |
|
| 552 | + if ($ret) { |
|
| 553 | + $deleteQuery->delete($con); |
|
| 554 | + $this->postDelete($con); |
|
| 555 | + $this->setDeleted(true); |
|
| 556 | + } |
|
| 557 | + }); |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + /** |
|
| 561 | + * Persists this object to the database. |
|
| 562 | + * |
|
| 563 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 564 | + * All modified related objects will also be persisted in the doSave() |
|
| 565 | + * method. This method wraps all precipitate database operations in a |
|
| 566 | + * single transaction. |
|
| 567 | + * |
|
| 568 | + * @param ConnectionInterface $con |
|
| 569 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 570 | + * @throws PropelException |
|
| 571 | + * @see doSave() |
|
| 572 | + */ |
|
| 573 | + public function save(ConnectionInterface $con = null) |
|
| 574 | + { |
|
| 575 | + if ($this->isDeleted()) { |
|
| 576 | + throw new PropelException("You cannot save an object that has been deleted."); |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + if ($con === null) { |
|
| 580 | + $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + return $con->transaction(function () use ($con) { |
|
| 584 | + $isInsert = $this->isNew(); |
|
| 585 | + $ret = $this->preSave($con); |
|
| 586 | + if ($isInsert) { |
|
| 587 | + $ret = $ret && $this->preInsert($con); |
|
| 588 | + } else { |
|
| 589 | + $ret = $ret && $this->preUpdate($con); |
|
| 590 | + } |
|
| 591 | + if ($ret) { |
|
| 592 | + $affectedRows = $this->doSave($con); |
|
| 593 | + if ($isInsert) { |
|
| 594 | + $this->postInsert($con); |
|
| 595 | + } else { |
|
| 596 | + $this->postUpdate($con); |
|
| 597 | + } |
|
| 598 | + $this->postSave($con); |
|
| 599 | + InstanceTableMap::addInstanceToPool($this); |
|
| 600 | + } else { |
|
| 601 | + $affectedRows = 0; |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + return $affectedRows; |
|
| 605 | + }); |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + /** |
|
| 609 | + * Performs the work of inserting or updating the row in the database. |
|
| 610 | + * |
|
| 611 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 612 | + * All related objects are also updated in this method. |
|
| 613 | + * |
|
| 614 | + * @param ConnectionInterface $con |
|
| 615 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 616 | + * @throws PropelException |
|
| 617 | + * @see save() |
|
| 618 | + */ |
|
| 619 | + protected function doSave(ConnectionInterface $con) |
|
| 620 | + { |
|
| 621 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 622 | + if (!$this->alreadyInSave) { |
|
| 623 | + $this->alreadyInSave = true; |
|
| 624 | + |
|
| 625 | + if ($this->isNew() || $this->isModified()) { |
|
| 626 | + // persist changes |
|
| 627 | + if ($this->isNew()) { |
|
| 628 | + $this->doInsert($con); |
|
| 629 | + $affectedRows += 1; |
|
| 630 | + } else { |
|
| 631 | + $affectedRows += $this->doUpdate($con); |
|
| 632 | + } |
|
| 633 | + $this->resetModified(); |
|
| 634 | + } |
|
| 635 | + |
|
| 636 | + if ($this->usersScheduledForDeletion !== null) { |
|
| 637 | + if (!$this->usersScheduledForDeletion->isEmpty()) { |
|
| 638 | + \Jalle19\StatusManager\Database\UserQuery::create() |
|
| 639 | + ->filterByPrimaryKeys($this->usersScheduledForDeletion->getPrimaryKeys(false)) |
|
| 640 | + ->delete($con); |
|
| 641 | + $this->usersScheduledForDeletion = null; |
|
| 642 | + } |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + if ($this->collUsers !== null) { |
|
| 646 | + foreach ($this->collUsers as $referrerFK) { |
|
| 647 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 648 | + $affectedRows += $referrerFK->save($con); |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + if ($this->connectionsScheduledForDeletion !== null) { |
|
| 654 | + if (!$this->connectionsScheduledForDeletion->isEmpty()) { |
|
| 655 | + \Jalle19\StatusManager\Database\ConnectionQuery::create() |
|
| 656 | + ->filterByPrimaryKeys($this->connectionsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 657 | + ->delete($con); |
|
| 658 | + $this->connectionsScheduledForDeletion = null; |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + |
|
| 662 | + if ($this->collConnections !== null) { |
|
| 663 | + foreach ($this->collConnections as $referrerFK) { |
|
| 664 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 665 | + $affectedRows += $referrerFK->save($con); |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | + } |
|
| 669 | + |
|
| 670 | + if ($this->inputsScheduledForDeletion !== null) { |
|
| 671 | + if (!$this->inputsScheduledForDeletion->isEmpty()) { |
|
| 672 | + \Jalle19\StatusManager\Database\InputQuery::create() |
|
| 673 | + ->filterByPrimaryKeys($this->inputsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 674 | + ->delete($con); |
|
| 675 | + $this->inputsScheduledForDeletion = null; |
|
| 676 | + } |
|
| 677 | + } |
|
| 678 | + |
|
| 679 | + if ($this->collInputs !== null) { |
|
| 680 | + foreach ($this->collInputs as $referrerFK) { |
|
| 681 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 682 | + $affectedRows += $referrerFK->save($con); |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + if ($this->channelsScheduledForDeletion !== null) { |
|
| 688 | + if (!$this->channelsScheduledForDeletion->isEmpty()) { |
|
| 689 | + \Jalle19\StatusManager\Database\ChannelQuery::create() |
|
| 690 | + ->filterByPrimaryKeys($this->channelsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 691 | + ->delete($con); |
|
| 692 | + $this->channelsScheduledForDeletion = null; |
|
| 693 | + } |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + if ($this->collChannels !== null) { |
|
| 697 | + foreach ($this->collChannels as $referrerFK) { |
|
| 698 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 699 | + $affectedRows += $referrerFK->save($con); |
|
| 700 | + } |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | + |
|
| 704 | + if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 705 | + if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 706 | + \Jalle19\StatusManager\Database\SubscriptionQuery::create() |
|
| 707 | + ->filterByPrimaryKeys($this->subscriptionsScheduledForDeletion->getPrimaryKeys(false)) |
|
| 708 | + ->delete($con); |
|
| 709 | + $this->subscriptionsScheduledForDeletion = null; |
|
| 710 | + } |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + if ($this->collSubscriptions !== null) { |
|
| 714 | + foreach ($this->collSubscriptions as $referrerFK) { |
|
| 715 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 716 | + $affectedRows += $referrerFK->save($con); |
|
| 717 | + } |
|
| 718 | + } |
|
| 719 | + } |
|
| 720 | + |
|
| 721 | + $this->alreadyInSave = false; |
|
| 722 | + |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + return $affectedRows; |
|
| 726 | + } // doSave() |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * Insert the row in the database. |
|
| 730 | + * |
|
| 731 | + * @param ConnectionInterface $con |
|
| 732 | + * |
|
| 733 | + * @throws PropelException |
|
| 734 | + * @see doSave() |
|
| 735 | + */ |
|
| 736 | + protected function doInsert(ConnectionInterface $con) |
|
| 737 | + { |
|
| 738 | + $modifiedColumns = array(); |
|
| 739 | + $index = 0; |
|
| 740 | + |
|
| 741 | + |
|
| 742 | + // check the columns in natural order for more readable SQL queries |
|
| 743 | + if ($this->isColumnModified(InstanceTableMap::COL_NAME)) { |
|
| 744 | + $modifiedColumns[':p' . $index++] = 'name'; |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + $sql = sprintf( |
|
| 748 | + 'INSERT INTO instance (%s) VALUES (%s)', |
|
| 749 | + implode(', ', $modifiedColumns), |
|
| 750 | + implode(', ', array_keys($modifiedColumns)) |
|
| 751 | + ); |
|
| 752 | + |
|
| 753 | + try { |
|
| 754 | + $stmt = $con->prepare($sql); |
|
| 755 | + foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 756 | + switch ($columnName) { |
|
| 757 | + case 'name': |
|
| 758 | + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
|
| 759 | + break; |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + $stmt->execute(); |
|
| 763 | + } catch (Exception $e) { |
|
| 764 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 765 | + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 766 | + } |
|
| 767 | + |
|
| 768 | + $this->setNew(false); |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + /** |
|
| 772 | + * Update the row in the database. |
|
| 773 | + * |
|
| 774 | + * @param ConnectionInterface $con |
|
| 775 | + * |
|
| 776 | + * @return Integer Number of updated rows |
|
| 777 | + * @see doSave() |
|
| 778 | + */ |
|
| 779 | + protected function doUpdate(ConnectionInterface $con) |
|
| 780 | + { |
|
| 781 | + $selectCriteria = $this->buildPkeyCriteria(); |
|
| 782 | + $valuesCriteria = $this->buildCriteria(); |
|
| 783 | + |
|
| 784 | + return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 785 | + } |
|
| 786 | + |
|
| 787 | + /** |
|
| 788 | + * Retrieves a field from the object by name passed in as a string. |
|
| 789 | + * |
|
| 790 | + * @param string $name name |
|
| 791 | + * @param string $type The type of fieldname the $name is of: |
|
| 792 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 793 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 794 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 795 | + * @return mixed Value of field. |
|
| 796 | + */ |
|
| 797 | + public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 798 | + { |
|
| 799 | + $pos = InstanceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 800 | + $field = $this->getByPosition($pos); |
|
| 801 | + |
|
| 802 | + return $field; |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + /** |
|
| 806 | + * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 807 | + * Zero-based. |
|
| 808 | + * |
|
| 809 | + * @param int $pos position in xml schema |
|
| 810 | + * @return mixed Value of field at $pos |
|
| 811 | + */ |
|
| 812 | + public function getByPosition($pos) |
|
| 813 | + { |
|
| 814 | + switch ($pos) { |
|
| 815 | + case 0: |
|
| 816 | + return $this->getName(); |
|
| 817 | + break; |
|
| 818 | + default: |
|
| 819 | + return null; |
|
| 820 | + break; |
|
| 821 | + } // switch() |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + /** |
|
| 825 | + * Exports the object as an array. |
|
| 826 | + * |
|
| 827 | + * You can specify the key type of the array by passing one of the class |
|
| 828 | + * type constants. |
|
| 829 | + * |
|
| 830 | + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 831 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 832 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 833 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 834 | + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 835 | + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 836 | + * |
|
| 837 | + * @return array an associative array containing the field names (as keys) and field values |
|
| 838 | + */ |
|
| 839 | + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 840 | + { |
|
| 841 | + |
|
| 842 | + if (isset($alreadyDumpedObjects['Instance'][$this->hashCode()])) { |
|
| 843 | + return '*RECURSION*'; |
|
| 844 | + } |
|
| 845 | + $alreadyDumpedObjects['Instance'][$this->hashCode()] = true; |
|
| 846 | + $keys = InstanceTableMap::getFieldNames($keyType); |
|
| 847 | + $result = array( |
|
| 848 | + $keys[0] => $this->getName(), |
|
| 849 | + ); |
|
| 850 | + $virtualColumns = $this->virtualColumns; |
|
| 851 | + foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 852 | + $result[$key] = $virtualColumn; |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + if ($includeForeignObjects) { |
|
| 856 | + if (null !== $this->collUsers) { |
|
| 857 | + |
|
| 858 | + switch ($keyType) { |
|
| 859 | + case TableMap::TYPE_CAMELNAME: |
|
| 860 | + $key = 'users'; |
|
| 861 | + break; |
|
| 862 | + case TableMap::TYPE_FIELDNAME: |
|
| 863 | + $key = 'users'; |
|
| 864 | + break; |
|
| 865 | + default: |
|
| 866 | + $key = 'Users'; |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + $result[$key] = $this->collUsers->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 870 | + } |
|
| 871 | + if (null !== $this->collConnections) { |
|
| 872 | + |
|
| 873 | + switch ($keyType) { |
|
| 874 | + case TableMap::TYPE_CAMELNAME: |
|
| 875 | + $key = 'connections'; |
|
| 876 | + break; |
|
| 877 | + case TableMap::TYPE_FIELDNAME: |
|
| 878 | + $key = 'connections'; |
|
| 879 | + break; |
|
| 880 | + default: |
|
| 881 | + $key = 'Connections'; |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + $result[$key] = $this->collConnections->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 885 | + } |
|
| 886 | + if (null !== $this->collInputs) { |
|
| 887 | + |
|
| 888 | + switch ($keyType) { |
|
| 889 | + case TableMap::TYPE_CAMELNAME: |
|
| 890 | + $key = 'inputs'; |
|
| 891 | + break; |
|
| 892 | + case TableMap::TYPE_FIELDNAME: |
|
| 893 | + $key = 'inputs'; |
|
| 894 | + break; |
|
| 895 | + default: |
|
| 896 | + $key = 'Inputs'; |
|
| 897 | + } |
|
| 898 | + |
|
| 899 | + $result[$key] = $this->collInputs->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 900 | + } |
|
| 901 | + if (null !== $this->collChannels) { |
|
| 902 | + |
|
| 903 | + switch ($keyType) { |
|
| 904 | + case TableMap::TYPE_CAMELNAME: |
|
| 905 | + $key = 'channels'; |
|
| 906 | + break; |
|
| 907 | + case TableMap::TYPE_FIELDNAME: |
|
| 908 | + $key = 'channels'; |
|
| 909 | + break; |
|
| 910 | + default: |
|
| 911 | + $key = 'Channels'; |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + $result[$key] = $this->collChannels->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 915 | + } |
|
| 916 | + if (null !== $this->collSubscriptions) { |
|
| 917 | + |
|
| 918 | + switch ($keyType) { |
|
| 919 | + case TableMap::TYPE_CAMELNAME: |
|
| 920 | + $key = 'subscriptions'; |
|
| 921 | + break; |
|
| 922 | + case TableMap::TYPE_FIELDNAME: |
|
| 923 | + $key = 'subscriptions'; |
|
| 924 | + break; |
|
| 925 | + default: |
|
| 926 | + $key = 'Subscriptions'; |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 930 | + } |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + return $result; |
|
| 934 | + } |
|
| 935 | + |
|
| 936 | + /** |
|
| 937 | + * Sets a field from the object by name passed in as a string. |
|
| 938 | + * |
|
| 939 | + * @param string $name |
|
| 940 | + * @param mixed $value field value |
|
| 941 | + * @param string $type The type of fieldname the $name is of: |
|
| 942 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 943 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 944 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 945 | + * @return $this|\Jalle19\StatusManager\Database\Instance |
|
| 946 | + */ |
|
| 947 | + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 948 | + { |
|
| 949 | + $pos = InstanceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 950 | + |
|
| 951 | + return $this->setByPosition($pos, $value); |
|
| 952 | + } |
|
| 953 | + |
|
| 954 | + /** |
|
| 955 | + * Sets a field from the object by Position as specified in the xml schema. |
|
| 956 | + * Zero-based. |
|
| 957 | + * |
|
| 958 | + * @param int $pos position in xml schema |
|
| 959 | + * @param mixed $value field value |
|
| 960 | + * @return $this|\Jalle19\StatusManager\Database\Instance |
|
| 961 | + */ |
|
| 962 | + public function setByPosition($pos, $value) |
|
| 963 | + { |
|
| 964 | + switch ($pos) { |
|
| 965 | + case 0: |
|
| 966 | + $this->setName($value); |
|
| 967 | + break; |
|
| 968 | + } // switch() |
|
| 969 | + |
|
| 970 | + return $this; |
|
| 971 | + } |
|
| 972 | + |
|
| 973 | + /** |
|
| 974 | + * Populates the object using an array. |
|
| 975 | + * |
|
| 976 | + * This is particularly useful when populating an object from one of the |
|
| 977 | + * request arrays (e.g. $_POST). This method goes through the column |
|
| 978 | + * names, checking to see whether a matching key exists in populated |
|
| 979 | + * array. If so the setByName() method is called for that column. |
|
| 980 | + * |
|
| 981 | + * You can specify the key type of the array by additionally passing one |
|
| 982 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 983 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 984 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 985 | + * |
|
| 986 | + * @param array $arr An array to populate the object from. |
|
| 987 | + * @param string $keyType The type of keys the array uses. |
|
| 988 | + * @return void |
|
| 989 | + */ |
|
| 990 | + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 991 | + { |
|
| 992 | + $keys = InstanceTableMap::getFieldNames($keyType); |
|
| 993 | + |
|
| 994 | + if (array_key_exists($keys[0], $arr)) { |
|
| 995 | + $this->setName($arr[$keys[0]]); |
|
| 996 | + } |
|
| 997 | + } |
|
| 998 | + |
|
| 999 | + /** |
|
| 1000 | + * Populate the current object from a string, using a given parser format |
|
| 1001 | + * <code> |
|
| 1002 | + * $book = new Book(); |
|
| 1003 | + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 1004 | + * </code> |
|
| 1005 | + * |
|
| 1006 | + * You can specify the key type of the array by additionally passing one |
|
| 1007 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1008 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1009 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1010 | + * |
|
| 1011 | + * @param mixed $parser A AbstractParser instance, |
|
| 1012 | + * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 1013 | + * @param string $data The source data to import from |
|
| 1014 | + * @param string $keyType The type of keys the array uses. |
|
| 1015 | + * |
|
| 1016 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object, for fluid interface |
|
| 1017 | + */ |
|
| 1018 | + public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1019 | + { |
|
| 1020 | + if (!$parser instanceof AbstractParser) { |
|
| 1021 | + $parser = AbstractParser::getParser($parser); |
|
| 1022 | + } |
|
| 1023 | + |
|
| 1024 | + $this->fromArray($parser->toArray($data), $keyType); |
|
| 1025 | + |
|
| 1026 | + return $this; |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + /** |
|
| 1030 | + * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1031 | + * |
|
| 1032 | + * @return Criteria The Criteria object containing all modified values. |
|
| 1033 | + */ |
|
| 1034 | + public function buildCriteria() |
|
| 1035 | + { |
|
| 1036 | + $criteria = new Criteria(InstanceTableMap::DATABASE_NAME); |
|
| 1037 | + |
|
| 1038 | + if ($this->isColumnModified(InstanceTableMap::COL_NAME)) { |
|
| 1039 | + $criteria->add(InstanceTableMap::COL_NAME, $this->name); |
|
| 1040 | + } |
|
| 1041 | + |
|
| 1042 | + return $criteria; |
|
| 1043 | + } |
|
| 1044 | + |
|
| 1045 | + /** |
|
| 1046 | + * Builds a Criteria object containing the primary key for this object. |
|
| 1047 | + * |
|
| 1048 | + * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1049 | + * of whether or not they have been modified. |
|
| 1050 | + * |
|
| 1051 | + * @throws LogicException if no primary key is defined |
|
| 1052 | + * |
|
| 1053 | + * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1054 | + */ |
|
| 1055 | + public function buildPkeyCriteria() |
|
| 1056 | + { |
|
| 1057 | + $criteria = ChildInstanceQuery::create(); |
|
| 1058 | + $criteria->add(InstanceTableMap::COL_NAME, $this->name); |
|
| 1059 | + |
|
| 1060 | + return $criteria; |
|
| 1061 | + } |
|
| 1062 | + |
|
| 1063 | + /** |
|
| 1064 | + * If the primary key is not null, return the hashcode of the |
|
| 1065 | + * primary key. Otherwise, return the hash code of the object. |
|
| 1066 | + * |
|
| 1067 | + * @return int Hashcode |
|
| 1068 | + */ |
|
| 1069 | + public function hashCode() |
|
| 1070 | + { |
|
| 1071 | + $validPk = null !== $this->getName(); |
|
| 1072 | + |
|
| 1073 | + $validPrimaryKeyFKs = 0; |
|
| 1074 | + $primaryKeyFKs = []; |
|
| 1075 | + |
|
| 1076 | + if ($validPk) { |
|
| 1077 | + return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1078 | + } elseif ($validPrimaryKeyFKs) { |
|
| 1079 | + return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + return spl_object_hash($this); |
|
| 1083 | + } |
|
| 1084 | + |
|
| 1085 | + /** |
|
| 1086 | + * Returns the primary key for this object (row). |
|
| 1087 | + * @return string |
|
| 1088 | + */ |
|
| 1089 | + public function getPrimaryKey() |
|
| 1090 | + { |
|
| 1091 | + return $this->getName(); |
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + /** |
|
| 1095 | + * Generic method to set the primary key (name column). |
|
| 1096 | + * |
|
| 1097 | + * @param string $key Primary key. |
|
| 1098 | + * @return void |
|
| 1099 | + */ |
|
| 1100 | + public function setPrimaryKey($key) |
|
| 1101 | + { |
|
| 1102 | + $this->setName($key); |
|
| 1103 | + } |
|
| 1104 | + |
|
| 1105 | + /** |
|
| 1106 | + * Returns true if the primary key for this object is null. |
|
| 1107 | + * @return boolean |
|
| 1108 | + */ |
|
| 1109 | + public function isPrimaryKeyNull() |
|
| 1110 | + { |
|
| 1111 | + return null === $this->getName(); |
|
| 1112 | + } |
|
| 1113 | + |
|
| 1114 | + /** |
|
| 1115 | + * Sets contents of passed object to values from current object. |
|
| 1116 | + * |
|
| 1117 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1118 | + * objects. |
|
| 1119 | + * |
|
| 1120 | + * @param object $copyObj An object of \Jalle19\StatusManager\Database\Instance (or compatible) type. |
|
| 1121 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1122 | + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1123 | + * @throws PropelException |
|
| 1124 | + */ |
|
| 1125 | + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1126 | + { |
|
| 1127 | + $copyObj->setName($this->getName()); |
|
| 1128 | + |
|
| 1129 | + if ($deepCopy) { |
|
| 1130 | + // important: temporarily setNew(false) because this affects the behavior of |
|
| 1131 | + // the getter/setter methods for fkey referrer objects. |
|
| 1132 | + $copyObj->setNew(false); |
|
| 1133 | + |
|
| 1134 | + foreach ($this->getUsers() as $relObj) { |
|
| 1135 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1136 | + $copyObj->addUser($relObj->copy($deepCopy)); |
|
| 1137 | + } |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + foreach ($this->getConnections() as $relObj) { |
|
| 1141 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1142 | + $copyObj->addConnection($relObj->copy($deepCopy)); |
|
| 1143 | + } |
|
| 1144 | + } |
|
| 1145 | + |
|
| 1146 | + foreach ($this->getInputs() as $relObj) { |
|
| 1147 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1148 | + $copyObj->addInput($relObj->copy($deepCopy)); |
|
| 1149 | + } |
|
| 1150 | + } |
|
| 1151 | + |
|
| 1152 | + foreach ($this->getChannels() as $relObj) { |
|
| 1153 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1154 | + $copyObj->addChannel($relObj->copy($deepCopy)); |
|
| 1155 | + } |
|
| 1156 | + } |
|
| 1157 | + |
|
| 1158 | + foreach ($this->getSubscriptions() as $relObj) { |
|
| 1159 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1160 | + $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1161 | + } |
|
| 1162 | + } |
|
| 1163 | + |
|
| 1164 | + } // if ($deepCopy) |
|
| 1165 | + |
|
| 1166 | + if ($makeNew) { |
|
| 1167 | + $copyObj->setNew(true); |
|
| 1168 | + } |
|
| 1169 | + } |
|
| 1170 | + |
|
| 1171 | + /** |
|
| 1172 | + * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1173 | + * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1174 | + * keys that are defined for the table. |
|
| 1175 | + * |
|
| 1176 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1177 | + * objects. |
|
| 1178 | + * |
|
| 1179 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1180 | + * @return \Jalle19\StatusManager\Database\Instance Clone of current object. |
|
| 1181 | + * @throws PropelException |
|
| 1182 | + */ |
|
| 1183 | + public function copy($deepCopy = false) |
|
| 1184 | + { |
|
| 1185 | + // we use get_class(), because this might be a subclass |
|
| 1186 | + $clazz = get_class($this); |
|
| 1187 | + $copyObj = new $clazz(); |
|
| 1188 | + $this->copyInto($copyObj, $deepCopy); |
|
| 1189 | + |
|
| 1190 | + return $copyObj; |
|
| 1191 | + } |
|
| 1192 | + |
|
| 1193 | + |
|
| 1194 | + /** |
|
| 1195 | + * Initializes a collection based on the name of a relation. |
|
| 1196 | + * Avoids crafting an 'init[$relationName]s' method name |
|
| 1197 | + * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1198 | + * |
|
| 1199 | + * @param string $relationName The name of the relation to initialize |
|
| 1200 | + * @return void |
|
| 1201 | + */ |
|
| 1202 | + public function initRelation($relationName) |
|
| 1203 | + { |
|
| 1204 | + if ('User' == $relationName) { |
|
| 1205 | + return $this->initUsers(); |
|
| 1206 | + } |
|
| 1207 | + if ('Connection' == $relationName) { |
|
| 1208 | + return $this->initConnections(); |
|
| 1209 | + } |
|
| 1210 | + if ('Input' == $relationName) { |
|
| 1211 | + return $this->initInputs(); |
|
| 1212 | + } |
|
| 1213 | + if ('Channel' == $relationName) { |
|
| 1214 | + return $this->initChannels(); |
|
| 1215 | + } |
|
| 1216 | + if ('Subscription' == $relationName) { |
|
| 1217 | + return $this->initSubscriptions(); |
|
| 1218 | + } |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + /** |
|
| 1222 | + * Clears out the collUsers collection |
|
| 1223 | + * |
|
| 1224 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1225 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1226 | + * |
|
| 1227 | + * @return void |
|
| 1228 | + * @see addUsers() |
|
| 1229 | + */ |
|
| 1230 | + public function clearUsers() |
|
| 1231 | + { |
|
| 1232 | + $this->collUsers = null; // important to set this to NULL since that means it is uninitialized |
|
| 1233 | + } |
|
| 1234 | + |
|
| 1235 | + /** |
|
| 1236 | + * Reset is the collUsers collection loaded partially. |
|
| 1237 | + */ |
|
| 1238 | + public function resetPartialUsers($v = true) |
|
| 1239 | + { |
|
| 1240 | + $this->collUsersPartial = $v; |
|
| 1241 | + } |
|
| 1242 | + |
|
| 1243 | + /** |
|
| 1244 | + * Initializes the collUsers collection. |
|
| 1245 | + * |
|
| 1246 | + * By default this just sets the collUsers collection to an empty array (like clearcollUsers()); |
|
| 1247 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1248 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1249 | + * |
|
| 1250 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1251 | + * the collection even if it is not empty |
|
| 1252 | + * |
|
| 1253 | + * @return void |
|
| 1254 | + */ |
|
| 1255 | + public function initUsers($overrideExisting = true) |
|
| 1256 | + { |
|
| 1257 | + if (null !== $this->collUsers && !$overrideExisting) { |
|
| 1258 | + return; |
|
| 1259 | + } |
|
| 1260 | + |
|
| 1261 | + $collectionClassName = UserTableMap::getTableMap()->getCollectionClassName(); |
|
| 1262 | + |
|
| 1263 | + $this->collUsers = new $collectionClassName; |
|
| 1264 | + $this->collUsers->setModel('\Jalle19\StatusManager\Database\User'); |
|
| 1265 | + } |
|
| 1266 | + |
|
| 1267 | + /** |
|
| 1268 | + * Gets an array of ChildUser objects which contain a foreign key that references this object. |
|
| 1269 | + * |
|
| 1270 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1271 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1272 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1273 | + * If this ChildInstance is new, it will return |
|
| 1274 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1275 | + * |
|
| 1276 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1277 | + * @param ConnectionInterface $con optional connection object |
|
| 1278 | + * @return ObjectCollection|ChildUser[] List of ChildUser objects |
|
| 1279 | + * @throws PropelException |
|
| 1280 | + */ |
|
| 1281 | + public function getUsers(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1282 | + { |
|
| 1283 | + $partial = $this->collUsersPartial && !$this->isNew(); |
|
| 1284 | + if (null === $this->collUsers || null !== $criteria || $partial) { |
|
| 1285 | + if ($this->isNew() && null === $this->collUsers) { |
|
| 1286 | + // return empty collection |
|
| 1287 | + $this->initUsers(); |
|
| 1288 | + } else { |
|
| 1289 | + $collUsers = ChildUserQuery::create(null, $criteria) |
|
| 1290 | + ->filterByInstance($this) |
|
| 1291 | + ->find($con); |
|
| 1292 | + |
|
| 1293 | + if (null !== $criteria) { |
|
| 1294 | + if (false !== $this->collUsersPartial && count($collUsers)) { |
|
| 1295 | + $this->initUsers(false); |
|
| 1296 | + |
|
| 1297 | + foreach ($collUsers as $obj) { |
|
| 1298 | + if (false == $this->collUsers->contains($obj)) { |
|
| 1299 | + $this->collUsers->append($obj); |
|
| 1300 | + } |
|
| 1301 | + } |
|
| 1302 | + |
|
| 1303 | + $this->collUsersPartial = true; |
|
| 1304 | + } |
|
| 1305 | + |
|
| 1306 | + return $collUsers; |
|
| 1307 | + } |
|
| 1308 | + |
|
| 1309 | + if ($partial && $this->collUsers) { |
|
| 1310 | + foreach ($this->collUsers as $obj) { |
|
| 1311 | + if ($obj->isNew()) { |
|
| 1312 | + $collUsers[] = $obj; |
|
| 1313 | + } |
|
| 1314 | + } |
|
| 1315 | + } |
|
| 1316 | + |
|
| 1317 | + $this->collUsers = $collUsers; |
|
| 1318 | + $this->collUsersPartial = false; |
|
| 1319 | + } |
|
| 1320 | + } |
|
| 1321 | + |
|
| 1322 | + return $this->collUsers; |
|
| 1323 | + } |
|
| 1324 | + |
|
| 1325 | + /** |
|
| 1326 | + * Sets a collection of ChildUser objects related by a one-to-many relationship |
|
| 1327 | + * to the current object. |
|
| 1328 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1329 | + * and new objects from the given Propel collection. |
|
| 1330 | + * |
|
| 1331 | + * @param Collection $users A Propel collection. |
|
| 1332 | + * @param ConnectionInterface $con Optional connection object |
|
| 1333 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1334 | + */ |
|
| 1335 | + public function setUsers(Collection $users, ConnectionInterface $con = null) |
|
| 1336 | + { |
|
| 1337 | + /** @var ChildUser[] $usersToDelete */ |
|
| 1338 | + $usersToDelete = $this->getUsers(new Criteria(), $con)->diff($users); |
|
| 1339 | + |
|
| 1340 | + |
|
| 1341 | + $this->usersScheduledForDeletion = $usersToDelete; |
|
| 1342 | + |
|
| 1343 | + foreach ($usersToDelete as $userRemoved) { |
|
| 1344 | + $userRemoved->setInstance(null); |
|
| 1345 | + } |
|
| 1346 | + |
|
| 1347 | + $this->collUsers = null; |
|
| 1348 | + foreach ($users as $user) { |
|
| 1349 | + $this->addUser($user); |
|
| 1350 | + } |
|
| 1351 | + |
|
| 1352 | + $this->collUsers = $users; |
|
| 1353 | + $this->collUsersPartial = false; |
|
| 1354 | + |
|
| 1355 | + return $this; |
|
| 1356 | + } |
|
| 1357 | + |
|
| 1358 | + /** |
|
| 1359 | + * Returns the number of related User objects. |
|
| 1360 | + * |
|
| 1361 | + * @param Criteria $criteria |
|
| 1362 | + * @param boolean $distinct |
|
| 1363 | + * @param ConnectionInterface $con |
|
| 1364 | + * @return int Count of related User objects. |
|
| 1365 | + * @throws PropelException |
|
| 1366 | + */ |
|
| 1367 | + public function countUsers(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1368 | + { |
|
| 1369 | + $partial = $this->collUsersPartial && !$this->isNew(); |
|
| 1370 | + if (null === $this->collUsers || null !== $criteria || $partial) { |
|
| 1371 | + if ($this->isNew() && null === $this->collUsers) { |
|
| 1372 | + return 0; |
|
| 1373 | + } |
|
| 1374 | + |
|
| 1375 | + if ($partial && !$criteria) { |
|
| 1376 | + return count($this->getUsers()); |
|
| 1377 | + } |
|
| 1378 | + |
|
| 1379 | + $query = ChildUserQuery::create(null, $criteria); |
|
| 1380 | + if ($distinct) { |
|
| 1381 | + $query->distinct(); |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + return $query |
|
| 1385 | + ->filterByInstance($this) |
|
| 1386 | + ->count($con); |
|
| 1387 | + } |
|
| 1388 | + |
|
| 1389 | + return count($this->collUsers); |
|
| 1390 | + } |
|
| 1391 | + |
|
| 1392 | + /** |
|
| 1393 | + * Method called to associate a ChildUser object to this object |
|
| 1394 | + * through the ChildUser foreign key attribute. |
|
| 1395 | + * |
|
| 1396 | + * @param ChildUser $l ChildUser |
|
| 1397 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 1398 | + */ |
|
| 1399 | + public function addUser(ChildUser $l) |
|
| 1400 | + { |
|
| 1401 | + if ($this->collUsers === null) { |
|
| 1402 | + $this->initUsers(); |
|
| 1403 | + $this->collUsersPartial = true; |
|
| 1404 | + } |
|
| 1405 | + |
|
| 1406 | + if (!$this->collUsers->contains($l)) { |
|
| 1407 | + $this->doAddUser($l); |
|
| 1408 | + |
|
| 1409 | + if ($this->usersScheduledForDeletion and $this->usersScheduledForDeletion->contains($l)) { |
|
| 1410 | + $this->usersScheduledForDeletion->remove($this->usersScheduledForDeletion->search($l)); |
|
| 1411 | + } |
|
| 1412 | + } |
|
| 1413 | + |
|
| 1414 | + return $this; |
|
| 1415 | + } |
|
| 1416 | + |
|
| 1417 | + /** |
|
| 1418 | + * @param ChildUser $user The ChildUser object to add. |
|
| 1419 | + */ |
|
| 1420 | + protected function doAddUser(ChildUser $user) |
|
| 1421 | + { |
|
| 1422 | + $this->collUsers[]= $user; |
|
| 1423 | + $user->setInstance($this); |
|
| 1424 | + } |
|
| 1425 | + |
|
| 1426 | + /** |
|
| 1427 | + * @param ChildUser $user The ChildUser object to remove. |
|
| 1428 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1429 | + */ |
|
| 1430 | + public function removeUser(ChildUser $user) |
|
| 1431 | + { |
|
| 1432 | + if ($this->getUsers()->contains($user)) { |
|
| 1433 | + $pos = $this->collUsers->search($user); |
|
| 1434 | + $this->collUsers->remove($pos); |
|
| 1435 | + if (null === $this->usersScheduledForDeletion) { |
|
| 1436 | + $this->usersScheduledForDeletion = clone $this->collUsers; |
|
| 1437 | + $this->usersScheduledForDeletion->clear(); |
|
| 1438 | + } |
|
| 1439 | + $this->usersScheduledForDeletion[]= clone $user; |
|
| 1440 | + $user->setInstance(null); |
|
| 1441 | + } |
|
| 1442 | + |
|
| 1443 | + return $this; |
|
| 1444 | + } |
|
| 1445 | + |
|
| 1446 | + /** |
|
| 1447 | + * Clears out the collConnections collection |
|
| 1448 | + * |
|
| 1449 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1450 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1451 | + * |
|
| 1452 | + * @return void |
|
| 1453 | + * @see addConnections() |
|
| 1454 | + */ |
|
| 1455 | + public function clearConnections() |
|
| 1456 | + { |
|
| 1457 | + $this->collConnections = null; // important to set this to NULL since that means it is uninitialized |
|
| 1458 | + } |
|
| 1459 | + |
|
| 1460 | + /** |
|
| 1461 | + * Reset is the collConnections collection loaded partially. |
|
| 1462 | + */ |
|
| 1463 | + public function resetPartialConnections($v = true) |
|
| 1464 | + { |
|
| 1465 | + $this->collConnectionsPartial = $v; |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + /** |
|
| 1469 | + * Initializes the collConnections collection. |
|
| 1470 | + * |
|
| 1471 | + * By default this just sets the collConnections collection to an empty array (like clearcollConnections()); |
|
| 1472 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1473 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1474 | + * |
|
| 1475 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1476 | + * the collection even if it is not empty |
|
| 1477 | + * |
|
| 1478 | + * @return void |
|
| 1479 | + */ |
|
| 1480 | + public function initConnections($overrideExisting = true) |
|
| 1481 | + { |
|
| 1482 | + if (null !== $this->collConnections && !$overrideExisting) { |
|
| 1483 | + return; |
|
| 1484 | + } |
|
| 1485 | + |
|
| 1486 | + $collectionClassName = ConnectionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1487 | + |
|
| 1488 | + $this->collConnections = new $collectionClassName; |
|
| 1489 | + $this->collConnections->setModel('\Jalle19\StatusManager\Database\Connection'); |
|
| 1490 | + } |
|
| 1491 | + |
|
| 1492 | + /** |
|
| 1493 | + * Gets an array of ChildConnection objects which contain a foreign key that references this object. |
|
| 1494 | + * |
|
| 1495 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1496 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1497 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1498 | + * If this ChildInstance is new, it will return |
|
| 1499 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1500 | + * |
|
| 1501 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1502 | + * @param ConnectionInterface $con optional connection object |
|
| 1503 | + * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1504 | + * @throws PropelException |
|
| 1505 | + */ |
|
| 1506 | + public function getConnections(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1507 | + { |
|
| 1508 | + $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1509 | + if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1510 | + if ($this->isNew() && null === $this->collConnections) { |
|
| 1511 | + // return empty collection |
|
| 1512 | + $this->initConnections(); |
|
| 1513 | + } else { |
|
| 1514 | + $collConnections = ChildConnectionQuery::create(null, $criteria) |
|
| 1515 | + ->filterByInstance($this) |
|
| 1516 | + ->find($con); |
|
| 1517 | + |
|
| 1518 | + if (null !== $criteria) { |
|
| 1519 | + if (false !== $this->collConnectionsPartial && count($collConnections)) { |
|
| 1520 | + $this->initConnections(false); |
|
| 1521 | + |
|
| 1522 | + foreach ($collConnections as $obj) { |
|
| 1523 | + if (false == $this->collConnections->contains($obj)) { |
|
| 1524 | + $this->collConnections->append($obj); |
|
| 1525 | + } |
|
| 1526 | + } |
|
| 1527 | + |
|
| 1528 | + $this->collConnectionsPartial = true; |
|
| 1529 | + } |
|
| 1530 | + |
|
| 1531 | + return $collConnections; |
|
| 1532 | + } |
|
| 1533 | + |
|
| 1534 | + if ($partial && $this->collConnections) { |
|
| 1535 | + foreach ($this->collConnections as $obj) { |
|
| 1536 | + if ($obj->isNew()) { |
|
| 1537 | + $collConnections[] = $obj; |
|
| 1538 | + } |
|
| 1539 | + } |
|
| 1540 | + } |
|
| 1541 | + |
|
| 1542 | + $this->collConnections = $collConnections; |
|
| 1543 | + $this->collConnectionsPartial = false; |
|
| 1544 | + } |
|
| 1545 | + } |
|
| 1546 | + |
|
| 1547 | + return $this->collConnections; |
|
| 1548 | + } |
|
| 1549 | + |
|
| 1550 | + /** |
|
| 1551 | + * Sets a collection of ChildConnection objects related by a one-to-many relationship |
|
| 1552 | + * to the current object. |
|
| 1553 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1554 | + * and new objects from the given Propel collection. |
|
| 1555 | + * |
|
| 1556 | + * @param Collection $connections A Propel collection. |
|
| 1557 | + * @param ConnectionInterface $con Optional connection object |
|
| 1558 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1559 | + */ |
|
| 1560 | + public function setConnections(Collection $connections, ConnectionInterface $con = null) |
|
| 1561 | + { |
|
| 1562 | + /** @var ChildConnection[] $connectionsToDelete */ |
|
| 1563 | + $connectionsToDelete = $this->getConnections(new Criteria(), $con)->diff($connections); |
|
| 1564 | + |
|
| 1565 | + |
|
| 1566 | + $this->connectionsScheduledForDeletion = $connectionsToDelete; |
|
| 1567 | + |
|
| 1568 | + foreach ($connectionsToDelete as $connectionRemoved) { |
|
| 1569 | + $connectionRemoved->setInstance(null); |
|
| 1570 | + } |
|
| 1571 | + |
|
| 1572 | + $this->collConnections = null; |
|
| 1573 | + foreach ($connections as $connection) { |
|
| 1574 | + $this->addConnection($connection); |
|
| 1575 | + } |
|
| 1576 | + |
|
| 1577 | + $this->collConnections = $connections; |
|
| 1578 | + $this->collConnectionsPartial = false; |
|
| 1579 | + |
|
| 1580 | + return $this; |
|
| 1581 | + } |
|
| 1582 | + |
|
| 1583 | + /** |
|
| 1584 | + * Returns the number of related Connection objects. |
|
| 1585 | + * |
|
| 1586 | + * @param Criteria $criteria |
|
| 1587 | + * @param boolean $distinct |
|
| 1588 | + * @param ConnectionInterface $con |
|
| 1589 | + * @return int Count of related Connection objects. |
|
| 1590 | + * @throws PropelException |
|
| 1591 | + */ |
|
| 1592 | + public function countConnections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1593 | + { |
|
| 1594 | + $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1595 | + if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1596 | + if ($this->isNew() && null === $this->collConnections) { |
|
| 1597 | + return 0; |
|
| 1598 | + } |
|
| 1599 | + |
|
| 1600 | + if ($partial && !$criteria) { |
|
| 1601 | + return count($this->getConnections()); |
|
| 1602 | + } |
|
| 1603 | + |
|
| 1604 | + $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1605 | + if ($distinct) { |
|
| 1606 | + $query->distinct(); |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + return $query |
|
| 1610 | + ->filterByInstance($this) |
|
| 1611 | + ->count($con); |
|
| 1612 | + } |
|
| 1613 | + |
|
| 1614 | + return count($this->collConnections); |
|
| 1615 | + } |
|
| 1616 | + |
|
| 1617 | + /** |
|
| 1618 | + * Method called to associate a ChildConnection object to this object |
|
| 1619 | + * through the ChildConnection foreign key attribute. |
|
| 1620 | + * |
|
| 1621 | + * @param ChildConnection $l ChildConnection |
|
| 1622 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 1623 | + */ |
|
| 1624 | + public function addConnection(ChildConnection $l) |
|
| 1625 | + { |
|
| 1626 | + if ($this->collConnections === null) { |
|
| 1627 | + $this->initConnections(); |
|
| 1628 | + $this->collConnectionsPartial = true; |
|
| 1629 | + } |
|
| 1630 | + |
|
| 1631 | + if (!$this->collConnections->contains($l)) { |
|
| 1632 | + $this->doAddConnection($l); |
|
| 1633 | + |
|
| 1634 | + if ($this->connectionsScheduledForDeletion and $this->connectionsScheduledForDeletion->contains($l)) { |
|
| 1635 | + $this->connectionsScheduledForDeletion->remove($this->connectionsScheduledForDeletion->search($l)); |
|
| 1636 | + } |
|
| 1637 | + } |
|
| 1638 | + |
|
| 1639 | + return $this; |
|
| 1640 | + } |
|
| 1641 | + |
|
| 1642 | + /** |
|
| 1643 | + * @param ChildConnection $connection The ChildConnection object to add. |
|
| 1644 | + */ |
|
| 1645 | + protected function doAddConnection(ChildConnection $connection) |
|
| 1646 | + { |
|
| 1647 | + $this->collConnections[]= $connection; |
|
| 1648 | + $connection->setInstance($this); |
|
| 1649 | + } |
|
| 1650 | + |
|
| 1651 | + /** |
|
| 1652 | + * @param ChildConnection $connection The ChildConnection object to remove. |
|
| 1653 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1654 | + */ |
|
| 1655 | + public function removeConnection(ChildConnection $connection) |
|
| 1656 | + { |
|
| 1657 | + if ($this->getConnections()->contains($connection)) { |
|
| 1658 | + $pos = $this->collConnections->search($connection); |
|
| 1659 | + $this->collConnections->remove($pos); |
|
| 1660 | + if (null === $this->connectionsScheduledForDeletion) { |
|
| 1661 | + $this->connectionsScheduledForDeletion = clone $this->collConnections; |
|
| 1662 | + $this->connectionsScheduledForDeletion->clear(); |
|
| 1663 | + } |
|
| 1664 | + $this->connectionsScheduledForDeletion[]= clone $connection; |
|
| 1665 | + $connection->setInstance(null); |
|
| 1666 | + } |
|
| 1667 | + |
|
| 1668 | + return $this; |
|
| 1669 | + } |
|
| 1670 | + |
|
| 1671 | + |
|
| 1672 | + /** |
|
| 1673 | + * If this collection has already been initialized with |
|
| 1674 | + * an identical criteria, it returns the collection. |
|
| 1675 | + * Otherwise if this Instance is new, it will return |
|
| 1676 | + * an empty collection; or if this Instance has previously |
|
| 1677 | + * been saved, it will retrieve related Connections from storage. |
|
| 1678 | + * |
|
| 1679 | + * This method is protected by default in order to keep the public |
|
| 1680 | + * api reasonable. You can provide public methods for those you |
|
| 1681 | + * actually need in Instance. |
|
| 1682 | + * |
|
| 1683 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1684 | + * @param ConnectionInterface $con optional connection object |
|
| 1685 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1686 | + * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1687 | + */ |
|
| 1688 | + public function getConnectionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1689 | + { |
|
| 1690 | + $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1691 | + $query->joinWith('User', $joinBehavior); |
|
| 1692 | + |
|
| 1693 | + return $this->getConnections($query, $con); |
|
| 1694 | + } |
|
| 1695 | + |
|
| 1696 | + /** |
|
| 1697 | + * Clears out the collInputs collection |
|
| 1698 | + * |
|
| 1699 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1700 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1701 | + * |
|
| 1702 | + * @return void |
|
| 1703 | + * @see addInputs() |
|
| 1704 | + */ |
|
| 1705 | + public function clearInputs() |
|
| 1706 | + { |
|
| 1707 | + $this->collInputs = null; // important to set this to NULL since that means it is uninitialized |
|
| 1708 | + } |
|
| 1709 | + |
|
| 1710 | + /** |
|
| 1711 | + * Reset is the collInputs collection loaded partially. |
|
| 1712 | + */ |
|
| 1713 | + public function resetPartialInputs($v = true) |
|
| 1714 | + { |
|
| 1715 | + $this->collInputsPartial = $v; |
|
| 1716 | + } |
|
| 1717 | + |
|
| 1718 | + /** |
|
| 1719 | + * Initializes the collInputs collection. |
|
| 1720 | + * |
|
| 1721 | + * By default this just sets the collInputs collection to an empty array (like clearcollInputs()); |
|
| 1722 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1723 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1724 | + * |
|
| 1725 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1726 | + * the collection even if it is not empty |
|
| 1727 | + * |
|
| 1728 | + * @return void |
|
| 1729 | + */ |
|
| 1730 | + public function initInputs($overrideExisting = true) |
|
| 1731 | + { |
|
| 1732 | + if (null !== $this->collInputs && !$overrideExisting) { |
|
| 1733 | + return; |
|
| 1734 | + } |
|
| 1735 | + |
|
| 1736 | + $collectionClassName = InputTableMap::getTableMap()->getCollectionClassName(); |
|
| 1737 | + |
|
| 1738 | + $this->collInputs = new $collectionClassName; |
|
| 1739 | + $this->collInputs->setModel('\Jalle19\StatusManager\Database\Input'); |
|
| 1740 | + } |
|
| 1741 | + |
|
| 1742 | + /** |
|
| 1743 | + * Gets an array of ChildInput objects which contain a foreign key that references this object. |
|
| 1744 | + * |
|
| 1745 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1746 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1747 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1748 | + * If this ChildInstance is new, it will return |
|
| 1749 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1750 | + * |
|
| 1751 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1752 | + * @param ConnectionInterface $con optional connection object |
|
| 1753 | + * @return ObjectCollection|ChildInput[] List of ChildInput objects |
|
| 1754 | + * @throws PropelException |
|
| 1755 | + */ |
|
| 1756 | + public function getInputs(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1757 | + { |
|
| 1758 | + $partial = $this->collInputsPartial && !$this->isNew(); |
|
| 1759 | + if (null === $this->collInputs || null !== $criteria || $partial) { |
|
| 1760 | + if ($this->isNew() && null === $this->collInputs) { |
|
| 1761 | + // return empty collection |
|
| 1762 | + $this->initInputs(); |
|
| 1763 | + } else { |
|
| 1764 | + $collInputs = ChildInputQuery::create(null, $criteria) |
|
| 1765 | + ->filterByInstance($this) |
|
| 1766 | + ->find($con); |
|
| 1767 | + |
|
| 1768 | + if (null !== $criteria) { |
|
| 1769 | + if (false !== $this->collInputsPartial && count($collInputs)) { |
|
| 1770 | + $this->initInputs(false); |
|
| 1771 | + |
|
| 1772 | + foreach ($collInputs as $obj) { |
|
| 1773 | + if (false == $this->collInputs->contains($obj)) { |
|
| 1774 | + $this->collInputs->append($obj); |
|
| 1775 | + } |
|
| 1776 | + } |
|
| 1777 | + |
|
| 1778 | + $this->collInputsPartial = true; |
|
| 1779 | + } |
|
| 1780 | + |
|
| 1781 | + return $collInputs; |
|
| 1782 | + } |
|
| 1783 | + |
|
| 1784 | + if ($partial && $this->collInputs) { |
|
| 1785 | + foreach ($this->collInputs as $obj) { |
|
| 1786 | + if ($obj->isNew()) { |
|
| 1787 | + $collInputs[] = $obj; |
|
| 1788 | + } |
|
| 1789 | + } |
|
| 1790 | + } |
|
| 1791 | + |
|
| 1792 | + $this->collInputs = $collInputs; |
|
| 1793 | + $this->collInputsPartial = false; |
|
| 1794 | + } |
|
| 1795 | + } |
|
| 1796 | + |
|
| 1797 | + return $this->collInputs; |
|
| 1798 | + } |
|
| 1799 | + |
|
| 1800 | + /** |
|
| 1801 | + * Sets a collection of ChildInput objects related by a one-to-many relationship |
|
| 1802 | + * to the current object. |
|
| 1803 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1804 | + * and new objects from the given Propel collection. |
|
| 1805 | + * |
|
| 1806 | + * @param Collection $inputs A Propel collection. |
|
| 1807 | + * @param ConnectionInterface $con Optional connection object |
|
| 1808 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1809 | + */ |
|
| 1810 | + public function setInputs(Collection $inputs, ConnectionInterface $con = null) |
|
| 1811 | + { |
|
| 1812 | + /** @var ChildInput[] $inputsToDelete */ |
|
| 1813 | + $inputsToDelete = $this->getInputs(new Criteria(), $con)->diff($inputs); |
|
| 1814 | + |
|
| 1815 | + |
|
| 1816 | + $this->inputsScheduledForDeletion = $inputsToDelete; |
|
| 1817 | + |
|
| 1818 | + foreach ($inputsToDelete as $inputRemoved) { |
|
| 1819 | + $inputRemoved->setInstance(null); |
|
| 1820 | + } |
|
| 1821 | + |
|
| 1822 | + $this->collInputs = null; |
|
| 1823 | + foreach ($inputs as $input) { |
|
| 1824 | + $this->addInput($input); |
|
| 1825 | + } |
|
| 1826 | + |
|
| 1827 | + $this->collInputs = $inputs; |
|
| 1828 | + $this->collInputsPartial = false; |
|
| 1829 | + |
|
| 1830 | + return $this; |
|
| 1831 | + } |
|
| 1832 | + |
|
| 1833 | + /** |
|
| 1834 | + * Returns the number of related Input objects. |
|
| 1835 | + * |
|
| 1836 | + * @param Criteria $criteria |
|
| 1837 | + * @param boolean $distinct |
|
| 1838 | + * @param ConnectionInterface $con |
|
| 1839 | + * @return int Count of related Input objects. |
|
| 1840 | + * @throws PropelException |
|
| 1841 | + */ |
|
| 1842 | + public function countInputs(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1843 | + { |
|
| 1844 | + $partial = $this->collInputsPartial && !$this->isNew(); |
|
| 1845 | + if (null === $this->collInputs || null !== $criteria || $partial) { |
|
| 1846 | + if ($this->isNew() && null === $this->collInputs) { |
|
| 1847 | + return 0; |
|
| 1848 | + } |
|
| 1849 | + |
|
| 1850 | + if ($partial && !$criteria) { |
|
| 1851 | + return count($this->getInputs()); |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + $query = ChildInputQuery::create(null, $criteria); |
|
| 1855 | + if ($distinct) { |
|
| 1856 | + $query->distinct(); |
|
| 1857 | + } |
|
| 1858 | + |
|
| 1859 | + return $query |
|
| 1860 | + ->filterByInstance($this) |
|
| 1861 | + ->count($con); |
|
| 1862 | + } |
|
| 1863 | + |
|
| 1864 | + return count($this->collInputs); |
|
| 1865 | + } |
|
| 1866 | + |
|
| 1867 | + /** |
|
| 1868 | + * Method called to associate a ChildInput object to this object |
|
| 1869 | + * through the ChildInput foreign key attribute. |
|
| 1870 | + * |
|
| 1871 | + * @param ChildInput $l ChildInput |
|
| 1872 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 1873 | + */ |
|
| 1874 | + public function addInput(ChildInput $l) |
|
| 1875 | + { |
|
| 1876 | + if ($this->collInputs === null) { |
|
| 1877 | + $this->initInputs(); |
|
| 1878 | + $this->collInputsPartial = true; |
|
| 1879 | + } |
|
| 1880 | + |
|
| 1881 | + if (!$this->collInputs->contains($l)) { |
|
| 1882 | + $this->doAddInput($l); |
|
| 1883 | + |
|
| 1884 | + if ($this->inputsScheduledForDeletion and $this->inputsScheduledForDeletion->contains($l)) { |
|
| 1885 | + $this->inputsScheduledForDeletion->remove($this->inputsScheduledForDeletion->search($l)); |
|
| 1886 | + } |
|
| 1887 | + } |
|
| 1888 | + |
|
| 1889 | + return $this; |
|
| 1890 | + } |
|
| 1891 | + |
|
| 1892 | + /** |
|
| 1893 | + * @param ChildInput $input The ChildInput object to add. |
|
| 1894 | + */ |
|
| 1895 | + protected function doAddInput(ChildInput $input) |
|
| 1896 | + { |
|
| 1897 | + $this->collInputs[]= $input; |
|
| 1898 | + $input->setInstance($this); |
|
| 1899 | + } |
|
| 1900 | + |
|
| 1901 | + /** |
|
| 1902 | + * @param ChildInput $input The ChildInput object to remove. |
|
| 1903 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 1904 | + */ |
|
| 1905 | + public function removeInput(ChildInput $input) |
|
| 1906 | + { |
|
| 1907 | + if ($this->getInputs()->contains($input)) { |
|
| 1908 | + $pos = $this->collInputs->search($input); |
|
| 1909 | + $this->collInputs->remove($pos); |
|
| 1910 | + if (null === $this->inputsScheduledForDeletion) { |
|
| 1911 | + $this->inputsScheduledForDeletion = clone $this->collInputs; |
|
| 1912 | + $this->inputsScheduledForDeletion->clear(); |
|
| 1913 | + } |
|
| 1914 | + $this->inputsScheduledForDeletion[]= clone $input; |
|
| 1915 | + $input->setInstance(null); |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + return $this; |
|
| 1919 | + } |
|
| 1920 | + |
|
| 1921 | + /** |
|
| 1922 | + * Clears out the collChannels collection |
|
| 1923 | + * |
|
| 1924 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1925 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1926 | + * |
|
| 1927 | + * @return void |
|
| 1928 | + * @see addChannels() |
|
| 1929 | + */ |
|
| 1930 | + public function clearChannels() |
|
| 1931 | + { |
|
| 1932 | + $this->collChannels = null; // important to set this to NULL since that means it is uninitialized |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + /** |
|
| 1936 | + * Reset is the collChannels collection loaded partially. |
|
| 1937 | + */ |
|
| 1938 | + public function resetPartialChannels($v = true) |
|
| 1939 | + { |
|
| 1940 | + $this->collChannelsPartial = $v; |
|
| 1941 | + } |
|
| 1942 | + |
|
| 1943 | + /** |
|
| 1944 | + * Initializes the collChannels collection. |
|
| 1945 | + * |
|
| 1946 | + * By default this just sets the collChannels collection to an empty array (like clearcollChannels()); |
|
| 1947 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1948 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1949 | + * |
|
| 1950 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1951 | + * the collection even if it is not empty |
|
| 1952 | + * |
|
| 1953 | + * @return void |
|
| 1954 | + */ |
|
| 1955 | + public function initChannels($overrideExisting = true) |
|
| 1956 | + { |
|
| 1957 | + if (null !== $this->collChannels && !$overrideExisting) { |
|
| 1958 | + return; |
|
| 1959 | + } |
|
| 1960 | + |
|
| 1961 | + $collectionClassName = ChannelTableMap::getTableMap()->getCollectionClassName(); |
|
| 1962 | + |
|
| 1963 | + $this->collChannels = new $collectionClassName; |
|
| 1964 | + $this->collChannels->setModel('\Jalle19\StatusManager\Database\Channel'); |
|
| 1965 | + } |
|
| 1966 | + |
|
| 1967 | + /** |
|
| 1968 | + * Gets an array of ChildChannel objects which contain a foreign key that references this object. |
|
| 1969 | + * |
|
| 1970 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1971 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1972 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1973 | + * If this ChildInstance is new, it will return |
|
| 1974 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1975 | + * |
|
| 1976 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1977 | + * @param ConnectionInterface $con optional connection object |
|
| 1978 | + * @return ObjectCollection|ChildChannel[] List of ChildChannel objects |
|
| 1979 | + * @throws PropelException |
|
| 1980 | + */ |
|
| 1981 | + public function getChannels(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1982 | + { |
|
| 1983 | + $partial = $this->collChannelsPartial && !$this->isNew(); |
|
| 1984 | + if (null === $this->collChannels || null !== $criteria || $partial) { |
|
| 1985 | + if ($this->isNew() && null === $this->collChannels) { |
|
| 1986 | + // return empty collection |
|
| 1987 | + $this->initChannels(); |
|
| 1988 | + } else { |
|
| 1989 | + $collChannels = ChildChannelQuery::create(null, $criteria) |
|
| 1990 | + ->filterByInstance($this) |
|
| 1991 | + ->find($con); |
|
| 1992 | + |
|
| 1993 | + if (null !== $criteria) { |
|
| 1994 | + if (false !== $this->collChannelsPartial && count($collChannels)) { |
|
| 1995 | + $this->initChannels(false); |
|
| 1996 | + |
|
| 1997 | + foreach ($collChannels as $obj) { |
|
| 1998 | + if (false == $this->collChannels->contains($obj)) { |
|
| 1999 | + $this->collChannels->append($obj); |
|
| 2000 | + } |
|
| 2001 | + } |
|
| 2002 | + |
|
| 2003 | + $this->collChannelsPartial = true; |
|
| 2004 | + } |
|
| 2005 | + |
|
| 2006 | + return $collChannels; |
|
| 2007 | + } |
|
| 2008 | + |
|
| 2009 | + if ($partial && $this->collChannels) { |
|
| 2010 | + foreach ($this->collChannels as $obj) { |
|
| 2011 | + if ($obj->isNew()) { |
|
| 2012 | + $collChannels[] = $obj; |
|
| 2013 | + } |
|
| 2014 | + } |
|
| 2015 | + } |
|
| 2016 | + |
|
| 2017 | + $this->collChannels = $collChannels; |
|
| 2018 | + $this->collChannelsPartial = false; |
|
| 2019 | + } |
|
| 2020 | + } |
|
| 2021 | + |
|
| 2022 | + return $this->collChannels; |
|
| 2023 | + } |
|
| 2024 | + |
|
| 2025 | + /** |
|
| 2026 | + * Sets a collection of ChildChannel objects related by a one-to-many relationship |
|
| 2027 | + * to the current object. |
|
| 2028 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 2029 | + * and new objects from the given Propel collection. |
|
| 2030 | + * |
|
| 2031 | + * @param Collection $channels A Propel collection. |
|
| 2032 | + * @param ConnectionInterface $con Optional connection object |
|
| 2033 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2034 | + */ |
|
| 2035 | + public function setChannels(Collection $channels, ConnectionInterface $con = null) |
|
| 2036 | + { |
|
| 2037 | + /** @var ChildChannel[] $channelsToDelete */ |
|
| 2038 | + $channelsToDelete = $this->getChannels(new Criteria(), $con)->diff($channels); |
|
| 2039 | + |
|
| 2040 | + |
|
| 2041 | + $this->channelsScheduledForDeletion = $channelsToDelete; |
|
| 2042 | + |
|
| 2043 | + foreach ($channelsToDelete as $channelRemoved) { |
|
| 2044 | + $channelRemoved->setInstance(null); |
|
| 2045 | + } |
|
| 2046 | + |
|
| 2047 | + $this->collChannels = null; |
|
| 2048 | + foreach ($channels as $channel) { |
|
| 2049 | + $this->addChannel($channel); |
|
| 2050 | + } |
|
| 2051 | + |
|
| 2052 | + $this->collChannels = $channels; |
|
| 2053 | + $this->collChannelsPartial = false; |
|
| 2054 | + |
|
| 2055 | + return $this; |
|
| 2056 | + } |
|
| 2057 | + |
|
| 2058 | + /** |
|
| 2059 | + * Returns the number of related Channel objects. |
|
| 2060 | + * |
|
| 2061 | + * @param Criteria $criteria |
|
| 2062 | + * @param boolean $distinct |
|
| 2063 | + * @param ConnectionInterface $con |
|
| 2064 | + * @return int Count of related Channel objects. |
|
| 2065 | + * @throws PropelException |
|
| 2066 | + */ |
|
| 2067 | + public function countChannels(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 2068 | + { |
|
| 2069 | + $partial = $this->collChannelsPartial && !$this->isNew(); |
|
| 2070 | + if (null === $this->collChannels || null !== $criteria || $partial) { |
|
| 2071 | + if ($this->isNew() && null === $this->collChannels) { |
|
| 2072 | + return 0; |
|
| 2073 | + } |
|
| 2074 | + |
|
| 2075 | + if ($partial && !$criteria) { |
|
| 2076 | + return count($this->getChannels()); |
|
| 2077 | + } |
|
| 2078 | + |
|
| 2079 | + $query = ChildChannelQuery::create(null, $criteria); |
|
| 2080 | + if ($distinct) { |
|
| 2081 | + $query->distinct(); |
|
| 2082 | + } |
|
| 2083 | + |
|
| 2084 | + return $query |
|
| 2085 | + ->filterByInstance($this) |
|
| 2086 | + ->count($con); |
|
| 2087 | + } |
|
| 2088 | + |
|
| 2089 | + return count($this->collChannels); |
|
| 2090 | + } |
|
| 2091 | + |
|
| 2092 | + /** |
|
| 2093 | + * Method called to associate a ChildChannel object to this object |
|
| 2094 | + * through the ChildChannel foreign key attribute. |
|
| 2095 | + * |
|
| 2096 | + * @param ChildChannel $l ChildChannel |
|
| 2097 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 2098 | + */ |
|
| 2099 | + public function addChannel(ChildChannel $l) |
|
| 2100 | + { |
|
| 2101 | + if ($this->collChannels === null) { |
|
| 2102 | + $this->initChannels(); |
|
| 2103 | + $this->collChannelsPartial = true; |
|
| 2104 | + } |
|
| 2105 | + |
|
| 2106 | + if (!$this->collChannels->contains($l)) { |
|
| 2107 | + $this->doAddChannel($l); |
|
| 2108 | + |
|
| 2109 | + if ($this->channelsScheduledForDeletion and $this->channelsScheduledForDeletion->contains($l)) { |
|
| 2110 | + $this->channelsScheduledForDeletion->remove($this->channelsScheduledForDeletion->search($l)); |
|
| 2111 | + } |
|
| 2112 | + } |
|
| 2113 | + |
|
| 2114 | + return $this; |
|
| 2115 | + } |
|
| 2116 | + |
|
| 2117 | + /** |
|
| 2118 | + * @param ChildChannel $channel The ChildChannel object to add. |
|
| 2119 | + */ |
|
| 2120 | + protected function doAddChannel(ChildChannel $channel) |
|
| 2121 | + { |
|
| 2122 | + $this->collChannels[]= $channel; |
|
| 2123 | + $channel->setInstance($this); |
|
| 2124 | + } |
|
| 2125 | + |
|
| 2126 | + /** |
|
| 2127 | + * @param ChildChannel $channel The ChildChannel object to remove. |
|
| 2128 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2129 | + */ |
|
| 2130 | + public function removeChannel(ChildChannel $channel) |
|
| 2131 | + { |
|
| 2132 | + if ($this->getChannels()->contains($channel)) { |
|
| 2133 | + $pos = $this->collChannels->search($channel); |
|
| 2134 | + $this->collChannels->remove($pos); |
|
| 2135 | + if (null === $this->channelsScheduledForDeletion) { |
|
| 2136 | + $this->channelsScheduledForDeletion = clone $this->collChannels; |
|
| 2137 | + $this->channelsScheduledForDeletion->clear(); |
|
| 2138 | + } |
|
| 2139 | + $this->channelsScheduledForDeletion[]= clone $channel; |
|
| 2140 | + $channel->setInstance(null); |
|
| 2141 | + } |
|
| 2142 | + |
|
| 2143 | + return $this; |
|
| 2144 | + } |
|
| 2145 | + |
|
| 2146 | + /** |
|
| 2147 | + * Clears out the collSubscriptions collection |
|
| 2148 | + * |
|
| 2149 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 2150 | + * them to be refetched by subsequent calls to accessor method. |
|
| 2151 | + * |
|
| 2152 | + * @return void |
|
| 2153 | + * @see addSubscriptions() |
|
| 2154 | + */ |
|
| 2155 | + public function clearSubscriptions() |
|
| 2156 | + { |
|
| 2157 | + $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 2158 | + } |
|
| 2159 | + |
|
| 2160 | + /** |
|
| 2161 | + * Reset is the collSubscriptions collection loaded partially. |
|
| 2162 | + */ |
|
| 2163 | + public function resetPartialSubscriptions($v = true) |
|
| 2164 | + { |
|
| 2165 | + $this->collSubscriptionsPartial = $v; |
|
| 2166 | + } |
|
| 2167 | + |
|
| 2168 | + /** |
|
| 2169 | + * Initializes the collSubscriptions collection. |
|
| 2170 | + * |
|
| 2171 | + * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 2172 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 2173 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 2174 | + * |
|
| 2175 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 2176 | + * the collection even if it is not empty |
|
| 2177 | + * |
|
| 2178 | + * @return void |
|
| 2179 | + */ |
|
| 2180 | + public function initSubscriptions($overrideExisting = true) |
|
| 2181 | + { |
|
| 2182 | + if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 2183 | + return; |
|
| 2184 | + } |
|
| 2185 | + |
|
| 2186 | + $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 2187 | + |
|
| 2188 | + $this->collSubscriptions = new $collectionClassName; |
|
| 2189 | + $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 2190 | + } |
|
| 2191 | + |
|
| 2192 | + /** |
|
| 2193 | + * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 2194 | + * |
|
| 2195 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 2196 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 2197 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 2198 | + * If this ChildInstance is new, it will return |
|
| 2199 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 2200 | + * |
|
| 2201 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2202 | + * @param ConnectionInterface $con optional connection object |
|
| 2203 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2204 | + * @throws PropelException |
|
| 2205 | + */ |
|
| 2206 | + public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 2207 | + { |
|
| 2208 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 2209 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 2210 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 2211 | + // return empty collection |
|
| 2212 | + $this->initSubscriptions(); |
|
| 2213 | + } else { |
|
| 2214 | + $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 2215 | + ->filterByInstance($this) |
|
| 2216 | + ->find($con); |
|
| 2217 | + |
|
| 2218 | + if (null !== $criteria) { |
|
| 2219 | + if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 2220 | + $this->initSubscriptions(false); |
|
| 2221 | + |
|
| 2222 | + foreach ($collSubscriptions as $obj) { |
|
| 2223 | + if (false == $this->collSubscriptions->contains($obj)) { |
|
| 2224 | + $this->collSubscriptions->append($obj); |
|
| 2225 | + } |
|
| 2226 | + } |
|
| 2227 | + |
|
| 2228 | + $this->collSubscriptionsPartial = true; |
|
| 2229 | + } |
|
| 2230 | + |
|
| 2231 | + return $collSubscriptions; |
|
| 2232 | + } |
|
| 2233 | + |
|
| 2234 | + if ($partial && $this->collSubscriptions) { |
|
| 2235 | + foreach ($this->collSubscriptions as $obj) { |
|
| 2236 | + if ($obj->isNew()) { |
|
| 2237 | + $collSubscriptions[] = $obj; |
|
| 2238 | + } |
|
| 2239 | + } |
|
| 2240 | + } |
|
| 2241 | + |
|
| 2242 | + $this->collSubscriptions = $collSubscriptions; |
|
| 2243 | + $this->collSubscriptionsPartial = false; |
|
| 2244 | + } |
|
| 2245 | + } |
|
| 2246 | + |
|
| 2247 | + return $this->collSubscriptions; |
|
| 2248 | + } |
|
| 2249 | + |
|
| 2250 | + /** |
|
| 2251 | + * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 2252 | + * to the current object. |
|
| 2253 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 2254 | + * and new objects from the given Propel collection. |
|
| 2255 | + * |
|
| 2256 | + * @param Collection $subscriptions A Propel collection. |
|
| 2257 | + * @param ConnectionInterface $con Optional connection object |
|
| 2258 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2259 | + */ |
|
| 2260 | + public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 2261 | + { |
|
| 2262 | + /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 2263 | + $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 2264 | + |
|
| 2265 | + |
|
| 2266 | + $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 2267 | + |
|
| 2268 | + foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 2269 | + $subscriptionRemoved->setInstance(null); |
|
| 2270 | + } |
|
| 2271 | + |
|
| 2272 | + $this->collSubscriptions = null; |
|
| 2273 | + foreach ($subscriptions as $subscription) { |
|
| 2274 | + $this->addSubscription($subscription); |
|
| 2275 | + } |
|
| 2276 | + |
|
| 2277 | + $this->collSubscriptions = $subscriptions; |
|
| 2278 | + $this->collSubscriptionsPartial = false; |
|
| 2279 | + |
|
| 2280 | + return $this; |
|
| 2281 | + } |
|
| 2282 | + |
|
| 2283 | + /** |
|
| 2284 | + * Returns the number of related Subscription objects. |
|
| 2285 | + * |
|
| 2286 | + * @param Criteria $criteria |
|
| 2287 | + * @param boolean $distinct |
|
| 2288 | + * @param ConnectionInterface $con |
|
| 2289 | + * @return int Count of related Subscription objects. |
|
| 2290 | + * @throws PropelException |
|
| 2291 | + */ |
|
| 2292 | + public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 2293 | + { |
|
| 2294 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 2295 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 2296 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 2297 | + return 0; |
|
| 2298 | + } |
|
| 2299 | + |
|
| 2300 | + if ($partial && !$criteria) { |
|
| 2301 | + return count($this->getSubscriptions()); |
|
| 2302 | + } |
|
| 2303 | + |
|
| 2304 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2305 | + if ($distinct) { |
|
| 2306 | + $query->distinct(); |
|
| 2307 | + } |
|
| 2308 | + |
|
| 2309 | + return $query |
|
| 2310 | + ->filterByInstance($this) |
|
| 2311 | + ->count($con); |
|
| 2312 | + } |
|
| 2313 | + |
|
| 2314 | + return count($this->collSubscriptions); |
|
| 2315 | + } |
|
| 2316 | + |
|
| 2317 | + /** |
|
| 2318 | + * Method called to associate a ChildSubscription object to this object |
|
| 2319 | + * through the ChildSubscription foreign key attribute. |
|
| 2320 | + * |
|
| 2321 | + * @param ChildSubscription $l ChildSubscription |
|
| 2322 | + * @return $this|\Jalle19\StatusManager\Database\Instance The current object (for fluent API support) |
|
| 2323 | + */ |
|
| 2324 | + public function addSubscription(ChildSubscription $l) |
|
| 2325 | + { |
|
| 2326 | + if ($this->collSubscriptions === null) { |
|
| 2327 | + $this->initSubscriptions(); |
|
| 2328 | + $this->collSubscriptionsPartial = true; |
|
| 2329 | + } |
|
| 2330 | + |
|
| 2331 | + if (!$this->collSubscriptions->contains($l)) { |
|
| 2332 | + $this->doAddSubscription($l); |
|
| 2333 | + |
|
| 2334 | + if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 2335 | + $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 2336 | + } |
|
| 2337 | + } |
|
| 2338 | + |
|
| 2339 | + return $this; |
|
| 2340 | + } |
|
| 2341 | + |
|
| 2342 | + /** |
|
| 2343 | + * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 2344 | + */ |
|
| 2345 | + protected function doAddSubscription(ChildSubscription $subscription) |
|
| 2346 | + { |
|
| 2347 | + $this->collSubscriptions[]= $subscription; |
|
| 2348 | + $subscription->setInstance($this); |
|
| 2349 | + } |
|
| 2350 | + |
|
| 2351 | + /** |
|
| 2352 | + * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 2353 | + * @return $this|ChildInstance The current object (for fluent API support) |
|
| 2354 | + */ |
|
| 2355 | + public function removeSubscription(ChildSubscription $subscription) |
|
| 2356 | + { |
|
| 2357 | + if ($this->getSubscriptions()->contains($subscription)) { |
|
| 2358 | + $pos = $this->collSubscriptions->search($subscription); |
|
| 2359 | + $this->collSubscriptions->remove($pos); |
|
| 2360 | + if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 2361 | + $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 2362 | + $this->subscriptionsScheduledForDeletion->clear(); |
|
| 2363 | + } |
|
| 2364 | + $this->subscriptionsScheduledForDeletion[]= clone $subscription; |
|
| 2365 | + $subscription->setInstance(null); |
|
| 2366 | + } |
|
| 2367 | + |
|
| 2368 | + return $this; |
|
| 2369 | + } |
|
| 2370 | + |
|
| 2371 | + |
|
| 2372 | + /** |
|
| 2373 | + * If this collection has already been initialized with |
|
| 2374 | + * an identical criteria, it returns the collection. |
|
| 2375 | + * Otherwise if this Instance is new, it will return |
|
| 2376 | + * an empty collection; or if this Instance has previously |
|
| 2377 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 2378 | + * |
|
| 2379 | + * This method is protected by default in order to keep the public |
|
| 2380 | + * api reasonable. You can provide public methods for those you |
|
| 2381 | + * actually need in Instance. |
|
| 2382 | + * |
|
| 2383 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2384 | + * @param ConnectionInterface $con optional connection object |
|
| 2385 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 2386 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2387 | + */ |
|
| 2388 | + public function getSubscriptionsJoinInput(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 2389 | + { |
|
| 2390 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2391 | + $query->joinWith('Input', $joinBehavior); |
|
| 2392 | + |
|
| 2393 | + return $this->getSubscriptions($query, $con); |
|
| 2394 | + } |
|
| 2395 | + |
|
| 2396 | + |
|
| 2397 | + /** |
|
| 2398 | + * If this collection has already been initialized with |
|
| 2399 | + * an identical criteria, it returns the collection. |
|
| 2400 | + * Otherwise if this Instance is new, it will return |
|
| 2401 | + * an empty collection; or if this Instance has previously |
|
| 2402 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 2403 | + * |
|
| 2404 | + * This method is protected by default in order to keep the public |
|
| 2405 | + * api reasonable. You can provide public methods for those you |
|
| 2406 | + * actually need in Instance. |
|
| 2407 | + * |
|
| 2408 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2409 | + * @param ConnectionInterface $con optional connection object |
|
| 2410 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 2411 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2412 | + */ |
|
| 2413 | + public function getSubscriptionsJoinUser(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 2414 | + { |
|
| 2415 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2416 | + $query->joinWith('User', $joinBehavior); |
|
| 2417 | + |
|
| 2418 | + return $this->getSubscriptions($query, $con); |
|
| 2419 | + } |
|
| 2420 | + |
|
| 2421 | + |
|
| 2422 | + /** |
|
| 2423 | + * If this collection has already been initialized with |
|
| 2424 | + * an identical criteria, it returns the collection. |
|
| 2425 | + * Otherwise if this Instance is new, it will return |
|
| 2426 | + * an empty collection; or if this Instance has previously |
|
| 2427 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 2428 | + * |
|
| 2429 | + * This method is protected by default in order to keep the public |
|
| 2430 | + * api reasonable. You can provide public methods for those you |
|
| 2431 | + * actually need in Instance. |
|
| 2432 | + * |
|
| 2433 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 2434 | + * @param ConnectionInterface $con optional connection object |
|
| 2435 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 2436 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 2437 | + */ |
|
| 2438 | + public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 2439 | + { |
|
| 2440 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 2441 | + $query->joinWith('Channel', $joinBehavior); |
|
| 2442 | + |
|
| 2443 | + return $this->getSubscriptions($query, $con); |
|
| 2444 | + } |
|
| 2445 | + |
|
| 2446 | + /** |
|
| 2447 | + * Clears the current object, sets all attributes to their default values and removes |
|
| 2448 | + * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 2449 | + * change of those foreign objects when you call `save` there). |
|
| 2450 | + */ |
|
| 2451 | + public function clear() |
|
| 2452 | + { |
|
| 2453 | + $this->name = null; |
|
| 2454 | + $this->alreadyInSave = false; |
|
| 2455 | + $this->clearAllReferences(); |
|
| 2456 | + $this->resetModified(); |
|
| 2457 | + $this->setNew(true); |
|
| 2458 | + $this->setDeleted(false); |
|
| 2459 | + } |
|
| 2460 | + |
|
| 2461 | + /** |
|
| 2462 | + * Resets all references and back-references to other model objects or collections of model objects. |
|
| 2463 | + * |
|
| 2464 | + * This method is used to reset all php object references (not the actual reference in the database). |
|
| 2465 | + * Necessary for object serialisation. |
|
| 2466 | + * |
|
| 2467 | + * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 2468 | + */ |
|
| 2469 | + public function clearAllReferences($deep = false) |
|
| 2470 | + { |
|
| 2471 | + if ($deep) { |
|
| 2472 | + if ($this->collUsers) { |
|
| 2473 | + foreach ($this->collUsers as $o) { |
|
| 2474 | + $o->clearAllReferences($deep); |
|
| 2475 | + } |
|
| 2476 | + } |
|
| 2477 | + if ($this->collConnections) { |
|
| 2478 | + foreach ($this->collConnections as $o) { |
|
| 2479 | + $o->clearAllReferences($deep); |
|
| 2480 | + } |
|
| 2481 | + } |
|
| 2482 | + if ($this->collInputs) { |
|
| 2483 | + foreach ($this->collInputs as $o) { |
|
| 2484 | + $o->clearAllReferences($deep); |
|
| 2485 | + } |
|
| 2486 | + } |
|
| 2487 | + if ($this->collChannels) { |
|
| 2488 | + foreach ($this->collChannels as $o) { |
|
| 2489 | + $o->clearAllReferences($deep); |
|
| 2490 | + } |
|
| 2491 | + } |
|
| 2492 | + if ($this->collSubscriptions) { |
|
| 2493 | + foreach ($this->collSubscriptions as $o) { |
|
| 2494 | + $o->clearAllReferences($deep); |
|
| 2495 | + } |
|
| 2496 | + } |
|
| 2497 | + } // if ($deep) |
|
| 2498 | + |
|
| 2499 | + $this->collUsers = null; |
|
| 2500 | + $this->collConnections = null; |
|
| 2501 | + $this->collInputs = null; |
|
| 2502 | + $this->collChannels = null; |
|
| 2503 | + $this->collSubscriptions = null; |
|
| 2504 | + } |
|
| 2505 | + |
|
| 2506 | + /** |
|
| 2507 | + * Return the string representation of this object |
|
| 2508 | + * |
|
| 2509 | + * @return string |
|
| 2510 | + */ |
|
| 2511 | + public function __toString() |
|
| 2512 | + { |
|
| 2513 | + return (string) $this->exportTo(InstanceTableMap::DEFAULT_STRING_FORMAT); |
|
| 2514 | + } |
|
| 2515 | + |
|
| 2516 | + /** |
|
| 2517 | + * Code to be run before persisting the object |
|
| 2518 | + * @param ConnectionInterface $con |
|
| 2519 | + * @return boolean |
|
| 2520 | + */ |
|
| 2521 | + public function preSave(ConnectionInterface $con = null) |
|
| 2522 | + { |
|
| 2523 | + return true; |
|
| 2524 | + } |
|
| 2525 | + |
|
| 2526 | + /** |
|
| 2527 | + * Code to be run after persisting the object |
|
| 2528 | + * @param ConnectionInterface $con |
|
| 2529 | + */ |
|
| 2530 | + public function postSave(ConnectionInterface $con = null) |
|
| 2531 | + { |
|
| 2532 | + |
|
| 2533 | + } |
|
| 2534 | + |
|
| 2535 | + /** |
|
| 2536 | + * Code to be run before inserting to database |
|
| 2537 | + * @param ConnectionInterface $con |
|
| 2538 | + * @return boolean |
|
| 2539 | + */ |
|
| 2540 | + public function preInsert(ConnectionInterface $con = null) |
|
| 2541 | + { |
|
| 2542 | + return true; |
|
| 2543 | + } |
|
| 2544 | + |
|
| 2545 | + /** |
|
| 2546 | + * Code to be run after inserting to database |
|
| 2547 | + * @param ConnectionInterface $con |
|
| 2548 | + */ |
|
| 2549 | + public function postInsert(ConnectionInterface $con = null) |
|
| 2550 | + { |
|
| 2551 | + |
|
| 2552 | + } |
|
| 2553 | + |
|
| 2554 | + /** |
|
| 2555 | + * Code to be run before updating the object in database |
|
| 2556 | + * @param ConnectionInterface $con |
|
| 2557 | + * @return boolean |
|
| 2558 | + */ |
|
| 2559 | + public function preUpdate(ConnectionInterface $con = null) |
|
| 2560 | + { |
|
| 2561 | + return true; |
|
| 2562 | + } |
|
| 2563 | + |
|
| 2564 | + /** |
|
| 2565 | + * Code to be run after updating the object in database |
|
| 2566 | + * @param ConnectionInterface $con |
|
| 2567 | + */ |
|
| 2568 | + public function postUpdate(ConnectionInterface $con = null) |
|
| 2569 | + { |
|
| 2570 | + |
|
| 2571 | + } |
|
| 2572 | + |
|
| 2573 | + /** |
|
| 2574 | + * Code to be run before deleting the object in database |
|
| 2575 | + * @param ConnectionInterface $con |
|
| 2576 | + * @return boolean |
|
| 2577 | + */ |
|
| 2578 | + public function preDelete(ConnectionInterface $con = null) |
|
| 2579 | + { |
|
| 2580 | + return true; |
|
| 2581 | + } |
|
| 2582 | + |
|
| 2583 | + /** |
|
| 2584 | + * Code to be run after deleting the object in database |
|
| 2585 | + * @param ConnectionInterface $con |
|
| 2586 | + */ |
|
| 2587 | + public function postDelete(ConnectionInterface $con = null) |
|
| 2588 | + { |
|
| 2589 | + |
|
| 2590 | + } |
|
| 2591 | + |
|
| 2592 | + |
|
| 2593 | + /** |
|
| 2594 | + * Derived method to catches calls to undefined methods. |
|
| 2595 | + * |
|
| 2596 | + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 2597 | + * Allows to define default __call() behavior if you overwrite __call() |
|
| 2598 | + * |
|
| 2599 | + * @param string $name |
|
| 2600 | + * @param mixed $params |
|
| 2601 | + * |
|
| 2602 | + * @return array|string |
|
| 2603 | + */ |
|
| 2604 | + public function __call($name, $params) |
|
| 2605 | + { |
|
| 2606 | + if (0 === strpos($name, 'get')) { |
|
| 2607 | + $virtualColumn = substr($name, 3); |
|
| 2608 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 2609 | + return $this->getVirtualColumn($virtualColumn); |
|
| 2610 | + } |
|
| 2611 | + |
|
| 2612 | + $virtualColumn = lcfirst($virtualColumn); |
|
| 2613 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 2614 | + return $this->getVirtualColumn($virtualColumn); |
|
| 2615 | + } |
|
| 2616 | + } |
|
| 2617 | + |
|
| 2618 | + if (0 === strpos($name, 'from')) { |
|
| 2619 | + $format = substr($name, 4); |
|
| 2620 | + |
|
| 2621 | + return $this->importFrom($format, reset($params)); |
|
| 2622 | + } |
|
| 2623 | + |
|
| 2624 | + if (0 === strpos($name, 'to')) { |
|
| 2625 | + $format = substr($name, 2); |
|
| 2626 | + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 2627 | + |
|
| 2628 | + return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 2629 | + } |
|
| 2630 | + |
|
| 2631 | + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 2632 | + } |
|
| 2633 | 2633 | |
| 2634 | 2634 | } |
@@ -88,7 +88,6 @@ discard block |
||
| 88 | 88 | * @method ChildInstance findOneOrCreate(ConnectionInterface $con = null) Return the first ChildInstance matching the query, or a new ChildInstance object populated from the query conditions when no match is found |
| 89 | 89 | * |
| 90 | 90 | * @method ChildInstance findOneByName(string $name) Return the first ChildInstance filtered by the name column * |
| 91 | - |
|
| 92 | 91 | * @method ChildInstance requirePk($key, ConnectionInterface $con = null) Return the ChildInstance by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
| 93 | 92 | * @method ChildInstance requireOne(ConnectionInterface $con = null) Return the first ChildInstance matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
| 94 | 93 | * |
@@ -101,652 +100,652 @@ discard block |
||
| 101 | 100 | */ |
| 102 | 101 | abstract class InstanceQuery extends ModelCriteria |
| 103 | 102 | { |
| 104 | - protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Initializes internal state of \Jalle19\StatusManager\Database\Base\InstanceQuery object. |
|
| 108 | - * |
|
| 109 | - * @param string $dbName The database name |
|
| 110 | - * @param string $modelName The phpName of a model, e.g. 'Book' |
|
| 111 | - * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
| 112 | - */ |
|
| 113 | - public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Instance', $modelAlias = null) |
|
| 114 | - { |
|
| 115 | - parent::__construct($dbName, $modelName, $modelAlias); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * Returns a new ChildInstanceQuery object. |
|
| 120 | - * |
|
| 121 | - * @param string $modelAlias The alias of a model in the query |
|
| 122 | - * @param Criteria $criteria Optional Criteria to build the query from |
|
| 123 | - * |
|
| 124 | - * @return ChildInstanceQuery |
|
| 125 | - */ |
|
| 126 | - public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 127 | - { |
|
| 128 | - if ($criteria instanceof ChildInstanceQuery) { |
|
| 129 | - return $criteria; |
|
| 130 | - } |
|
| 131 | - $query = new ChildInstanceQuery(); |
|
| 132 | - if (null !== $modelAlias) { |
|
| 133 | - $query->setModelAlias($modelAlias); |
|
| 134 | - } |
|
| 135 | - if ($criteria instanceof Criteria) { |
|
| 136 | - $query->mergeWith($criteria); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return $query; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Find object by primary key. |
|
| 144 | - * Propel uses the instance pool to skip the database if the object exists. |
|
| 145 | - * Go fast if the query is untouched. |
|
| 146 | - * |
|
| 147 | - * <code> |
|
| 148 | - * $obj = $c->findPk(12, $con); |
|
| 149 | - * </code> |
|
| 150 | - * |
|
| 151 | - * @param mixed $key Primary key to use for the query |
|
| 152 | - * @param ConnectionInterface $con an optional connection object |
|
| 153 | - * |
|
| 154 | - * @return ChildInstance|array|mixed the result, formatted by the current formatter |
|
| 155 | - */ |
|
| 156 | - public function findPk($key, ConnectionInterface $con = null) |
|
| 157 | - { |
|
| 158 | - if ($key === null) { |
|
| 159 | - return null; |
|
| 160 | - } |
|
| 161 | - if ((null !== ($obj = InstanceTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
| 162 | - // the object is already in the instance pool |
|
| 163 | - return $obj; |
|
| 164 | - } |
|
| 165 | - if ($con === null) { |
|
| 166 | - $con = Propel::getServiceContainer()->getReadConnection(InstanceTableMap::DATABASE_NAME); |
|
| 167 | - } |
|
| 168 | - $this->basePreSelect($con); |
|
| 169 | - if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
| 170 | - || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
| 171 | - || $this->map || $this->having || $this->joins) { |
|
| 172 | - return $this->findPkComplex($key, $con); |
|
| 173 | - } else { |
|
| 174 | - return $this->findPkSimple($key, $con); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Find object by primary key using raw SQL to go fast. |
|
| 180 | - * Bypass doSelect() and the object formatter by using generated code. |
|
| 181 | - * |
|
| 182 | - * @param mixed $key Primary key to use for the query |
|
| 183 | - * @param ConnectionInterface $con A connection object |
|
| 184 | - * |
|
| 185 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 186 | - * |
|
| 187 | - * @return ChildInstance A model object, or null if the key is not found |
|
| 188 | - */ |
|
| 189 | - protected function findPkSimple($key, ConnectionInterface $con) |
|
| 190 | - { |
|
| 191 | - $sql = 'SELECT name FROM instance WHERE name = :p0'; |
|
| 192 | - try { |
|
| 193 | - $stmt = $con->prepare($sql); |
|
| 194 | - $stmt->bindValue(':p0', $key, PDO::PARAM_STR); |
|
| 195 | - $stmt->execute(); |
|
| 196 | - } catch (Exception $e) { |
|
| 197 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 198 | - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
| 199 | - } |
|
| 200 | - $obj = null; |
|
| 201 | - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
| 202 | - /** @var ChildInstance $obj */ |
|
| 203 | - $obj = new ChildInstance(); |
|
| 204 | - $obj->hydrate($row); |
|
| 205 | - InstanceTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
| 206 | - } |
|
| 207 | - $stmt->closeCursor(); |
|
| 208 | - |
|
| 209 | - return $obj; |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * Find object by primary key. |
|
| 214 | - * |
|
| 215 | - * @param mixed $key Primary key to use for the query |
|
| 216 | - * @param ConnectionInterface $con A connection object |
|
| 217 | - * |
|
| 218 | - * @return ChildInstance|array|mixed the result, formatted by the current formatter |
|
| 219 | - */ |
|
| 220 | - protected function findPkComplex($key, ConnectionInterface $con) |
|
| 221 | - { |
|
| 222 | - // As the query uses a PK condition, no limit(1) is necessary. |
|
| 223 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 224 | - $dataFetcher = $criteria |
|
| 225 | - ->filterByPrimaryKey($key) |
|
| 226 | - ->doSelect($con); |
|
| 227 | - |
|
| 228 | - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Find objects by primary key |
|
| 233 | - * <code> |
|
| 234 | - * $objs = $c->findPks(array(12, 56, 832), $con); |
|
| 235 | - * </code> |
|
| 236 | - * @param array $keys Primary keys to use for the query |
|
| 237 | - * @param ConnectionInterface $con an optional connection object |
|
| 238 | - * |
|
| 239 | - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
| 240 | - */ |
|
| 241 | - public function findPks($keys, ConnectionInterface $con = null) |
|
| 242 | - { |
|
| 243 | - if (null === $con) { |
|
| 244 | - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
| 245 | - } |
|
| 246 | - $this->basePreSelect($con); |
|
| 247 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 248 | - $dataFetcher = $criteria |
|
| 249 | - ->filterByPrimaryKeys($keys) |
|
| 250 | - ->doSelect($con); |
|
| 251 | - |
|
| 252 | - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * Filter the query by primary key |
|
| 257 | - * |
|
| 258 | - * @param mixed $key Primary key to use for the query |
|
| 259 | - * |
|
| 260 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 261 | - */ |
|
| 262 | - public function filterByPrimaryKey($key) |
|
| 263 | - { |
|
| 264 | - |
|
| 265 | - return $this->addUsingAlias(InstanceTableMap::COL_NAME, $key, Criteria::EQUAL); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * Filter the query by a list of primary keys |
|
| 270 | - * |
|
| 271 | - * @param array $keys The list of primary key to use for the query |
|
| 272 | - * |
|
| 273 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 274 | - */ |
|
| 275 | - public function filterByPrimaryKeys($keys) |
|
| 276 | - { |
|
| 277 | - |
|
| 278 | - return $this->addUsingAlias(InstanceTableMap::COL_NAME, $keys, Criteria::IN); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Filter the query on the name column |
|
| 283 | - * |
|
| 284 | - * Example usage: |
|
| 285 | - * <code> |
|
| 286 | - * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
|
| 287 | - * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
|
| 288 | - * </code> |
|
| 289 | - * |
|
| 290 | - * @param string $name The value to use as filter. |
|
| 291 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 292 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 293 | - * |
|
| 294 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 295 | - */ |
|
| 296 | - public function filterByName($name = null, $comparison = null) |
|
| 297 | - { |
|
| 298 | - if (null === $comparison) { |
|
| 299 | - if (is_array($name)) { |
|
| 300 | - $comparison = Criteria::IN; |
|
| 301 | - } elseif (preg_match('/[\%\*]/', $name)) { |
|
| 302 | - $name = str_replace('*', '%', $name); |
|
| 303 | - $comparison = Criteria::LIKE; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - |
|
| 307 | - return $this->addUsingAlias(InstanceTableMap::COL_NAME, $name, $comparison); |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * Filter the query by a related \Jalle19\StatusManager\Database\User object |
|
| 312 | - * |
|
| 313 | - * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user the related object to use as filter |
|
| 314 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 315 | - * |
|
| 316 | - * @return ChildInstanceQuery The current query, for fluid interface |
|
| 317 | - */ |
|
| 318 | - public function filterByUser($user, $comparison = null) |
|
| 319 | - { |
|
| 320 | - if ($user instanceof \Jalle19\StatusManager\Database\User) { |
|
| 321 | - return $this |
|
| 322 | - ->addUsingAlias(InstanceTableMap::COL_NAME, $user->getInstanceName(), $comparison); |
|
| 323 | - } elseif ($user instanceof ObjectCollection) { |
|
| 324 | - return $this |
|
| 325 | - ->useUserQuery() |
|
| 326 | - ->filterByPrimaryKeys($user->getPrimaryKeys()) |
|
| 327 | - ->endUse(); |
|
| 328 | - } else { |
|
| 329 | - throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection'); |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - /** |
|
| 334 | - * Adds a JOIN clause to the query using the User relation |
|
| 335 | - * |
|
| 336 | - * @param string $relationAlias optional alias for the relation |
|
| 337 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 338 | - * |
|
| 339 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 340 | - */ |
|
| 341 | - public function joinUser($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 342 | - { |
|
| 343 | - $tableMap = $this->getTableMap(); |
|
| 344 | - $relationMap = $tableMap->getRelation('User'); |
|
| 345 | - |
|
| 346 | - // create a ModelJoin object for this join |
|
| 347 | - $join = new ModelJoin(); |
|
| 348 | - $join->setJoinType($joinType); |
|
| 349 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 350 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 351 | - $join->setPreviousJoin($previousJoin); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - // add the ModelJoin to the current object |
|
| 355 | - if ($relationAlias) { |
|
| 356 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 357 | - $this->addJoinObject($join, $relationAlias); |
|
| 358 | - } else { |
|
| 359 | - $this->addJoinObject($join, 'User'); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - return $this; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Use the User relation User object |
|
| 367 | - * |
|
| 368 | - * @see useQuery() |
|
| 369 | - * |
|
| 370 | - * @param string $relationAlias optional alias for the relation, |
|
| 371 | - * to be used as main alias in the secondary query |
|
| 372 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 373 | - * |
|
| 374 | - * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query |
|
| 375 | - */ |
|
| 376 | - public function useUserQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 377 | - { |
|
| 378 | - return $this |
|
| 379 | - ->joinUser($relationAlias, $joinType) |
|
| 380 | - ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery'); |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Filter the query by a related \Jalle19\StatusManager\Database\Connection object |
|
| 385 | - * |
|
| 386 | - * @param \Jalle19\StatusManager\Database\Connection|ObjectCollection $connection the related object to use as filter |
|
| 387 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 388 | - * |
|
| 389 | - * @return ChildInstanceQuery The current query, for fluid interface |
|
| 390 | - */ |
|
| 391 | - public function filterByConnection($connection, $comparison = null) |
|
| 392 | - { |
|
| 393 | - if ($connection instanceof \Jalle19\StatusManager\Database\Connection) { |
|
| 394 | - return $this |
|
| 395 | - ->addUsingAlias(InstanceTableMap::COL_NAME, $connection->getInstanceName(), $comparison); |
|
| 396 | - } elseif ($connection instanceof ObjectCollection) { |
|
| 397 | - return $this |
|
| 398 | - ->useConnectionQuery() |
|
| 399 | - ->filterByPrimaryKeys($connection->getPrimaryKeys()) |
|
| 400 | - ->endUse(); |
|
| 401 | - } else { |
|
| 402 | - throw new PropelException('filterByConnection() only accepts arguments of type \Jalle19\StatusManager\Database\Connection or Collection'); |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * Adds a JOIN clause to the query using the Connection relation |
|
| 408 | - * |
|
| 409 | - * @param string $relationAlias optional alias for the relation |
|
| 410 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 411 | - * |
|
| 412 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 413 | - */ |
|
| 414 | - public function joinConnection($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 415 | - { |
|
| 416 | - $tableMap = $this->getTableMap(); |
|
| 417 | - $relationMap = $tableMap->getRelation('Connection'); |
|
| 418 | - |
|
| 419 | - // create a ModelJoin object for this join |
|
| 420 | - $join = new ModelJoin(); |
|
| 421 | - $join->setJoinType($joinType); |
|
| 422 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 423 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 424 | - $join->setPreviousJoin($previousJoin); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - // add the ModelJoin to the current object |
|
| 428 | - if ($relationAlias) { |
|
| 429 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 430 | - $this->addJoinObject($join, $relationAlias); |
|
| 431 | - } else { |
|
| 432 | - $this->addJoinObject($join, 'Connection'); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - return $this; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * Use the Connection relation Connection object |
|
| 440 | - * |
|
| 441 | - * @see useQuery() |
|
| 442 | - * |
|
| 443 | - * @param string $relationAlias optional alias for the relation, |
|
| 444 | - * to be used as main alias in the secondary query |
|
| 445 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 446 | - * |
|
| 447 | - * @return \Jalle19\StatusManager\Database\ConnectionQuery A secondary query class using the current class as primary query |
|
| 448 | - */ |
|
| 449 | - public function useConnectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 450 | - { |
|
| 451 | - return $this |
|
| 452 | - ->joinConnection($relationAlias, $joinType) |
|
| 453 | - ->useQuery($relationAlias ? $relationAlias : 'Connection', '\Jalle19\StatusManager\Database\ConnectionQuery'); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * Filter the query by a related \Jalle19\StatusManager\Database\Input object |
|
| 458 | - * |
|
| 459 | - * @param \Jalle19\StatusManager\Database\Input|ObjectCollection $input the related object to use as filter |
|
| 460 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 461 | - * |
|
| 462 | - * @return ChildInstanceQuery The current query, for fluid interface |
|
| 463 | - */ |
|
| 464 | - public function filterByInput($input, $comparison = null) |
|
| 465 | - { |
|
| 466 | - if ($input instanceof \Jalle19\StatusManager\Database\Input) { |
|
| 467 | - return $this |
|
| 468 | - ->addUsingAlias(InstanceTableMap::COL_NAME, $input->getInstanceName(), $comparison); |
|
| 469 | - } elseif ($input instanceof ObjectCollection) { |
|
| 470 | - return $this |
|
| 471 | - ->useInputQuery() |
|
| 472 | - ->filterByPrimaryKeys($input->getPrimaryKeys()) |
|
| 473 | - ->endUse(); |
|
| 474 | - } else { |
|
| 475 | - throw new PropelException('filterByInput() only accepts arguments of type \Jalle19\StatusManager\Database\Input or Collection'); |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - /** |
|
| 480 | - * Adds a JOIN clause to the query using the Input relation |
|
| 481 | - * |
|
| 482 | - * @param string $relationAlias optional alias for the relation |
|
| 483 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 484 | - * |
|
| 485 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 486 | - */ |
|
| 487 | - public function joinInput($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 488 | - { |
|
| 489 | - $tableMap = $this->getTableMap(); |
|
| 490 | - $relationMap = $tableMap->getRelation('Input'); |
|
| 491 | - |
|
| 492 | - // create a ModelJoin object for this join |
|
| 493 | - $join = new ModelJoin(); |
|
| 494 | - $join->setJoinType($joinType); |
|
| 495 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 496 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 497 | - $join->setPreviousJoin($previousJoin); |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - // add the ModelJoin to the current object |
|
| 501 | - if ($relationAlias) { |
|
| 502 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 503 | - $this->addJoinObject($join, $relationAlias); |
|
| 504 | - } else { |
|
| 505 | - $this->addJoinObject($join, 'Input'); |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - return $this; |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - /** |
|
| 512 | - * Use the Input relation Input object |
|
| 513 | - * |
|
| 514 | - * @see useQuery() |
|
| 515 | - * |
|
| 516 | - * @param string $relationAlias optional alias for the relation, |
|
| 517 | - * to be used as main alias in the secondary query |
|
| 518 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 519 | - * |
|
| 520 | - * @return \Jalle19\StatusManager\Database\InputQuery A secondary query class using the current class as primary query |
|
| 521 | - */ |
|
| 522 | - public function useInputQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 523 | - { |
|
| 524 | - return $this |
|
| 525 | - ->joinInput($relationAlias, $joinType) |
|
| 526 | - ->useQuery($relationAlias ? $relationAlias : 'Input', '\Jalle19\StatusManager\Database\InputQuery'); |
|
| 527 | - } |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Filter the query by a related \Jalle19\StatusManager\Database\Channel object |
|
| 531 | - * |
|
| 532 | - * @param \Jalle19\StatusManager\Database\Channel|ObjectCollection $channel the related object to use as filter |
|
| 533 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 534 | - * |
|
| 535 | - * @return ChildInstanceQuery The current query, for fluid interface |
|
| 536 | - */ |
|
| 537 | - public function filterByChannel($channel, $comparison = null) |
|
| 538 | - { |
|
| 539 | - if ($channel instanceof \Jalle19\StatusManager\Database\Channel) { |
|
| 540 | - return $this |
|
| 541 | - ->addUsingAlias(InstanceTableMap::COL_NAME, $channel->getInstanceName(), $comparison); |
|
| 542 | - } elseif ($channel instanceof ObjectCollection) { |
|
| 543 | - return $this |
|
| 544 | - ->useChannelQuery() |
|
| 545 | - ->filterByPrimaryKeys($channel->getPrimaryKeys()) |
|
| 546 | - ->endUse(); |
|
| 547 | - } else { |
|
| 548 | - throw new PropelException('filterByChannel() only accepts arguments of type \Jalle19\StatusManager\Database\Channel or Collection'); |
|
| 549 | - } |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - /** |
|
| 553 | - * Adds a JOIN clause to the query using the Channel relation |
|
| 554 | - * |
|
| 555 | - * @param string $relationAlias optional alias for the relation |
|
| 556 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 557 | - * |
|
| 558 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 559 | - */ |
|
| 560 | - public function joinChannel($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 561 | - { |
|
| 562 | - $tableMap = $this->getTableMap(); |
|
| 563 | - $relationMap = $tableMap->getRelation('Channel'); |
|
| 564 | - |
|
| 565 | - // create a ModelJoin object for this join |
|
| 566 | - $join = new ModelJoin(); |
|
| 567 | - $join->setJoinType($joinType); |
|
| 568 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 569 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 570 | - $join->setPreviousJoin($previousJoin); |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - // add the ModelJoin to the current object |
|
| 574 | - if ($relationAlias) { |
|
| 575 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 576 | - $this->addJoinObject($join, $relationAlias); |
|
| 577 | - } else { |
|
| 578 | - $this->addJoinObject($join, 'Channel'); |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - return $this; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * Use the Channel relation Channel object |
|
| 586 | - * |
|
| 587 | - * @see useQuery() |
|
| 588 | - * |
|
| 589 | - * @param string $relationAlias optional alias for the relation, |
|
| 590 | - * to be used as main alias in the secondary query |
|
| 591 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 592 | - * |
|
| 593 | - * @return \Jalle19\StatusManager\Database\ChannelQuery A secondary query class using the current class as primary query |
|
| 594 | - */ |
|
| 595 | - public function useChannelQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 596 | - { |
|
| 597 | - return $this |
|
| 598 | - ->joinChannel($relationAlias, $joinType) |
|
| 599 | - ->useQuery($relationAlias ? $relationAlias : 'Channel', '\Jalle19\StatusManager\Database\ChannelQuery'); |
|
| 600 | - } |
|
| 601 | - |
|
| 602 | - /** |
|
| 603 | - * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
| 604 | - * |
|
| 605 | - * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
| 606 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 607 | - * |
|
| 608 | - * @return ChildInstanceQuery The current query, for fluid interface |
|
| 609 | - */ |
|
| 610 | - public function filterBySubscription($subscription, $comparison = null) |
|
| 611 | - { |
|
| 612 | - if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
| 613 | - return $this |
|
| 614 | - ->addUsingAlias(InstanceTableMap::COL_NAME, $subscription->getInstanceName(), $comparison); |
|
| 615 | - } elseif ($subscription instanceof ObjectCollection) { |
|
| 616 | - return $this |
|
| 617 | - ->useSubscriptionQuery() |
|
| 618 | - ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
| 619 | - ->endUse(); |
|
| 620 | - } else { |
|
| 621 | - throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
| 622 | - } |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - /** |
|
| 626 | - * Adds a JOIN clause to the query using the Subscription relation |
|
| 627 | - * |
|
| 628 | - * @param string $relationAlias optional alias for the relation |
|
| 629 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 630 | - * |
|
| 631 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 632 | - */ |
|
| 633 | - public function joinSubscription($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 634 | - { |
|
| 635 | - $tableMap = $this->getTableMap(); |
|
| 636 | - $relationMap = $tableMap->getRelation('Subscription'); |
|
| 637 | - |
|
| 638 | - // create a ModelJoin object for this join |
|
| 639 | - $join = new ModelJoin(); |
|
| 640 | - $join->setJoinType($joinType); |
|
| 641 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 642 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 643 | - $join->setPreviousJoin($previousJoin); |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - // add the ModelJoin to the current object |
|
| 647 | - if ($relationAlias) { |
|
| 648 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 649 | - $this->addJoinObject($join, $relationAlias); |
|
| 650 | - } else { |
|
| 651 | - $this->addJoinObject($join, 'Subscription'); |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $this; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - /** |
|
| 658 | - * Use the Subscription relation Subscription object |
|
| 659 | - * |
|
| 660 | - * @see useQuery() |
|
| 661 | - * |
|
| 662 | - * @param string $relationAlias optional alias for the relation, |
|
| 663 | - * to be used as main alias in the secondary query |
|
| 664 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 665 | - * |
|
| 666 | - * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
| 667 | - */ |
|
| 668 | - public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 669 | - { |
|
| 670 | - return $this |
|
| 671 | - ->joinSubscription($relationAlias, $joinType) |
|
| 672 | - ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - /** |
|
| 676 | - * Exclude object from result |
|
| 677 | - * |
|
| 678 | - * @param ChildInstance $instance Object to remove from the list of results |
|
| 679 | - * |
|
| 680 | - * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 681 | - */ |
|
| 682 | - public function prune($instance = null) |
|
| 683 | - { |
|
| 684 | - if ($instance) { |
|
| 685 | - $this->addUsingAlias(InstanceTableMap::COL_NAME, $instance->getName(), Criteria::NOT_EQUAL); |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - return $this; |
|
| 689 | - } |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * Deletes all rows from the instance table. |
|
| 693 | - * |
|
| 694 | - * @param ConnectionInterface $con the connection to use |
|
| 695 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
| 696 | - */ |
|
| 697 | - public function doDeleteAll(ConnectionInterface $con = null) |
|
| 698 | - { |
|
| 699 | - if (null === $con) { |
|
| 700 | - $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 701 | - } |
|
| 702 | - |
|
| 703 | - // use transaction because $criteria could contain info |
|
| 704 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 705 | - return $con->transaction(function () use ($con) { |
|
| 706 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 707 | - $affectedRows += parent::doDeleteAll($con); |
|
| 708 | - // Because this db requires some delete cascade/set null emulation, we have to |
|
| 709 | - // clear the cached instance *after* the emulation has happened (since |
|
| 710 | - // instances get re-added by the select statement contained therein). |
|
| 711 | - InstanceTableMap::clearInstancePool(); |
|
| 712 | - InstanceTableMap::clearRelatedInstancePool(); |
|
| 713 | - |
|
| 714 | - return $affectedRows; |
|
| 715 | - }); |
|
| 716 | - } |
|
| 717 | - |
|
| 718 | - /** |
|
| 719 | - * Performs a DELETE on the database based on the current ModelCriteria |
|
| 720 | - * |
|
| 721 | - * @param ConnectionInterface $con the connection to use |
|
| 722 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
| 723 | - * if supported by native driver or if emulated using Propel. |
|
| 724 | - * @throws PropelException Any exceptions caught during processing will be |
|
| 725 | - * rethrown wrapped into a PropelException. |
|
| 726 | - */ |
|
| 727 | - public function delete(ConnectionInterface $con = null) |
|
| 728 | - { |
|
| 729 | - if (null === $con) { |
|
| 730 | - $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - $criteria = $this; |
|
| 734 | - |
|
| 735 | - // Set the correct dbName |
|
| 736 | - $criteria->setDbName(InstanceTableMap::DATABASE_NAME); |
|
| 737 | - |
|
| 738 | - // use transaction because $criteria could contain info |
|
| 739 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 740 | - return $con->transaction(function () use ($con, $criteria) { |
|
| 741 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 742 | - |
|
| 743 | - InstanceTableMap::removeInstanceFromPool($criteria); |
|
| 744 | - |
|
| 745 | - $affectedRows += ModelCriteria::delete($con); |
|
| 746 | - InstanceTableMap::clearRelatedInstancePool(); |
|
| 747 | - |
|
| 748 | - return $affectedRows; |
|
| 749 | - }); |
|
| 750 | - } |
|
| 103 | + protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Initializes internal state of \Jalle19\StatusManager\Database\Base\InstanceQuery object. |
|
| 107 | + * |
|
| 108 | + * @param string $dbName The database name |
|
| 109 | + * @param string $modelName The phpName of a model, e.g. 'Book' |
|
| 110 | + * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
| 111 | + */ |
|
| 112 | + public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Instance', $modelAlias = null) |
|
| 113 | + { |
|
| 114 | + parent::__construct($dbName, $modelName, $modelAlias); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Returns a new ChildInstanceQuery object. |
|
| 119 | + * |
|
| 120 | + * @param string $modelAlias The alias of a model in the query |
|
| 121 | + * @param Criteria $criteria Optional Criteria to build the query from |
|
| 122 | + * |
|
| 123 | + * @return ChildInstanceQuery |
|
| 124 | + */ |
|
| 125 | + public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 126 | + { |
|
| 127 | + if ($criteria instanceof ChildInstanceQuery) { |
|
| 128 | + return $criteria; |
|
| 129 | + } |
|
| 130 | + $query = new ChildInstanceQuery(); |
|
| 131 | + if (null !== $modelAlias) { |
|
| 132 | + $query->setModelAlias($modelAlias); |
|
| 133 | + } |
|
| 134 | + if ($criteria instanceof Criteria) { |
|
| 135 | + $query->mergeWith($criteria); |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + return $query; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Find object by primary key. |
|
| 143 | + * Propel uses the instance pool to skip the database if the object exists. |
|
| 144 | + * Go fast if the query is untouched. |
|
| 145 | + * |
|
| 146 | + * <code> |
|
| 147 | + * $obj = $c->findPk(12, $con); |
|
| 148 | + * </code> |
|
| 149 | + * |
|
| 150 | + * @param mixed $key Primary key to use for the query |
|
| 151 | + * @param ConnectionInterface $con an optional connection object |
|
| 152 | + * |
|
| 153 | + * @return ChildInstance|array|mixed the result, formatted by the current formatter |
|
| 154 | + */ |
|
| 155 | + public function findPk($key, ConnectionInterface $con = null) |
|
| 156 | + { |
|
| 157 | + if ($key === null) { |
|
| 158 | + return null; |
|
| 159 | + } |
|
| 160 | + if ((null !== ($obj = InstanceTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
| 161 | + // the object is already in the instance pool |
|
| 162 | + return $obj; |
|
| 163 | + } |
|
| 164 | + if ($con === null) { |
|
| 165 | + $con = Propel::getServiceContainer()->getReadConnection(InstanceTableMap::DATABASE_NAME); |
|
| 166 | + } |
|
| 167 | + $this->basePreSelect($con); |
|
| 168 | + if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
| 169 | + || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
| 170 | + || $this->map || $this->having || $this->joins) { |
|
| 171 | + return $this->findPkComplex($key, $con); |
|
| 172 | + } else { |
|
| 173 | + return $this->findPkSimple($key, $con); |
|
| 174 | + } |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Find object by primary key using raw SQL to go fast. |
|
| 179 | + * Bypass doSelect() and the object formatter by using generated code. |
|
| 180 | + * |
|
| 181 | + * @param mixed $key Primary key to use for the query |
|
| 182 | + * @param ConnectionInterface $con A connection object |
|
| 183 | + * |
|
| 184 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 185 | + * |
|
| 186 | + * @return ChildInstance A model object, or null if the key is not found |
|
| 187 | + */ |
|
| 188 | + protected function findPkSimple($key, ConnectionInterface $con) |
|
| 189 | + { |
|
| 190 | + $sql = 'SELECT name FROM instance WHERE name = :p0'; |
|
| 191 | + try { |
|
| 192 | + $stmt = $con->prepare($sql); |
|
| 193 | + $stmt->bindValue(':p0', $key, PDO::PARAM_STR); |
|
| 194 | + $stmt->execute(); |
|
| 195 | + } catch (Exception $e) { |
|
| 196 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 197 | + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
| 198 | + } |
|
| 199 | + $obj = null; |
|
| 200 | + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
| 201 | + /** @var ChildInstance $obj */ |
|
| 202 | + $obj = new ChildInstance(); |
|
| 203 | + $obj->hydrate($row); |
|
| 204 | + InstanceTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
| 205 | + } |
|
| 206 | + $stmt->closeCursor(); |
|
| 207 | + |
|
| 208 | + return $obj; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * Find object by primary key. |
|
| 213 | + * |
|
| 214 | + * @param mixed $key Primary key to use for the query |
|
| 215 | + * @param ConnectionInterface $con A connection object |
|
| 216 | + * |
|
| 217 | + * @return ChildInstance|array|mixed the result, formatted by the current formatter |
|
| 218 | + */ |
|
| 219 | + protected function findPkComplex($key, ConnectionInterface $con) |
|
| 220 | + { |
|
| 221 | + // As the query uses a PK condition, no limit(1) is necessary. |
|
| 222 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 223 | + $dataFetcher = $criteria |
|
| 224 | + ->filterByPrimaryKey($key) |
|
| 225 | + ->doSelect($con); |
|
| 226 | + |
|
| 227 | + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Find objects by primary key |
|
| 232 | + * <code> |
|
| 233 | + * $objs = $c->findPks(array(12, 56, 832), $con); |
|
| 234 | + * </code> |
|
| 235 | + * @param array $keys Primary keys to use for the query |
|
| 236 | + * @param ConnectionInterface $con an optional connection object |
|
| 237 | + * |
|
| 238 | + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
| 239 | + */ |
|
| 240 | + public function findPks($keys, ConnectionInterface $con = null) |
|
| 241 | + { |
|
| 242 | + if (null === $con) { |
|
| 243 | + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
| 244 | + } |
|
| 245 | + $this->basePreSelect($con); |
|
| 246 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 247 | + $dataFetcher = $criteria |
|
| 248 | + ->filterByPrimaryKeys($keys) |
|
| 249 | + ->doSelect($con); |
|
| 250 | + |
|
| 251 | + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + /** |
|
| 255 | + * Filter the query by primary key |
|
| 256 | + * |
|
| 257 | + * @param mixed $key Primary key to use for the query |
|
| 258 | + * |
|
| 259 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 260 | + */ |
|
| 261 | + public function filterByPrimaryKey($key) |
|
| 262 | + { |
|
| 263 | + |
|
| 264 | + return $this->addUsingAlias(InstanceTableMap::COL_NAME, $key, Criteria::EQUAL); |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Filter the query by a list of primary keys |
|
| 269 | + * |
|
| 270 | + * @param array $keys The list of primary key to use for the query |
|
| 271 | + * |
|
| 272 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 273 | + */ |
|
| 274 | + public function filterByPrimaryKeys($keys) |
|
| 275 | + { |
|
| 276 | + |
|
| 277 | + return $this->addUsingAlias(InstanceTableMap::COL_NAME, $keys, Criteria::IN); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Filter the query on the name column |
|
| 282 | + * |
|
| 283 | + * Example usage: |
|
| 284 | + * <code> |
|
| 285 | + * $query->filterByName('fooValue'); // WHERE name = 'fooValue' |
|
| 286 | + * $query->filterByName('%fooValue%'); // WHERE name LIKE '%fooValue%' |
|
| 287 | + * </code> |
|
| 288 | + * |
|
| 289 | + * @param string $name The value to use as filter. |
|
| 290 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 291 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 292 | + * |
|
| 293 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 294 | + */ |
|
| 295 | + public function filterByName($name = null, $comparison = null) |
|
| 296 | + { |
|
| 297 | + if (null === $comparison) { |
|
| 298 | + if (is_array($name)) { |
|
| 299 | + $comparison = Criteria::IN; |
|
| 300 | + } elseif (preg_match('/[\%\*]/', $name)) { |
|
| 301 | + $name = str_replace('*', '%', $name); |
|
| 302 | + $comparison = Criteria::LIKE; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + return $this->addUsingAlias(InstanceTableMap::COL_NAME, $name, $comparison); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * Filter the query by a related \Jalle19\StatusManager\Database\User object |
|
| 311 | + * |
|
| 312 | + * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user the related object to use as filter |
|
| 313 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 314 | + * |
|
| 315 | + * @return ChildInstanceQuery The current query, for fluid interface |
|
| 316 | + */ |
|
| 317 | + public function filterByUser($user, $comparison = null) |
|
| 318 | + { |
|
| 319 | + if ($user instanceof \Jalle19\StatusManager\Database\User) { |
|
| 320 | + return $this |
|
| 321 | + ->addUsingAlias(InstanceTableMap::COL_NAME, $user->getInstanceName(), $comparison); |
|
| 322 | + } elseif ($user instanceof ObjectCollection) { |
|
| 323 | + return $this |
|
| 324 | + ->useUserQuery() |
|
| 325 | + ->filterByPrimaryKeys($user->getPrimaryKeys()) |
|
| 326 | + ->endUse(); |
|
| 327 | + } else { |
|
| 328 | + throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection'); |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + /** |
|
| 333 | + * Adds a JOIN clause to the query using the User relation |
|
| 334 | + * |
|
| 335 | + * @param string $relationAlias optional alias for the relation |
|
| 336 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 337 | + * |
|
| 338 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 339 | + */ |
|
| 340 | + public function joinUser($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 341 | + { |
|
| 342 | + $tableMap = $this->getTableMap(); |
|
| 343 | + $relationMap = $tableMap->getRelation('User'); |
|
| 344 | + |
|
| 345 | + // create a ModelJoin object for this join |
|
| 346 | + $join = new ModelJoin(); |
|
| 347 | + $join->setJoinType($joinType); |
|
| 348 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 349 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 350 | + $join->setPreviousJoin($previousJoin); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + // add the ModelJoin to the current object |
|
| 354 | + if ($relationAlias) { |
|
| 355 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 356 | + $this->addJoinObject($join, $relationAlias); |
|
| 357 | + } else { |
|
| 358 | + $this->addJoinObject($join, 'User'); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return $this; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + /** |
|
| 365 | + * Use the User relation User object |
|
| 366 | + * |
|
| 367 | + * @see useQuery() |
|
| 368 | + * |
|
| 369 | + * @param string $relationAlias optional alias for the relation, |
|
| 370 | + * to be used as main alias in the secondary query |
|
| 371 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 372 | + * |
|
| 373 | + * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query |
|
| 374 | + */ |
|
| 375 | + public function useUserQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 376 | + { |
|
| 377 | + return $this |
|
| 378 | + ->joinUser($relationAlias, $joinType) |
|
| 379 | + ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery'); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * Filter the query by a related \Jalle19\StatusManager\Database\Connection object |
|
| 384 | + * |
|
| 385 | + * @param \Jalle19\StatusManager\Database\Connection|ObjectCollection $connection the related object to use as filter |
|
| 386 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 387 | + * |
|
| 388 | + * @return ChildInstanceQuery The current query, for fluid interface |
|
| 389 | + */ |
|
| 390 | + public function filterByConnection($connection, $comparison = null) |
|
| 391 | + { |
|
| 392 | + if ($connection instanceof \Jalle19\StatusManager\Database\Connection) { |
|
| 393 | + return $this |
|
| 394 | + ->addUsingAlias(InstanceTableMap::COL_NAME, $connection->getInstanceName(), $comparison); |
|
| 395 | + } elseif ($connection instanceof ObjectCollection) { |
|
| 396 | + return $this |
|
| 397 | + ->useConnectionQuery() |
|
| 398 | + ->filterByPrimaryKeys($connection->getPrimaryKeys()) |
|
| 399 | + ->endUse(); |
|
| 400 | + } else { |
|
| 401 | + throw new PropelException('filterByConnection() only accepts arguments of type \Jalle19\StatusManager\Database\Connection or Collection'); |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Adds a JOIN clause to the query using the Connection relation |
|
| 407 | + * |
|
| 408 | + * @param string $relationAlias optional alias for the relation |
|
| 409 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 410 | + * |
|
| 411 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 412 | + */ |
|
| 413 | + public function joinConnection($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 414 | + { |
|
| 415 | + $tableMap = $this->getTableMap(); |
|
| 416 | + $relationMap = $tableMap->getRelation('Connection'); |
|
| 417 | + |
|
| 418 | + // create a ModelJoin object for this join |
|
| 419 | + $join = new ModelJoin(); |
|
| 420 | + $join->setJoinType($joinType); |
|
| 421 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 422 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 423 | + $join->setPreviousJoin($previousJoin); |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + // add the ModelJoin to the current object |
|
| 427 | + if ($relationAlias) { |
|
| 428 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 429 | + $this->addJoinObject($join, $relationAlias); |
|
| 430 | + } else { |
|
| 431 | + $this->addJoinObject($join, 'Connection'); |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + return $this; |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * Use the Connection relation Connection object |
|
| 439 | + * |
|
| 440 | + * @see useQuery() |
|
| 441 | + * |
|
| 442 | + * @param string $relationAlias optional alias for the relation, |
|
| 443 | + * to be used as main alias in the secondary query |
|
| 444 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 445 | + * |
|
| 446 | + * @return \Jalle19\StatusManager\Database\ConnectionQuery A secondary query class using the current class as primary query |
|
| 447 | + */ |
|
| 448 | + public function useConnectionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 449 | + { |
|
| 450 | + return $this |
|
| 451 | + ->joinConnection($relationAlias, $joinType) |
|
| 452 | + ->useQuery($relationAlias ? $relationAlias : 'Connection', '\Jalle19\StatusManager\Database\ConnectionQuery'); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + /** |
|
| 456 | + * Filter the query by a related \Jalle19\StatusManager\Database\Input object |
|
| 457 | + * |
|
| 458 | + * @param \Jalle19\StatusManager\Database\Input|ObjectCollection $input the related object to use as filter |
|
| 459 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 460 | + * |
|
| 461 | + * @return ChildInstanceQuery The current query, for fluid interface |
|
| 462 | + */ |
|
| 463 | + public function filterByInput($input, $comparison = null) |
|
| 464 | + { |
|
| 465 | + if ($input instanceof \Jalle19\StatusManager\Database\Input) { |
|
| 466 | + return $this |
|
| 467 | + ->addUsingAlias(InstanceTableMap::COL_NAME, $input->getInstanceName(), $comparison); |
|
| 468 | + } elseif ($input instanceof ObjectCollection) { |
|
| 469 | + return $this |
|
| 470 | + ->useInputQuery() |
|
| 471 | + ->filterByPrimaryKeys($input->getPrimaryKeys()) |
|
| 472 | + ->endUse(); |
|
| 473 | + } else { |
|
| 474 | + throw new PropelException('filterByInput() only accepts arguments of type \Jalle19\StatusManager\Database\Input or Collection'); |
|
| 475 | + } |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + /** |
|
| 479 | + * Adds a JOIN clause to the query using the Input relation |
|
| 480 | + * |
|
| 481 | + * @param string $relationAlias optional alias for the relation |
|
| 482 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 483 | + * |
|
| 484 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 485 | + */ |
|
| 486 | + public function joinInput($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 487 | + { |
|
| 488 | + $tableMap = $this->getTableMap(); |
|
| 489 | + $relationMap = $tableMap->getRelation('Input'); |
|
| 490 | + |
|
| 491 | + // create a ModelJoin object for this join |
|
| 492 | + $join = new ModelJoin(); |
|
| 493 | + $join->setJoinType($joinType); |
|
| 494 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 495 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 496 | + $join->setPreviousJoin($previousJoin); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + // add the ModelJoin to the current object |
|
| 500 | + if ($relationAlias) { |
|
| 501 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 502 | + $this->addJoinObject($join, $relationAlias); |
|
| 503 | + } else { |
|
| 504 | + $this->addJoinObject($join, 'Input'); |
|
| 505 | + } |
|
| 506 | + |
|
| 507 | + return $this; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + /** |
|
| 511 | + * Use the Input relation Input object |
|
| 512 | + * |
|
| 513 | + * @see useQuery() |
|
| 514 | + * |
|
| 515 | + * @param string $relationAlias optional alias for the relation, |
|
| 516 | + * to be used as main alias in the secondary query |
|
| 517 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 518 | + * |
|
| 519 | + * @return \Jalle19\StatusManager\Database\InputQuery A secondary query class using the current class as primary query |
|
| 520 | + */ |
|
| 521 | + public function useInputQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 522 | + { |
|
| 523 | + return $this |
|
| 524 | + ->joinInput($relationAlias, $joinType) |
|
| 525 | + ->useQuery($relationAlias ? $relationAlias : 'Input', '\Jalle19\StatusManager\Database\InputQuery'); |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * Filter the query by a related \Jalle19\StatusManager\Database\Channel object |
|
| 530 | + * |
|
| 531 | + * @param \Jalle19\StatusManager\Database\Channel|ObjectCollection $channel the related object to use as filter |
|
| 532 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 533 | + * |
|
| 534 | + * @return ChildInstanceQuery The current query, for fluid interface |
|
| 535 | + */ |
|
| 536 | + public function filterByChannel($channel, $comparison = null) |
|
| 537 | + { |
|
| 538 | + if ($channel instanceof \Jalle19\StatusManager\Database\Channel) { |
|
| 539 | + return $this |
|
| 540 | + ->addUsingAlias(InstanceTableMap::COL_NAME, $channel->getInstanceName(), $comparison); |
|
| 541 | + } elseif ($channel instanceof ObjectCollection) { |
|
| 542 | + return $this |
|
| 543 | + ->useChannelQuery() |
|
| 544 | + ->filterByPrimaryKeys($channel->getPrimaryKeys()) |
|
| 545 | + ->endUse(); |
|
| 546 | + } else { |
|
| 547 | + throw new PropelException('filterByChannel() only accepts arguments of type \Jalle19\StatusManager\Database\Channel or Collection'); |
|
| 548 | + } |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + /** |
|
| 552 | + * Adds a JOIN clause to the query using the Channel relation |
|
| 553 | + * |
|
| 554 | + * @param string $relationAlias optional alias for the relation |
|
| 555 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 556 | + * |
|
| 557 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 558 | + */ |
|
| 559 | + public function joinChannel($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 560 | + { |
|
| 561 | + $tableMap = $this->getTableMap(); |
|
| 562 | + $relationMap = $tableMap->getRelation('Channel'); |
|
| 563 | + |
|
| 564 | + // create a ModelJoin object for this join |
|
| 565 | + $join = new ModelJoin(); |
|
| 566 | + $join->setJoinType($joinType); |
|
| 567 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 568 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 569 | + $join->setPreviousJoin($previousJoin); |
|
| 570 | + } |
|
| 571 | + |
|
| 572 | + // add the ModelJoin to the current object |
|
| 573 | + if ($relationAlias) { |
|
| 574 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 575 | + $this->addJoinObject($join, $relationAlias); |
|
| 576 | + } else { |
|
| 577 | + $this->addJoinObject($join, 'Channel'); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + return $this; |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + /** |
|
| 584 | + * Use the Channel relation Channel object |
|
| 585 | + * |
|
| 586 | + * @see useQuery() |
|
| 587 | + * |
|
| 588 | + * @param string $relationAlias optional alias for the relation, |
|
| 589 | + * to be used as main alias in the secondary query |
|
| 590 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 591 | + * |
|
| 592 | + * @return \Jalle19\StatusManager\Database\ChannelQuery A secondary query class using the current class as primary query |
|
| 593 | + */ |
|
| 594 | + public function useChannelQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 595 | + { |
|
| 596 | + return $this |
|
| 597 | + ->joinChannel($relationAlias, $joinType) |
|
| 598 | + ->useQuery($relationAlias ? $relationAlias : 'Channel', '\Jalle19\StatusManager\Database\ChannelQuery'); |
|
| 599 | + } |
|
| 600 | + |
|
| 601 | + /** |
|
| 602 | + * Filter the query by a related \Jalle19\StatusManager\Database\Subscription object |
|
| 603 | + * |
|
| 604 | + * @param \Jalle19\StatusManager\Database\Subscription|ObjectCollection $subscription the related object to use as filter |
|
| 605 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 606 | + * |
|
| 607 | + * @return ChildInstanceQuery The current query, for fluid interface |
|
| 608 | + */ |
|
| 609 | + public function filterBySubscription($subscription, $comparison = null) |
|
| 610 | + { |
|
| 611 | + if ($subscription instanceof \Jalle19\StatusManager\Database\Subscription) { |
|
| 612 | + return $this |
|
| 613 | + ->addUsingAlias(InstanceTableMap::COL_NAME, $subscription->getInstanceName(), $comparison); |
|
| 614 | + } elseif ($subscription instanceof ObjectCollection) { |
|
| 615 | + return $this |
|
| 616 | + ->useSubscriptionQuery() |
|
| 617 | + ->filterByPrimaryKeys($subscription->getPrimaryKeys()) |
|
| 618 | + ->endUse(); |
|
| 619 | + } else { |
|
| 620 | + throw new PropelException('filterBySubscription() only accepts arguments of type \Jalle19\StatusManager\Database\Subscription or Collection'); |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + /** |
|
| 625 | + * Adds a JOIN clause to the query using the Subscription relation |
|
| 626 | + * |
|
| 627 | + * @param string $relationAlias optional alias for the relation |
|
| 628 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 629 | + * |
|
| 630 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 631 | + */ |
|
| 632 | + public function joinSubscription($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 633 | + { |
|
| 634 | + $tableMap = $this->getTableMap(); |
|
| 635 | + $relationMap = $tableMap->getRelation('Subscription'); |
|
| 636 | + |
|
| 637 | + // create a ModelJoin object for this join |
|
| 638 | + $join = new ModelJoin(); |
|
| 639 | + $join->setJoinType($joinType); |
|
| 640 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 641 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 642 | + $join->setPreviousJoin($previousJoin); |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + // add the ModelJoin to the current object |
|
| 646 | + if ($relationAlias) { |
|
| 647 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 648 | + $this->addJoinObject($join, $relationAlias); |
|
| 649 | + } else { |
|
| 650 | + $this->addJoinObject($join, 'Subscription'); |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + return $this; |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Use the Subscription relation Subscription object |
|
| 658 | + * |
|
| 659 | + * @see useQuery() |
|
| 660 | + * |
|
| 661 | + * @param string $relationAlias optional alias for the relation, |
|
| 662 | + * to be used as main alias in the secondary query |
|
| 663 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 664 | + * |
|
| 665 | + * @return \Jalle19\StatusManager\Database\SubscriptionQuery A secondary query class using the current class as primary query |
|
| 666 | + */ |
|
| 667 | + public function useSubscriptionQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 668 | + { |
|
| 669 | + return $this |
|
| 670 | + ->joinSubscription($relationAlias, $joinType) |
|
| 671 | + ->useQuery($relationAlias ? $relationAlias : 'Subscription', '\Jalle19\StatusManager\Database\SubscriptionQuery'); |
|
| 672 | + } |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Exclude object from result |
|
| 676 | + * |
|
| 677 | + * @param ChildInstance $instance Object to remove from the list of results |
|
| 678 | + * |
|
| 679 | + * @return $this|ChildInstanceQuery The current query, for fluid interface |
|
| 680 | + */ |
|
| 681 | + public function prune($instance = null) |
|
| 682 | + { |
|
| 683 | + if ($instance) { |
|
| 684 | + $this->addUsingAlias(InstanceTableMap::COL_NAME, $instance->getName(), Criteria::NOT_EQUAL); |
|
| 685 | + } |
|
| 686 | + |
|
| 687 | + return $this; |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * Deletes all rows from the instance table. |
|
| 692 | + * |
|
| 693 | + * @param ConnectionInterface $con the connection to use |
|
| 694 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
| 695 | + */ |
|
| 696 | + public function doDeleteAll(ConnectionInterface $con = null) |
|
| 697 | + { |
|
| 698 | + if (null === $con) { |
|
| 699 | + $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + // use transaction because $criteria could contain info |
|
| 703 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 704 | + return $con->transaction(function () use ($con) { |
|
| 705 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 706 | + $affectedRows += parent::doDeleteAll($con); |
|
| 707 | + // Because this db requires some delete cascade/set null emulation, we have to |
|
| 708 | + // clear the cached instance *after* the emulation has happened (since |
|
| 709 | + // instances get re-added by the select statement contained therein). |
|
| 710 | + InstanceTableMap::clearInstancePool(); |
|
| 711 | + InstanceTableMap::clearRelatedInstancePool(); |
|
| 712 | + |
|
| 713 | + return $affectedRows; |
|
| 714 | + }); |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * Performs a DELETE on the database based on the current ModelCriteria |
|
| 719 | + * |
|
| 720 | + * @param ConnectionInterface $con the connection to use |
|
| 721 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
| 722 | + * if supported by native driver or if emulated using Propel. |
|
| 723 | + * @throws PropelException Any exceptions caught during processing will be |
|
| 724 | + * rethrown wrapped into a PropelException. |
|
| 725 | + */ |
|
| 726 | + public function delete(ConnectionInterface $con = null) |
|
| 727 | + { |
|
| 728 | + if (null === $con) { |
|
| 729 | + $con = Propel::getServiceContainer()->getWriteConnection(InstanceTableMap::DATABASE_NAME); |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + $criteria = $this; |
|
| 733 | + |
|
| 734 | + // Set the correct dbName |
|
| 735 | + $criteria->setDbName(InstanceTableMap::DATABASE_NAME); |
|
| 736 | + |
|
| 737 | + // use transaction because $criteria could contain info |
|
| 738 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 739 | + return $con->transaction(function () use ($con, $criteria) { |
|
| 740 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 741 | + |
|
| 742 | + InstanceTableMap::removeInstanceFromPool($criteria); |
|
| 743 | + |
|
| 744 | + $affectedRows += ModelCriteria::delete($con); |
|
| 745 | + InstanceTableMap::clearRelatedInstancePool(); |
|
| 746 | + |
|
| 747 | + return $affectedRows; |
|
| 748 | + }); |
|
| 749 | + } |
|
| 751 | 750 | |
| 752 | 751 | } // InstanceQuery |
@@ -37,1993 +37,1993 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | abstract class Subscription implements ActiveRecordInterface |
| 39 | 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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(). |
|
| 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 | - 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 |
|
| 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | + 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 | 1682 | guarantee the related object contains a reference |
| 1683 | 1683 | to this object. This level of coupling may, however, be |
| 1684 | 1684 | undesirable since it could result in an only partially populated collection |
| 1685 | 1685 | in the referenced object. |
| 1686 | 1686 | $this->aInstance->addSubscriptions($this); |
| 1687 | 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 |
|
| 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 | 1733 | guarantee the related object contains a reference |
| 1734 | 1734 | to this object. This level of coupling may, however, be |
| 1735 | 1735 | undesirable since it could result in an only partially populated collection |
| 1736 | 1736 | in the referenced object. |
| 1737 | 1737 | $this->aInput->addSubscriptions($this); |
| 1738 | 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 | - 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 | - 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 |
|
| 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 | + 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 | + 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 | 1784 | guarantee the related object contains a reference |
| 1785 | 1785 | to this object. This level of coupling may, however, be |
| 1786 | 1786 | undesirable since it could result in an only partially populated collection |
| 1787 | 1787 | in the referenced object. |
| 1788 | 1788 | $this->aUser->addSubscriptions($this); |
| 1789 | 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 | - 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 |
|
| 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 | + 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 | 1835 | guarantee the related object contains a reference |
| 1836 | 1836 | to this object. This level of coupling may, however, be |
| 1837 | 1837 | undesirable since it could result in an only partially populated collection |
| 1838 | 1838 | in the referenced object. |
| 1839 | 1839 | $this->aChannel->addSubscriptions($this); |
| 1840 | 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 | - 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 | - } |
|
| 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 | + 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 | 2028 | |
| 2029 | 2029 | } |
@@ -105,7 +105,6 @@ discard block |
||
| 105 | 105 | * @method ChildSubscription findOneByStopped(string $stopped) Return the first ChildSubscription filtered by the stopped column |
| 106 | 106 | * @method ChildSubscription findOneByTitle(string $title) Return the first ChildSubscription filtered by the title column |
| 107 | 107 | * @method ChildSubscription findOneByService(string $service) Return the first ChildSubscription filtered by the service column * |
| 108 | - |
|
| 109 | 108 | * @method ChildSubscription requirePk($key, ConnectionInterface $con = null) Return the ChildSubscription by primary key and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
| 110 | 109 | * @method ChildSubscription requireOne(ConnectionInterface $con = null) Return the first ChildSubscription matching the query and throws \Propel\Runtime\Exception\EntityNotFoundException when not found |
| 111 | 110 | * |
@@ -136,936 +135,936 @@ discard block |
||
| 136 | 135 | */ |
| 137 | 136 | abstract class SubscriptionQuery extends ModelCriteria |
| 138 | 137 | { |
| 139 | - protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Initializes internal state of \Jalle19\StatusManager\Database\Base\SubscriptionQuery object. |
|
| 143 | - * |
|
| 144 | - * @param string $dbName The database name |
|
| 145 | - * @param string $modelName The phpName of a model, e.g. 'Book' |
|
| 146 | - * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
| 147 | - */ |
|
| 148 | - public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Subscription', $modelAlias = null) |
|
| 149 | - { |
|
| 150 | - parent::__construct($dbName, $modelName, $modelAlias); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Returns a new ChildSubscriptionQuery object. |
|
| 155 | - * |
|
| 156 | - * @param string $modelAlias The alias of a model in the query |
|
| 157 | - * @param Criteria $criteria Optional Criteria to build the query from |
|
| 158 | - * |
|
| 159 | - * @return ChildSubscriptionQuery |
|
| 160 | - */ |
|
| 161 | - public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 162 | - { |
|
| 163 | - if ($criteria instanceof ChildSubscriptionQuery) { |
|
| 164 | - return $criteria; |
|
| 165 | - } |
|
| 166 | - $query = new ChildSubscriptionQuery(); |
|
| 167 | - if (null !== $modelAlias) { |
|
| 168 | - $query->setModelAlias($modelAlias); |
|
| 169 | - } |
|
| 170 | - if ($criteria instanceof Criteria) { |
|
| 171 | - $query->mergeWith($criteria); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - return $query; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Find object by primary key. |
|
| 179 | - * Propel uses the instance pool to skip the database if the object exists. |
|
| 180 | - * Go fast if the query is untouched. |
|
| 181 | - * |
|
| 182 | - * <code> |
|
| 183 | - * $obj = $c->findPk(12, $con); |
|
| 184 | - * </code> |
|
| 185 | - * |
|
| 186 | - * @param mixed $key Primary key to use for the query |
|
| 187 | - * @param ConnectionInterface $con an optional connection object |
|
| 188 | - * |
|
| 189 | - * @return ChildSubscription|array|mixed the result, formatted by the current formatter |
|
| 190 | - */ |
|
| 191 | - public function findPk($key, ConnectionInterface $con = null) |
|
| 192 | - { |
|
| 193 | - if ($key === null) { |
|
| 194 | - return null; |
|
| 195 | - } |
|
| 196 | - if ((null !== ($obj = SubscriptionTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
| 197 | - // the object is already in the instance pool |
|
| 198 | - return $obj; |
|
| 199 | - } |
|
| 200 | - if ($con === null) { |
|
| 201 | - $con = Propel::getServiceContainer()->getReadConnection(SubscriptionTableMap::DATABASE_NAME); |
|
| 202 | - } |
|
| 203 | - $this->basePreSelect($con); |
|
| 204 | - if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
| 205 | - || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
| 206 | - || $this->map || $this->having || $this->joins) { |
|
| 207 | - return $this->findPkComplex($key, $con); |
|
| 208 | - } else { |
|
| 209 | - return $this->findPkSimple($key, $con); |
|
| 210 | - } |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Find object by primary key using raw SQL to go fast. |
|
| 215 | - * Bypass doSelect() and the object formatter by using generated code. |
|
| 216 | - * |
|
| 217 | - * @param mixed $key Primary key to use for the query |
|
| 218 | - * @param ConnectionInterface $con A connection object |
|
| 219 | - * |
|
| 220 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 221 | - * |
|
| 222 | - * @return ChildSubscription A model object, or null if the key is not found |
|
| 223 | - */ |
|
| 224 | - protected function findPkSimple($key, ConnectionInterface $con) |
|
| 225 | - { |
|
| 226 | - $sql = 'SELECT id, instance_name, input_uuid, user_id, channel_id, subscription_id, started, stopped, title, service FROM subscription WHERE id = :p0'; |
|
| 227 | - try { |
|
| 228 | - $stmt = $con->prepare($sql); |
|
| 229 | - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
| 230 | - $stmt->execute(); |
|
| 231 | - } catch (Exception $e) { |
|
| 232 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 233 | - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
| 234 | - } |
|
| 235 | - $obj = null; |
|
| 236 | - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
| 237 | - /** @var ChildSubscription $obj */ |
|
| 238 | - $obj = new ChildSubscription(); |
|
| 239 | - $obj->hydrate($row); |
|
| 240 | - SubscriptionTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
| 241 | - } |
|
| 242 | - $stmt->closeCursor(); |
|
| 243 | - |
|
| 244 | - return $obj; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * Find object by primary key. |
|
| 249 | - * |
|
| 250 | - * @param mixed $key Primary key to use for the query |
|
| 251 | - * @param ConnectionInterface $con A connection object |
|
| 252 | - * |
|
| 253 | - * @return ChildSubscription|array|mixed the result, formatted by the current formatter |
|
| 254 | - */ |
|
| 255 | - protected function findPkComplex($key, ConnectionInterface $con) |
|
| 256 | - { |
|
| 257 | - // As the query uses a PK condition, no limit(1) is necessary. |
|
| 258 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 259 | - $dataFetcher = $criteria |
|
| 260 | - ->filterByPrimaryKey($key) |
|
| 261 | - ->doSelect($con); |
|
| 262 | - |
|
| 263 | - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Find objects by primary key |
|
| 268 | - * <code> |
|
| 269 | - * $objs = $c->findPks(array(12, 56, 832), $con); |
|
| 270 | - * </code> |
|
| 271 | - * @param array $keys Primary keys to use for the query |
|
| 272 | - * @param ConnectionInterface $con an optional connection object |
|
| 273 | - * |
|
| 274 | - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
| 275 | - */ |
|
| 276 | - public function findPks($keys, ConnectionInterface $con = null) |
|
| 277 | - { |
|
| 278 | - if (null === $con) { |
|
| 279 | - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
| 280 | - } |
|
| 281 | - $this->basePreSelect($con); |
|
| 282 | - $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 283 | - $dataFetcher = $criteria |
|
| 284 | - ->filterByPrimaryKeys($keys) |
|
| 285 | - ->doSelect($con); |
|
| 286 | - |
|
| 287 | - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * Filter the query by primary key |
|
| 292 | - * |
|
| 293 | - * @param mixed $key Primary key to use for the query |
|
| 294 | - * |
|
| 295 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 296 | - */ |
|
| 297 | - public function filterByPrimaryKey($key) |
|
| 298 | - { |
|
| 299 | - |
|
| 300 | - return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $key, Criteria::EQUAL); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Filter the query by a list of primary keys |
|
| 305 | - * |
|
| 306 | - * @param array $keys The list of primary key to use for the query |
|
| 307 | - * |
|
| 308 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 309 | - */ |
|
| 310 | - public function filterByPrimaryKeys($keys) |
|
| 311 | - { |
|
| 312 | - |
|
| 313 | - return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $keys, Criteria::IN); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - /** |
|
| 317 | - * Filter the query on the id column |
|
| 318 | - * |
|
| 319 | - * Example usage: |
|
| 320 | - * <code> |
|
| 321 | - * $query->filterById(1234); // WHERE id = 1234 |
|
| 322 | - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
| 323 | - * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
| 324 | - * </code> |
|
| 325 | - * |
|
| 326 | - * @param mixed $id The value to use as filter. |
|
| 327 | - * Use scalar values for equality. |
|
| 328 | - * Use array values for in_array() equivalent. |
|
| 329 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 330 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 331 | - * |
|
| 332 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 333 | - */ |
|
| 334 | - public function filterById($id = null, $comparison = null) |
|
| 335 | - { |
|
| 336 | - if (is_array($id)) { |
|
| 337 | - $useMinMax = false; |
|
| 338 | - if (isset($id['min'])) { |
|
| 339 | - $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
| 340 | - $useMinMax = true; |
|
| 341 | - } |
|
| 342 | - if (isset($id['max'])) { |
|
| 343 | - $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
| 344 | - $useMinMax = true; |
|
| 345 | - } |
|
| 346 | - if ($useMinMax) { |
|
| 347 | - return $this; |
|
| 348 | - } |
|
| 349 | - if (null === $comparison) { |
|
| 350 | - $comparison = Criteria::IN; |
|
| 351 | - } |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id, $comparison); |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - /** |
|
| 358 | - * Filter the query on the instance_name column |
|
| 359 | - * |
|
| 360 | - * Example usage: |
|
| 361 | - * <code> |
|
| 362 | - * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
| 363 | - * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
| 364 | - * </code> |
|
| 365 | - * |
|
| 366 | - * @param string $instanceName The value to use as filter. |
|
| 367 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 368 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 369 | - * |
|
| 370 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 371 | - */ |
|
| 372 | - public function filterByInstanceName($instanceName = null, $comparison = null) |
|
| 373 | - { |
|
| 374 | - if (null === $comparison) { |
|
| 375 | - if (is_array($instanceName)) { |
|
| 376 | - $comparison = Criteria::IN; |
|
| 377 | - } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
| 378 | - $instanceName = str_replace('*', '%', $instanceName); |
|
| 379 | - $comparison = Criteria::LIKE; |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return $this->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * Filter the query on the input_uuid column |
|
| 388 | - * |
|
| 389 | - * Example usage: |
|
| 390 | - * <code> |
|
| 391 | - * $query->filterByInputUuid('fooValue'); // WHERE input_uuid = 'fooValue' |
|
| 392 | - * $query->filterByInputUuid('%fooValue%'); // WHERE input_uuid LIKE '%fooValue%' |
|
| 393 | - * </code> |
|
| 394 | - * |
|
| 395 | - * @param string $inputUuid The value to use as filter. |
|
| 396 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 397 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 398 | - * |
|
| 399 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 400 | - */ |
|
| 401 | - public function filterByInputUuid($inputUuid = null, $comparison = null) |
|
| 402 | - { |
|
| 403 | - if (null === $comparison) { |
|
| 404 | - if (is_array($inputUuid)) { |
|
| 405 | - $comparison = Criteria::IN; |
|
| 406 | - } elseif (preg_match('/[\%\*]/', $inputUuid)) { |
|
| 407 | - $inputUuid = str_replace('*', '%', $inputUuid); |
|
| 408 | - $comparison = Criteria::LIKE; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - return $this->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $inputUuid, $comparison); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * Filter the query on the user_id column |
|
| 417 | - * |
|
| 418 | - * Example usage: |
|
| 419 | - * <code> |
|
| 420 | - * $query->filterByUserId(1234); // WHERE user_id = 1234 |
|
| 421 | - * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34) |
|
| 422 | - * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12 |
|
| 423 | - * </code> |
|
| 424 | - * |
|
| 425 | - * @see filterByUser() |
|
| 426 | - * |
|
| 427 | - * @param mixed $userId The value to use as filter. |
|
| 428 | - * Use scalar values for equality. |
|
| 429 | - * Use array values for in_array() equivalent. |
|
| 430 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 431 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 432 | - * |
|
| 433 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 434 | - */ |
|
| 435 | - public function filterByUserId($userId = null, $comparison = null) |
|
| 436 | - { |
|
| 437 | - if (is_array($userId)) { |
|
| 438 | - $useMinMax = false; |
|
| 439 | - if (isset($userId['min'])) { |
|
| 440 | - $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId['min'], Criteria::GREATER_EQUAL); |
|
| 441 | - $useMinMax = true; |
|
| 442 | - } |
|
| 443 | - if (isset($userId['max'])) { |
|
| 444 | - $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId['max'], Criteria::LESS_EQUAL); |
|
| 445 | - $useMinMax = true; |
|
| 446 | - } |
|
| 447 | - if ($useMinMax) { |
|
| 448 | - return $this; |
|
| 449 | - } |
|
| 450 | - if (null === $comparison) { |
|
| 451 | - $comparison = Criteria::IN; |
|
| 452 | - } |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - return $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId, $comparison); |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - /** |
|
| 459 | - * Filter the query on the channel_id column |
|
| 460 | - * |
|
| 461 | - * Example usage: |
|
| 462 | - * <code> |
|
| 463 | - * $query->filterByChannelId(1234); // WHERE channel_id = 1234 |
|
| 464 | - * $query->filterByChannelId(array(12, 34)); // WHERE channel_id IN (12, 34) |
|
| 465 | - * $query->filterByChannelId(array('min' => 12)); // WHERE channel_id > 12 |
|
| 466 | - * </code> |
|
| 467 | - * |
|
| 468 | - * @see filterByChannel() |
|
| 469 | - * |
|
| 470 | - * @param mixed $channelId The value to use as filter. |
|
| 471 | - * Use scalar values for equality. |
|
| 472 | - * Use array values for in_array() equivalent. |
|
| 473 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 474 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 475 | - * |
|
| 476 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 477 | - */ |
|
| 478 | - public function filterByChannelId($channelId = null, $comparison = null) |
|
| 479 | - { |
|
| 480 | - if (is_array($channelId)) { |
|
| 481 | - $useMinMax = false; |
|
| 482 | - if (isset($channelId['min'])) { |
|
| 483 | - $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId['min'], Criteria::GREATER_EQUAL); |
|
| 484 | - $useMinMax = true; |
|
| 485 | - } |
|
| 486 | - if (isset($channelId['max'])) { |
|
| 487 | - $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId['max'], Criteria::LESS_EQUAL); |
|
| 488 | - $useMinMax = true; |
|
| 489 | - } |
|
| 490 | - if ($useMinMax) { |
|
| 491 | - return $this; |
|
| 492 | - } |
|
| 493 | - if (null === $comparison) { |
|
| 494 | - $comparison = Criteria::IN; |
|
| 495 | - } |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - return $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId, $comparison); |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - /** |
|
| 502 | - * Filter the query on the subscription_id column |
|
| 503 | - * |
|
| 504 | - * Example usage: |
|
| 505 | - * <code> |
|
| 506 | - * $query->filterBySubscriptionId(1234); // WHERE subscription_id = 1234 |
|
| 507 | - * $query->filterBySubscriptionId(array(12, 34)); // WHERE subscription_id IN (12, 34) |
|
| 508 | - * $query->filterBySubscriptionId(array('min' => 12)); // WHERE subscription_id > 12 |
|
| 509 | - * </code> |
|
| 510 | - * |
|
| 511 | - * @param mixed $subscriptionId The value to use as filter. |
|
| 512 | - * Use scalar values for equality. |
|
| 513 | - * Use array values for in_array() equivalent. |
|
| 514 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 515 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 516 | - * |
|
| 517 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 518 | - */ |
|
| 519 | - public function filterBySubscriptionId($subscriptionId = null, $comparison = null) |
|
| 520 | - { |
|
| 521 | - if (is_array($subscriptionId)) { |
|
| 522 | - $useMinMax = false; |
|
| 523 | - if (isset($subscriptionId['min'])) { |
|
| 524 | - $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId['min'], Criteria::GREATER_EQUAL); |
|
| 525 | - $useMinMax = true; |
|
| 526 | - } |
|
| 527 | - if (isset($subscriptionId['max'])) { |
|
| 528 | - $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId['max'], Criteria::LESS_EQUAL); |
|
| 529 | - $useMinMax = true; |
|
| 530 | - } |
|
| 531 | - if ($useMinMax) { |
|
| 532 | - return $this; |
|
| 533 | - } |
|
| 534 | - if (null === $comparison) { |
|
| 535 | - $comparison = Criteria::IN; |
|
| 536 | - } |
|
| 537 | - } |
|
| 538 | - |
|
| 539 | - return $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId, $comparison); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * Filter the query on the started column |
|
| 544 | - * |
|
| 545 | - * Example usage: |
|
| 546 | - * <code> |
|
| 547 | - * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
|
| 548 | - * $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
|
| 549 | - * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
|
| 550 | - * </code> |
|
| 551 | - * |
|
| 552 | - * @param mixed $started The value to use as filter. |
|
| 553 | - * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
| 554 | - * Empty strings are treated as NULL. |
|
| 555 | - * Use scalar values for equality. |
|
| 556 | - * Use array values for in_array() equivalent. |
|
| 557 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 558 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 559 | - * |
|
| 560 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 561 | - */ |
|
| 562 | - public function filterByStarted($started = null, $comparison = null) |
|
| 563 | - { |
|
| 564 | - if (is_array($started)) { |
|
| 565 | - $useMinMax = false; |
|
| 566 | - if (isset($started['min'])) { |
|
| 567 | - $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
|
| 568 | - $useMinMax = true; |
|
| 569 | - } |
|
| 570 | - if (isset($started['max'])) { |
|
| 571 | - $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
|
| 572 | - $useMinMax = true; |
|
| 573 | - } |
|
| 574 | - if ($useMinMax) { |
|
| 575 | - return $this; |
|
| 576 | - } |
|
| 577 | - if (null === $comparison) { |
|
| 578 | - $comparison = Criteria::IN; |
|
| 579 | - } |
|
| 580 | - } |
|
| 581 | - |
|
| 582 | - return $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started, $comparison); |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - /** |
|
| 586 | - * Filter the query on the stopped column |
|
| 587 | - * |
|
| 588 | - * Example usage: |
|
| 589 | - * <code> |
|
| 590 | - * $query->filterByStopped('2011-03-14'); // WHERE stopped = '2011-03-14' |
|
| 591 | - * $query->filterByStopped('now'); // WHERE stopped = '2011-03-14' |
|
| 592 | - * $query->filterByStopped(array('max' => 'yesterday')); // WHERE stopped > '2011-03-13' |
|
| 593 | - * </code> |
|
| 594 | - * |
|
| 595 | - * @param mixed $stopped The value to use as filter. |
|
| 596 | - * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
| 597 | - * Empty strings are treated as NULL. |
|
| 598 | - * Use scalar values for equality. |
|
| 599 | - * Use array values for in_array() equivalent. |
|
| 600 | - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 601 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 602 | - * |
|
| 603 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 604 | - */ |
|
| 605 | - public function filterByStopped($stopped = null, $comparison = null) |
|
| 606 | - { |
|
| 607 | - if (is_array($stopped)) { |
|
| 608 | - $useMinMax = false; |
|
| 609 | - if (isset($stopped['min'])) { |
|
| 610 | - $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped['min'], Criteria::GREATER_EQUAL); |
|
| 611 | - $useMinMax = true; |
|
| 612 | - } |
|
| 613 | - if (isset($stopped['max'])) { |
|
| 614 | - $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped['max'], Criteria::LESS_EQUAL); |
|
| 615 | - $useMinMax = true; |
|
| 616 | - } |
|
| 617 | - if ($useMinMax) { |
|
| 618 | - return $this; |
|
| 619 | - } |
|
| 620 | - if (null === $comparison) { |
|
| 621 | - $comparison = Criteria::IN; |
|
| 622 | - } |
|
| 623 | - } |
|
| 624 | - |
|
| 625 | - return $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped, $comparison); |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - /** |
|
| 629 | - * Filter the query on the title column |
|
| 630 | - * |
|
| 631 | - * Example usage: |
|
| 632 | - * <code> |
|
| 633 | - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' |
|
| 634 | - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' |
|
| 635 | - * </code> |
|
| 636 | - * |
|
| 637 | - * @param string $title The value to use as filter. |
|
| 638 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 639 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 640 | - * |
|
| 641 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 642 | - */ |
|
| 643 | - public function filterByTitle($title = null, $comparison = null) |
|
| 644 | - { |
|
| 645 | - if (null === $comparison) { |
|
| 646 | - if (is_array($title)) { |
|
| 647 | - $comparison = Criteria::IN; |
|
| 648 | - } elseif (preg_match('/[\%\*]/', $title)) { |
|
| 649 | - $title = str_replace('*', '%', $title); |
|
| 650 | - $comparison = Criteria::LIKE; |
|
| 651 | - } |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - return $this->addUsingAlias(SubscriptionTableMap::COL_TITLE, $title, $comparison); |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - /** |
|
| 658 | - * Filter the query on the service column |
|
| 659 | - * |
|
| 660 | - * Example usage: |
|
| 661 | - * <code> |
|
| 662 | - * $query->filterByService('fooValue'); // WHERE service = 'fooValue' |
|
| 663 | - * $query->filterByService('%fooValue%'); // WHERE service LIKE '%fooValue%' |
|
| 664 | - * </code> |
|
| 665 | - * |
|
| 666 | - * @param string $service The value to use as filter. |
|
| 667 | - * Accepts wildcards (* and % trigger a LIKE) |
|
| 668 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 669 | - * |
|
| 670 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 671 | - */ |
|
| 672 | - public function filterByService($service = null, $comparison = null) |
|
| 673 | - { |
|
| 674 | - if (null === $comparison) { |
|
| 675 | - if (is_array($service)) { |
|
| 676 | - $comparison = Criteria::IN; |
|
| 677 | - } elseif (preg_match('/[\%\*]/', $service)) { |
|
| 678 | - $service = str_replace('*', '%', $service); |
|
| 679 | - $comparison = Criteria::LIKE; |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - return $this->addUsingAlias(SubscriptionTableMap::COL_SERVICE, $service, $comparison); |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - /** |
|
| 687 | - * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
| 688 | - * |
|
| 689 | - * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
| 690 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 691 | - * |
|
| 692 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 693 | - * |
|
| 694 | - * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 695 | - */ |
|
| 696 | - public function filterByInstance($instance, $comparison = null) |
|
| 697 | - { |
|
| 698 | - if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
| 699 | - return $this |
|
| 700 | - ->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
| 701 | - } elseif ($instance instanceof ObjectCollection) { |
|
| 702 | - if (null === $comparison) { |
|
| 703 | - $comparison = Criteria::IN; |
|
| 704 | - } |
|
| 705 | - |
|
| 706 | - return $this |
|
| 707 | - ->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
| 708 | - } else { |
|
| 709 | - throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
| 710 | - } |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - /** |
|
| 714 | - * Adds a JOIN clause to the query using the Instance relation |
|
| 715 | - * |
|
| 716 | - * @param string $relationAlias optional alias for the relation |
|
| 717 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 718 | - * |
|
| 719 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 720 | - */ |
|
| 721 | - public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 722 | - { |
|
| 723 | - $tableMap = $this->getTableMap(); |
|
| 724 | - $relationMap = $tableMap->getRelation('Instance'); |
|
| 725 | - |
|
| 726 | - // create a ModelJoin object for this join |
|
| 727 | - $join = new ModelJoin(); |
|
| 728 | - $join->setJoinType($joinType); |
|
| 729 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 730 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 731 | - $join->setPreviousJoin($previousJoin); |
|
| 732 | - } |
|
| 733 | - |
|
| 734 | - // add the ModelJoin to the current object |
|
| 735 | - if ($relationAlias) { |
|
| 736 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 737 | - $this->addJoinObject($join, $relationAlias); |
|
| 738 | - } else { |
|
| 739 | - $this->addJoinObject($join, 'Instance'); |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - return $this; |
|
| 743 | - } |
|
| 744 | - |
|
| 745 | - /** |
|
| 746 | - * Use the Instance relation Instance object |
|
| 747 | - * |
|
| 748 | - * @see useQuery() |
|
| 749 | - * |
|
| 750 | - * @param string $relationAlias optional alias for the relation, |
|
| 751 | - * to be used as main alias in the secondary query |
|
| 752 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 753 | - * |
|
| 754 | - * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
| 755 | - */ |
|
| 756 | - public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 757 | - { |
|
| 758 | - return $this |
|
| 759 | - ->joinInstance($relationAlias, $joinType) |
|
| 760 | - ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
| 761 | - } |
|
| 762 | - |
|
| 763 | - /** |
|
| 764 | - * Filter the query by a related \Jalle19\StatusManager\Database\Input object |
|
| 765 | - * |
|
| 766 | - * @param \Jalle19\StatusManager\Database\Input|ObjectCollection $input The related object(s) to use as filter |
|
| 767 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 768 | - * |
|
| 769 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 770 | - * |
|
| 771 | - * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 772 | - */ |
|
| 773 | - public function filterByInput($input, $comparison = null) |
|
| 774 | - { |
|
| 775 | - if ($input instanceof \Jalle19\StatusManager\Database\Input) { |
|
| 776 | - return $this |
|
| 777 | - ->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $input->getUuid(), $comparison); |
|
| 778 | - } elseif ($input instanceof ObjectCollection) { |
|
| 779 | - if (null === $comparison) { |
|
| 780 | - $comparison = Criteria::IN; |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - return $this |
|
| 784 | - ->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $input->toKeyValue('PrimaryKey', 'Uuid'), $comparison); |
|
| 785 | - } else { |
|
| 786 | - throw new PropelException('filterByInput() only accepts arguments of type \Jalle19\StatusManager\Database\Input or Collection'); |
|
| 787 | - } |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - /** |
|
| 791 | - * Adds a JOIN clause to the query using the Input relation |
|
| 792 | - * |
|
| 793 | - * @param string $relationAlias optional alias for the relation |
|
| 794 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 795 | - * |
|
| 796 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 797 | - */ |
|
| 798 | - public function joinInput($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 799 | - { |
|
| 800 | - $tableMap = $this->getTableMap(); |
|
| 801 | - $relationMap = $tableMap->getRelation('Input'); |
|
| 802 | - |
|
| 803 | - // create a ModelJoin object for this join |
|
| 804 | - $join = new ModelJoin(); |
|
| 805 | - $join->setJoinType($joinType); |
|
| 806 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 807 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 808 | - $join->setPreviousJoin($previousJoin); |
|
| 809 | - } |
|
| 810 | - |
|
| 811 | - // add the ModelJoin to the current object |
|
| 812 | - if ($relationAlias) { |
|
| 813 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 814 | - $this->addJoinObject($join, $relationAlias); |
|
| 815 | - } else { |
|
| 816 | - $this->addJoinObject($join, 'Input'); |
|
| 817 | - } |
|
| 818 | - |
|
| 819 | - return $this; |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - /** |
|
| 823 | - * Use the Input relation Input object |
|
| 824 | - * |
|
| 825 | - * @see useQuery() |
|
| 826 | - * |
|
| 827 | - * @param string $relationAlias optional alias for the relation, |
|
| 828 | - * to be used as main alias in the secondary query |
|
| 829 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 830 | - * |
|
| 831 | - * @return \Jalle19\StatusManager\Database\InputQuery A secondary query class using the current class as primary query |
|
| 832 | - */ |
|
| 833 | - public function useInputQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 834 | - { |
|
| 835 | - return $this |
|
| 836 | - ->joinInput($relationAlias, $joinType) |
|
| 837 | - ->useQuery($relationAlias ? $relationAlias : 'Input', '\Jalle19\StatusManager\Database\InputQuery'); |
|
| 838 | - } |
|
| 839 | - |
|
| 840 | - /** |
|
| 841 | - * Filter the query by a related \Jalle19\StatusManager\Database\User object |
|
| 842 | - * |
|
| 843 | - * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user The related object(s) to use as filter |
|
| 844 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 845 | - * |
|
| 846 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 847 | - * |
|
| 848 | - * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 849 | - */ |
|
| 850 | - public function filterByUser($user, $comparison = null) |
|
| 851 | - { |
|
| 852 | - if ($user instanceof \Jalle19\StatusManager\Database\User) { |
|
| 853 | - return $this |
|
| 854 | - ->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $user->getId(), $comparison); |
|
| 855 | - } elseif ($user instanceof ObjectCollection) { |
|
| 856 | - if (null === $comparison) { |
|
| 857 | - $comparison = Criteria::IN; |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - return $this |
|
| 861 | - ->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); |
|
| 862 | - } else { |
|
| 863 | - throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection'); |
|
| 864 | - } |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - /** |
|
| 868 | - * Adds a JOIN clause to the query using the User relation |
|
| 869 | - * |
|
| 870 | - * @param string $relationAlias optional alias for the relation |
|
| 871 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 872 | - * |
|
| 873 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 874 | - */ |
|
| 875 | - public function joinUser($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 876 | - { |
|
| 877 | - $tableMap = $this->getTableMap(); |
|
| 878 | - $relationMap = $tableMap->getRelation('User'); |
|
| 879 | - |
|
| 880 | - // create a ModelJoin object for this join |
|
| 881 | - $join = new ModelJoin(); |
|
| 882 | - $join->setJoinType($joinType); |
|
| 883 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 884 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 885 | - $join->setPreviousJoin($previousJoin); |
|
| 886 | - } |
|
| 887 | - |
|
| 888 | - // add the ModelJoin to the current object |
|
| 889 | - if ($relationAlias) { |
|
| 890 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 891 | - $this->addJoinObject($join, $relationAlias); |
|
| 892 | - } else { |
|
| 893 | - $this->addJoinObject($join, 'User'); |
|
| 894 | - } |
|
| 895 | - |
|
| 896 | - return $this; |
|
| 897 | - } |
|
| 898 | - |
|
| 899 | - /** |
|
| 900 | - * Use the User relation User object |
|
| 901 | - * |
|
| 902 | - * @see useQuery() |
|
| 903 | - * |
|
| 904 | - * @param string $relationAlias optional alias for the relation, |
|
| 905 | - * to be used as main alias in the secondary query |
|
| 906 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 907 | - * |
|
| 908 | - * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query |
|
| 909 | - */ |
|
| 910 | - public function useUserQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 911 | - { |
|
| 912 | - return $this |
|
| 913 | - ->joinUser($relationAlias, $joinType) |
|
| 914 | - ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery'); |
|
| 915 | - } |
|
| 916 | - |
|
| 917 | - /** |
|
| 918 | - * Filter the query by a related \Jalle19\StatusManager\Database\Channel object |
|
| 919 | - * |
|
| 920 | - * @param \Jalle19\StatusManager\Database\Channel|ObjectCollection $channel The related object(s) to use as filter |
|
| 921 | - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 922 | - * |
|
| 923 | - * @throws \Propel\Runtime\Exception\PropelException |
|
| 924 | - * |
|
| 925 | - * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 926 | - */ |
|
| 927 | - public function filterByChannel($channel, $comparison = null) |
|
| 928 | - { |
|
| 929 | - if ($channel instanceof \Jalle19\StatusManager\Database\Channel) { |
|
| 930 | - return $this |
|
| 931 | - ->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channel->getId(), $comparison); |
|
| 932 | - } elseif ($channel instanceof ObjectCollection) { |
|
| 933 | - if (null === $comparison) { |
|
| 934 | - $comparison = Criteria::IN; |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - return $this |
|
| 938 | - ->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channel->toKeyValue('PrimaryKey', 'Id'), $comparison); |
|
| 939 | - } else { |
|
| 940 | - throw new PropelException('filterByChannel() only accepts arguments of type \Jalle19\StatusManager\Database\Channel or Collection'); |
|
| 941 | - } |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - /** |
|
| 945 | - * Adds a JOIN clause to the query using the Channel relation |
|
| 946 | - * |
|
| 947 | - * @param string $relationAlias optional alias for the relation |
|
| 948 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 949 | - * |
|
| 950 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 951 | - */ |
|
| 952 | - public function joinChannel($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 953 | - { |
|
| 954 | - $tableMap = $this->getTableMap(); |
|
| 955 | - $relationMap = $tableMap->getRelation('Channel'); |
|
| 956 | - |
|
| 957 | - // create a ModelJoin object for this join |
|
| 958 | - $join = new ModelJoin(); |
|
| 959 | - $join->setJoinType($joinType); |
|
| 960 | - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 961 | - if ($previousJoin = $this->getPreviousJoin()) { |
|
| 962 | - $join->setPreviousJoin($previousJoin); |
|
| 963 | - } |
|
| 964 | - |
|
| 965 | - // add the ModelJoin to the current object |
|
| 966 | - if ($relationAlias) { |
|
| 967 | - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 968 | - $this->addJoinObject($join, $relationAlias); |
|
| 969 | - } else { |
|
| 970 | - $this->addJoinObject($join, 'Channel'); |
|
| 971 | - } |
|
| 972 | - |
|
| 973 | - return $this; |
|
| 974 | - } |
|
| 975 | - |
|
| 976 | - /** |
|
| 977 | - * Use the Channel relation Channel object |
|
| 978 | - * |
|
| 979 | - * @see useQuery() |
|
| 980 | - * |
|
| 981 | - * @param string $relationAlias optional alias for the relation, |
|
| 982 | - * to be used as main alias in the secondary query |
|
| 983 | - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 984 | - * |
|
| 985 | - * @return \Jalle19\StatusManager\Database\ChannelQuery A secondary query class using the current class as primary query |
|
| 986 | - */ |
|
| 987 | - public function useChannelQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 988 | - { |
|
| 989 | - return $this |
|
| 990 | - ->joinChannel($relationAlias, $joinType) |
|
| 991 | - ->useQuery($relationAlias ? $relationAlias : 'Channel', '\Jalle19\StatusManager\Database\ChannelQuery'); |
|
| 992 | - } |
|
| 993 | - |
|
| 994 | - /** |
|
| 995 | - * Exclude object from result |
|
| 996 | - * |
|
| 997 | - * @param ChildSubscription $subscription Object to remove from the list of results |
|
| 998 | - * |
|
| 999 | - * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 1000 | - */ |
|
| 1001 | - public function prune($subscription = null) |
|
| 1002 | - { |
|
| 1003 | - if ($subscription) { |
|
| 1004 | - $this->addUsingAlias(SubscriptionTableMap::COL_ID, $subscription->getId(), Criteria::NOT_EQUAL); |
|
| 1005 | - } |
|
| 1006 | - |
|
| 1007 | - return $this; |
|
| 1008 | - } |
|
| 1009 | - |
|
| 1010 | - /** |
|
| 1011 | - * Deletes all rows from the subscription table. |
|
| 1012 | - * |
|
| 1013 | - * @param ConnectionInterface $con the connection to use |
|
| 1014 | - * @return int The number of affected rows (if supported by underlying database driver). |
|
| 1015 | - */ |
|
| 1016 | - public function doDeleteAll(ConnectionInterface $con = null) |
|
| 1017 | - { |
|
| 1018 | - if (null === $con) { |
|
| 1019 | - $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - // use transaction because $criteria could contain info |
|
| 1023 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 1024 | - return $con->transaction(function () use ($con) { |
|
| 1025 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 1026 | - $affectedRows += parent::doDeleteAll($con); |
|
| 1027 | - // Because this db requires some delete cascade/set null emulation, we have to |
|
| 1028 | - // clear the cached instance *after* the emulation has happened (since |
|
| 1029 | - // instances get re-added by the select statement contained therein). |
|
| 1030 | - SubscriptionTableMap::clearInstancePool(); |
|
| 1031 | - SubscriptionTableMap::clearRelatedInstancePool(); |
|
| 1032 | - |
|
| 1033 | - return $affectedRows; |
|
| 1034 | - }); |
|
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - /** |
|
| 1038 | - * Performs a DELETE on the database based on the current ModelCriteria |
|
| 1039 | - * |
|
| 1040 | - * @param ConnectionInterface $con the connection to use |
|
| 1041 | - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
| 1042 | - * if supported by native driver or if emulated using Propel. |
|
| 1043 | - * @throws PropelException Any exceptions caught during processing will be |
|
| 1044 | - * rethrown wrapped into a PropelException. |
|
| 1045 | - */ |
|
| 1046 | - public function delete(ConnectionInterface $con = null) |
|
| 1047 | - { |
|
| 1048 | - if (null === $con) { |
|
| 1049 | - $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
| 1050 | - } |
|
| 1051 | - |
|
| 1052 | - $criteria = $this; |
|
| 1053 | - |
|
| 1054 | - // Set the correct dbName |
|
| 1055 | - $criteria->setDbName(SubscriptionTableMap::DATABASE_NAME); |
|
| 1056 | - |
|
| 1057 | - // use transaction because $criteria could contain info |
|
| 1058 | - // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 1059 | - return $con->transaction(function () use ($con, $criteria) { |
|
| 1060 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 1061 | - |
|
| 1062 | - SubscriptionTableMap::removeInstanceFromPool($criteria); |
|
| 1063 | - |
|
| 1064 | - $affectedRows += ModelCriteria::delete($con); |
|
| 1065 | - SubscriptionTableMap::clearRelatedInstancePool(); |
|
| 1066 | - |
|
| 1067 | - return $affectedRows; |
|
| 1068 | - }); |
|
| 1069 | - } |
|
| 138 | + protected $entityNotFoundExceptionClass = '\\Propel\\Runtime\\Exception\\EntityNotFoundException'; |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Initializes internal state of \Jalle19\StatusManager\Database\Base\SubscriptionQuery object. |
|
| 142 | + * |
|
| 143 | + * @param string $dbName The database name |
|
| 144 | + * @param string $modelName The phpName of a model, e.g. 'Book' |
|
| 145 | + * @param string $modelAlias The alias for the model in this query, e.g. 'b' |
|
| 146 | + */ |
|
| 147 | + public function __construct($dbName = 'tvheadend_status_manager', $modelName = '\\Jalle19\\StatusManager\\Database\\Subscription', $modelAlias = null) |
|
| 148 | + { |
|
| 149 | + parent::__construct($dbName, $modelName, $modelAlias); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Returns a new ChildSubscriptionQuery object. |
|
| 154 | + * |
|
| 155 | + * @param string $modelAlias The alias of a model in the query |
|
| 156 | + * @param Criteria $criteria Optional Criteria to build the query from |
|
| 157 | + * |
|
| 158 | + * @return ChildSubscriptionQuery |
|
| 159 | + */ |
|
| 160 | + public static function create($modelAlias = null, Criteria $criteria = null) |
|
| 161 | + { |
|
| 162 | + if ($criteria instanceof ChildSubscriptionQuery) { |
|
| 163 | + return $criteria; |
|
| 164 | + } |
|
| 165 | + $query = new ChildSubscriptionQuery(); |
|
| 166 | + if (null !== $modelAlias) { |
|
| 167 | + $query->setModelAlias($modelAlias); |
|
| 168 | + } |
|
| 169 | + if ($criteria instanceof Criteria) { |
|
| 170 | + $query->mergeWith($criteria); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + return $query; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Find object by primary key. |
|
| 178 | + * Propel uses the instance pool to skip the database if the object exists. |
|
| 179 | + * Go fast if the query is untouched. |
|
| 180 | + * |
|
| 181 | + * <code> |
|
| 182 | + * $obj = $c->findPk(12, $con); |
|
| 183 | + * </code> |
|
| 184 | + * |
|
| 185 | + * @param mixed $key Primary key to use for the query |
|
| 186 | + * @param ConnectionInterface $con an optional connection object |
|
| 187 | + * |
|
| 188 | + * @return ChildSubscription|array|mixed the result, formatted by the current formatter |
|
| 189 | + */ |
|
| 190 | + public function findPk($key, ConnectionInterface $con = null) |
|
| 191 | + { |
|
| 192 | + if ($key === null) { |
|
| 193 | + return null; |
|
| 194 | + } |
|
| 195 | + if ((null !== ($obj = SubscriptionTableMap::getInstanceFromPool(null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key))) && !$this->formatter) { |
|
| 196 | + // the object is already in the instance pool |
|
| 197 | + return $obj; |
|
| 198 | + } |
|
| 199 | + if ($con === null) { |
|
| 200 | + $con = Propel::getServiceContainer()->getReadConnection(SubscriptionTableMap::DATABASE_NAME); |
|
| 201 | + } |
|
| 202 | + $this->basePreSelect($con); |
|
| 203 | + if ($this->formatter || $this->modelAlias || $this->with || $this->select |
|
| 204 | + || $this->selectColumns || $this->asColumns || $this->selectModifiers |
|
| 205 | + || $this->map || $this->having || $this->joins) { |
|
| 206 | + return $this->findPkComplex($key, $con); |
|
| 207 | + } else { |
|
| 208 | + return $this->findPkSimple($key, $con); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + /** |
|
| 213 | + * Find object by primary key using raw SQL to go fast. |
|
| 214 | + * Bypass doSelect() and the object formatter by using generated code. |
|
| 215 | + * |
|
| 216 | + * @param mixed $key Primary key to use for the query |
|
| 217 | + * @param ConnectionInterface $con A connection object |
|
| 218 | + * |
|
| 219 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 220 | + * |
|
| 221 | + * @return ChildSubscription A model object, or null if the key is not found |
|
| 222 | + */ |
|
| 223 | + protected function findPkSimple($key, ConnectionInterface $con) |
|
| 224 | + { |
|
| 225 | + $sql = 'SELECT id, instance_name, input_uuid, user_id, channel_id, subscription_id, started, stopped, title, service FROM subscription WHERE id = :p0'; |
|
| 226 | + try { |
|
| 227 | + $stmt = $con->prepare($sql); |
|
| 228 | + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); |
|
| 229 | + $stmt->execute(); |
|
| 230 | + } catch (Exception $e) { |
|
| 231 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 232 | + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); |
|
| 233 | + } |
|
| 234 | + $obj = null; |
|
| 235 | + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { |
|
| 236 | + /** @var ChildSubscription $obj */ |
|
| 237 | + $obj = new ChildSubscription(); |
|
| 238 | + $obj->hydrate($row); |
|
| 239 | + SubscriptionTableMap::addInstanceToPool($obj, null === $key || is_scalar($key) || is_callable([$key, '__toString']) ? (string) $key : $key); |
|
| 240 | + } |
|
| 241 | + $stmt->closeCursor(); |
|
| 242 | + |
|
| 243 | + return $obj; |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * Find object by primary key. |
|
| 248 | + * |
|
| 249 | + * @param mixed $key Primary key to use for the query |
|
| 250 | + * @param ConnectionInterface $con A connection object |
|
| 251 | + * |
|
| 252 | + * @return ChildSubscription|array|mixed the result, formatted by the current formatter |
|
| 253 | + */ |
|
| 254 | + protected function findPkComplex($key, ConnectionInterface $con) |
|
| 255 | + { |
|
| 256 | + // As the query uses a PK condition, no limit(1) is necessary. |
|
| 257 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 258 | + $dataFetcher = $criteria |
|
| 259 | + ->filterByPrimaryKey($key) |
|
| 260 | + ->doSelect($con); |
|
| 261 | + |
|
| 262 | + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Find objects by primary key |
|
| 267 | + * <code> |
|
| 268 | + * $objs = $c->findPks(array(12, 56, 832), $con); |
|
| 269 | + * </code> |
|
| 270 | + * @param array $keys Primary keys to use for the query |
|
| 271 | + * @param ConnectionInterface $con an optional connection object |
|
| 272 | + * |
|
| 273 | + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter |
|
| 274 | + */ |
|
| 275 | + public function findPks($keys, ConnectionInterface $con = null) |
|
| 276 | + { |
|
| 277 | + if (null === $con) { |
|
| 278 | + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); |
|
| 279 | + } |
|
| 280 | + $this->basePreSelect($con); |
|
| 281 | + $criteria = $this->isKeepQuery() ? clone $this : $this; |
|
| 282 | + $dataFetcher = $criteria |
|
| 283 | + ->filterByPrimaryKeys($keys) |
|
| 284 | + ->doSelect($con); |
|
| 285 | + |
|
| 286 | + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + /** |
|
| 290 | + * Filter the query by primary key |
|
| 291 | + * |
|
| 292 | + * @param mixed $key Primary key to use for the query |
|
| 293 | + * |
|
| 294 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 295 | + */ |
|
| 296 | + public function filterByPrimaryKey($key) |
|
| 297 | + { |
|
| 298 | + |
|
| 299 | + return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $key, Criteria::EQUAL); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * Filter the query by a list of primary keys |
|
| 304 | + * |
|
| 305 | + * @param array $keys The list of primary key to use for the query |
|
| 306 | + * |
|
| 307 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 308 | + */ |
|
| 309 | + public function filterByPrimaryKeys($keys) |
|
| 310 | + { |
|
| 311 | + |
|
| 312 | + return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $keys, Criteria::IN); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Filter the query on the id column |
|
| 317 | + * |
|
| 318 | + * Example usage: |
|
| 319 | + * <code> |
|
| 320 | + * $query->filterById(1234); // WHERE id = 1234 |
|
| 321 | + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) |
|
| 322 | + * $query->filterById(array('min' => 12)); // WHERE id > 12 |
|
| 323 | + * </code> |
|
| 324 | + * |
|
| 325 | + * @param mixed $id The value to use as filter. |
|
| 326 | + * Use scalar values for equality. |
|
| 327 | + * Use array values for in_array() equivalent. |
|
| 328 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 329 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 330 | + * |
|
| 331 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 332 | + */ |
|
| 333 | + public function filterById($id = null, $comparison = null) |
|
| 334 | + { |
|
| 335 | + if (is_array($id)) { |
|
| 336 | + $useMinMax = false; |
|
| 337 | + if (isset($id['min'])) { |
|
| 338 | + $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id['min'], Criteria::GREATER_EQUAL); |
|
| 339 | + $useMinMax = true; |
|
| 340 | + } |
|
| 341 | + if (isset($id['max'])) { |
|
| 342 | + $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id['max'], Criteria::LESS_EQUAL); |
|
| 343 | + $useMinMax = true; |
|
| 344 | + } |
|
| 345 | + if ($useMinMax) { |
|
| 346 | + return $this; |
|
| 347 | + } |
|
| 348 | + if (null === $comparison) { |
|
| 349 | + $comparison = Criteria::IN; |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + return $this->addUsingAlias(SubscriptionTableMap::COL_ID, $id, $comparison); |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Filter the query on the instance_name column |
|
| 358 | + * |
|
| 359 | + * Example usage: |
|
| 360 | + * <code> |
|
| 361 | + * $query->filterByInstanceName('fooValue'); // WHERE instance_name = 'fooValue' |
|
| 362 | + * $query->filterByInstanceName('%fooValue%'); // WHERE instance_name LIKE '%fooValue%' |
|
| 363 | + * </code> |
|
| 364 | + * |
|
| 365 | + * @param string $instanceName The value to use as filter. |
|
| 366 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 367 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 368 | + * |
|
| 369 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 370 | + */ |
|
| 371 | + public function filterByInstanceName($instanceName = null, $comparison = null) |
|
| 372 | + { |
|
| 373 | + if (null === $comparison) { |
|
| 374 | + if (is_array($instanceName)) { |
|
| 375 | + $comparison = Criteria::IN; |
|
| 376 | + } elseif (preg_match('/[\%\*]/', $instanceName)) { |
|
| 377 | + $instanceName = str_replace('*', '%', $instanceName); |
|
| 378 | + $comparison = Criteria::LIKE; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + return $this->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instanceName, $comparison); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * Filter the query on the input_uuid column |
|
| 387 | + * |
|
| 388 | + * Example usage: |
|
| 389 | + * <code> |
|
| 390 | + * $query->filterByInputUuid('fooValue'); // WHERE input_uuid = 'fooValue' |
|
| 391 | + * $query->filterByInputUuid('%fooValue%'); // WHERE input_uuid LIKE '%fooValue%' |
|
| 392 | + * </code> |
|
| 393 | + * |
|
| 394 | + * @param string $inputUuid The value to use as filter. |
|
| 395 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 396 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 397 | + * |
|
| 398 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 399 | + */ |
|
| 400 | + public function filterByInputUuid($inputUuid = null, $comparison = null) |
|
| 401 | + { |
|
| 402 | + if (null === $comparison) { |
|
| 403 | + if (is_array($inputUuid)) { |
|
| 404 | + $comparison = Criteria::IN; |
|
| 405 | + } elseif (preg_match('/[\%\*]/', $inputUuid)) { |
|
| 406 | + $inputUuid = str_replace('*', '%', $inputUuid); |
|
| 407 | + $comparison = Criteria::LIKE; |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return $this->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $inputUuid, $comparison); |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + /** |
|
| 415 | + * Filter the query on the user_id column |
|
| 416 | + * |
|
| 417 | + * Example usage: |
|
| 418 | + * <code> |
|
| 419 | + * $query->filterByUserId(1234); // WHERE user_id = 1234 |
|
| 420 | + * $query->filterByUserId(array(12, 34)); // WHERE user_id IN (12, 34) |
|
| 421 | + * $query->filterByUserId(array('min' => 12)); // WHERE user_id > 12 |
|
| 422 | + * </code> |
|
| 423 | + * |
|
| 424 | + * @see filterByUser() |
|
| 425 | + * |
|
| 426 | + * @param mixed $userId The value to use as filter. |
|
| 427 | + * Use scalar values for equality. |
|
| 428 | + * Use array values for in_array() equivalent. |
|
| 429 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 430 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 431 | + * |
|
| 432 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 433 | + */ |
|
| 434 | + public function filterByUserId($userId = null, $comparison = null) |
|
| 435 | + { |
|
| 436 | + if (is_array($userId)) { |
|
| 437 | + $useMinMax = false; |
|
| 438 | + if (isset($userId['min'])) { |
|
| 439 | + $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId['min'], Criteria::GREATER_EQUAL); |
|
| 440 | + $useMinMax = true; |
|
| 441 | + } |
|
| 442 | + if (isset($userId['max'])) { |
|
| 443 | + $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId['max'], Criteria::LESS_EQUAL); |
|
| 444 | + $useMinMax = true; |
|
| 445 | + } |
|
| 446 | + if ($useMinMax) { |
|
| 447 | + return $this; |
|
| 448 | + } |
|
| 449 | + if (null === $comparison) { |
|
| 450 | + $comparison = Criteria::IN; |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + return $this->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $userId, $comparison); |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + /** |
|
| 458 | + * Filter the query on the channel_id column |
|
| 459 | + * |
|
| 460 | + * Example usage: |
|
| 461 | + * <code> |
|
| 462 | + * $query->filterByChannelId(1234); // WHERE channel_id = 1234 |
|
| 463 | + * $query->filterByChannelId(array(12, 34)); // WHERE channel_id IN (12, 34) |
|
| 464 | + * $query->filterByChannelId(array('min' => 12)); // WHERE channel_id > 12 |
|
| 465 | + * </code> |
|
| 466 | + * |
|
| 467 | + * @see filterByChannel() |
|
| 468 | + * |
|
| 469 | + * @param mixed $channelId The value to use as filter. |
|
| 470 | + * Use scalar values for equality. |
|
| 471 | + * Use array values for in_array() equivalent. |
|
| 472 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 473 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 474 | + * |
|
| 475 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 476 | + */ |
|
| 477 | + public function filterByChannelId($channelId = null, $comparison = null) |
|
| 478 | + { |
|
| 479 | + if (is_array($channelId)) { |
|
| 480 | + $useMinMax = false; |
|
| 481 | + if (isset($channelId['min'])) { |
|
| 482 | + $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId['min'], Criteria::GREATER_EQUAL); |
|
| 483 | + $useMinMax = true; |
|
| 484 | + } |
|
| 485 | + if (isset($channelId['max'])) { |
|
| 486 | + $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId['max'], Criteria::LESS_EQUAL); |
|
| 487 | + $useMinMax = true; |
|
| 488 | + } |
|
| 489 | + if ($useMinMax) { |
|
| 490 | + return $this; |
|
| 491 | + } |
|
| 492 | + if (null === $comparison) { |
|
| 493 | + $comparison = Criteria::IN; |
|
| 494 | + } |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + return $this->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channelId, $comparison); |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * Filter the query on the subscription_id column |
|
| 502 | + * |
|
| 503 | + * Example usage: |
|
| 504 | + * <code> |
|
| 505 | + * $query->filterBySubscriptionId(1234); // WHERE subscription_id = 1234 |
|
| 506 | + * $query->filterBySubscriptionId(array(12, 34)); // WHERE subscription_id IN (12, 34) |
|
| 507 | + * $query->filterBySubscriptionId(array('min' => 12)); // WHERE subscription_id > 12 |
|
| 508 | + * </code> |
|
| 509 | + * |
|
| 510 | + * @param mixed $subscriptionId The value to use as filter. |
|
| 511 | + * Use scalar values for equality. |
|
| 512 | + * Use array values for in_array() equivalent. |
|
| 513 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 514 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 515 | + * |
|
| 516 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 517 | + */ |
|
| 518 | + public function filterBySubscriptionId($subscriptionId = null, $comparison = null) |
|
| 519 | + { |
|
| 520 | + if (is_array($subscriptionId)) { |
|
| 521 | + $useMinMax = false; |
|
| 522 | + if (isset($subscriptionId['min'])) { |
|
| 523 | + $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId['min'], Criteria::GREATER_EQUAL); |
|
| 524 | + $useMinMax = true; |
|
| 525 | + } |
|
| 526 | + if (isset($subscriptionId['max'])) { |
|
| 527 | + $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId['max'], Criteria::LESS_EQUAL); |
|
| 528 | + $useMinMax = true; |
|
| 529 | + } |
|
| 530 | + if ($useMinMax) { |
|
| 531 | + return $this; |
|
| 532 | + } |
|
| 533 | + if (null === $comparison) { |
|
| 534 | + $comparison = Criteria::IN; |
|
| 535 | + } |
|
| 536 | + } |
|
| 537 | + |
|
| 538 | + return $this->addUsingAlias(SubscriptionTableMap::COL_SUBSCRIPTION_ID, $subscriptionId, $comparison); |
|
| 539 | + } |
|
| 540 | + |
|
| 541 | + /** |
|
| 542 | + * Filter the query on the started column |
|
| 543 | + * |
|
| 544 | + * Example usage: |
|
| 545 | + * <code> |
|
| 546 | + * $query->filterByStarted('2011-03-14'); // WHERE started = '2011-03-14' |
|
| 547 | + * $query->filterByStarted('now'); // WHERE started = '2011-03-14' |
|
| 548 | + * $query->filterByStarted(array('max' => 'yesterday')); // WHERE started > '2011-03-13' |
|
| 549 | + * </code> |
|
| 550 | + * |
|
| 551 | + * @param mixed $started The value to use as filter. |
|
| 552 | + * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
| 553 | + * Empty strings are treated as NULL. |
|
| 554 | + * Use scalar values for equality. |
|
| 555 | + * Use array values for in_array() equivalent. |
|
| 556 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 557 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 558 | + * |
|
| 559 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 560 | + */ |
|
| 561 | + public function filterByStarted($started = null, $comparison = null) |
|
| 562 | + { |
|
| 563 | + if (is_array($started)) { |
|
| 564 | + $useMinMax = false; |
|
| 565 | + if (isset($started['min'])) { |
|
| 566 | + $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started['min'], Criteria::GREATER_EQUAL); |
|
| 567 | + $useMinMax = true; |
|
| 568 | + } |
|
| 569 | + if (isset($started['max'])) { |
|
| 570 | + $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started['max'], Criteria::LESS_EQUAL); |
|
| 571 | + $useMinMax = true; |
|
| 572 | + } |
|
| 573 | + if ($useMinMax) { |
|
| 574 | + return $this; |
|
| 575 | + } |
|
| 576 | + if (null === $comparison) { |
|
| 577 | + $comparison = Criteria::IN; |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + return $this->addUsingAlias(SubscriptionTableMap::COL_STARTED, $started, $comparison); |
|
| 582 | + } |
|
| 583 | + |
|
| 584 | + /** |
|
| 585 | + * Filter the query on the stopped column |
|
| 586 | + * |
|
| 587 | + * Example usage: |
|
| 588 | + * <code> |
|
| 589 | + * $query->filterByStopped('2011-03-14'); // WHERE stopped = '2011-03-14' |
|
| 590 | + * $query->filterByStopped('now'); // WHERE stopped = '2011-03-14' |
|
| 591 | + * $query->filterByStopped(array('max' => 'yesterday')); // WHERE stopped > '2011-03-13' |
|
| 592 | + * </code> |
|
| 593 | + * |
|
| 594 | + * @param mixed $stopped The value to use as filter. |
|
| 595 | + * Values can be integers (unix timestamps), DateTime objects, or strings. |
|
| 596 | + * Empty strings are treated as NULL. |
|
| 597 | + * Use scalar values for equality. |
|
| 598 | + * Use array values for in_array() equivalent. |
|
| 599 | + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. |
|
| 600 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 601 | + * |
|
| 602 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 603 | + */ |
|
| 604 | + public function filterByStopped($stopped = null, $comparison = null) |
|
| 605 | + { |
|
| 606 | + if (is_array($stopped)) { |
|
| 607 | + $useMinMax = false; |
|
| 608 | + if (isset($stopped['min'])) { |
|
| 609 | + $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped['min'], Criteria::GREATER_EQUAL); |
|
| 610 | + $useMinMax = true; |
|
| 611 | + } |
|
| 612 | + if (isset($stopped['max'])) { |
|
| 613 | + $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped['max'], Criteria::LESS_EQUAL); |
|
| 614 | + $useMinMax = true; |
|
| 615 | + } |
|
| 616 | + if ($useMinMax) { |
|
| 617 | + return $this; |
|
| 618 | + } |
|
| 619 | + if (null === $comparison) { |
|
| 620 | + $comparison = Criteria::IN; |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + |
|
| 624 | + return $this->addUsingAlias(SubscriptionTableMap::COL_STOPPED, $stopped, $comparison); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + /** |
|
| 628 | + * Filter the query on the title column |
|
| 629 | + * |
|
| 630 | + * Example usage: |
|
| 631 | + * <code> |
|
| 632 | + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' |
|
| 633 | + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' |
|
| 634 | + * </code> |
|
| 635 | + * |
|
| 636 | + * @param string $title The value to use as filter. |
|
| 637 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 638 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 639 | + * |
|
| 640 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 641 | + */ |
|
| 642 | + public function filterByTitle($title = null, $comparison = null) |
|
| 643 | + { |
|
| 644 | + if (null === $comparison) { |
|
| 645 | + if (is_array($title)) { |
|
| 646 | + $comparison = Criteria::IN; |
|
| 647 | + } elseif (preg_match('/[\%\*]/', $title)) { |
|
| 648 | + $title = str_replace('*', '%', $title); |
|
| 649 | + $comparison = Criteria::LIKE; |
|
| 650 | + } |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + return $this->addUsingAlias(SubscriptionTableMap::COL_TITLE, $title, $comparison); |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Filter the query on the service column |
|
| 658 | + * |
|
| 659 | + * Example usage: |
|
| 660 | + * <code> |
|
| 661 | + * $query->filterByService('fooValue'); // WHERE service = 'fooValue' |
|
| 662 | + * $query->filterByService('%fooValue%'); // WHERE service LIKE '%fooValue%' |
|
| 663 | + * </code> |
|
| 664 | + * |
|
| 665 | + * @param string $service The value to use as filter. |
|
| 666 | + * Accepts wildcards (* and % trigger a LIKE) |
|
| 667 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 668 | + * |
|
| 669 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 670 | + */ |
|
| 671 | + public function filterByService($service = null, $comparison = null) |
|
| 672 | + { |
|
| 673 | + if (null === $comparison) { |
|
| 674 | + if (is_array($service)) { |
|
| 675 | + $comparison = Criteria::IN; |
|
| 676 | + } elseif (preg_match('/[\%\*]/', $service)) { |
|
| 677 | + $service = str_replace('*', '%', $service); |
|
| 678 | + $comparison = Criteria::LIKE; |
|
| 679 | + } |
|
| 680 | + } |
|
| 681 | + |
|
| 682 | + return $this->addUsingAlias(SubscriptionTableMap::COL_SERVICE, $service, $comparison); |
|
| 683 | + } |
|
| 684 | + |
|
| 685 | + /** |
|
| 686 | + * Filter the query by a related \Jalle19\StatusManager\Database\Instance object |
|
| 687 | + * |
|
| 688 | + * @param \Jalle19\StatusManager\Database\Instance|ObjectCollection $instance The related object(s) to use as filter |
|
| 689 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 690 | + * |
|
| 691 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 692 | + * |
|
| 693 | + * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 694 | + */ |
|
| 695 | + public function filterByInstance($instance, $comparison = null) |
|
| 696 | + { |
|
| 697 | + if ($instance instanceof \Jalle19\StatusManager\Database\Instance) { |
|
| 698 | + return $this |
|
| 699 | + ->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instance->getName(), $comparison); |
|
| 700 | + } elseif ($instance instanceof ObjectCollection) { |
|
| 701 | + if (null === $comparison) { |
|
| 702 | + $comparison = Criteria::IN; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + return $this |
|
| 706 | + ->addUsingAlias(SubscriptionTableMap::COL_INSTANCE_NAME, $instance->toKeyValue('PrimaryKey', 'Name'), $comparison); |
|
| 707 | + } else { |
|
| 708 | + throw new PropelException('filterByInstance() only accepts arguments of type \Jalle19\StatusManager\Database\Instance or Collection'); |
|
| 709 | + } |
|
| 710 | + } |
|
| 711 | + |
|
| 712 | + /** |
|
| 713 | + * Adds a JOIN clause to the query using the Instance relation |
|
| 714 | + * |
|
| 715 | + * @param string $relationAlias optional alias for the relation |
|
| 716 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 717 | + * |
|
| 718 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 719 | + */ |
|
| 720 | + public function joinInstance($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 721 | + { |
|
| 722 | + $tableMap = $this->getTableMap(); |
|
| 723 | + $relationMap = $tableMap->getRelation('Instance'); |
|
| 724 | + |
|
| 725 | + // create a ModelJoin object for this join |
|
| 726 | + $join = new ModelJoin(); |
|
| 727 | + $join->setJoinType($joinType); |
|
| 728 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 729 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 730 | + $join->setPreviousJoin($previousJoin); |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + // add the ModelJoin to the current object |
|
| 734 | + if ($relationAlias) { |
|
| 735 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 736 | + $this->addJoinObject($join, $relationAlias); |
|
| 737 | + } else { |
|
| 738 | + $this->addJoinObject($join, 'Instance'); |
|
| 739 | + } |
|
| 740 | + |
|
| 741 | + return $this; |
|
| 742 | + } |
|
| 743 | + |
|
| 744 | + /** |
|
| 745 | + * Use the Instance relation Instance object |
|
| 746 | + * |
|
| 747 | + * @see useQuery() |
|
| 748 | + * |
|
| 749 | + * @param string $relationAlias optional alias for the relation, |
|
| 750 | + * to be used as main alias in the secondary query |
|
| 751 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 752 | + * |
|
| 753 | + * @return \Jalle19\StatusManager\Database\InstanceQuery A secondary query class using the current class as primary query |
|
| 754 | + */ |
|
| 755 | + public function useInstanceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 756 | + { |
|
| 757 | + return $this |
|
| 758 | + ->joinInstance($relationAlias, $joinType) |
|
| 759 | + ->useQuery($relationAlias ? $relationAlias : 'Instance', '\Jalle19\StatusManager\Database\InstanceQuery'); |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * Filter the query by a related \Jalle19\StatusManager\Database\Input object |
|
| 764 | + * |
|
| 765 | + * @param \Jalle19\StatusManager\Database\Input|ObjectCollection $input The related object(s) to use as filter |
|
| 766 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 767 | + * |
|
| 768 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 769 | + * |
|
| 770 | + * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 771 | + */ |
|
| 772 | + public function filterByInput($input, $comparison = null) |
|
| 773 | + { |
|
| 774 | + if ($input instanceof \Jalle19\StatusManager\Database\Input) { |
|
| 775 | + return $this |
|
| 776 | + ->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $input->getUuid(), $comparison); |
|
| 777 | + } elseif ($input instanceof ObjectCollection) { |
|
| 778 | + if (null === $comparison) { |
|
| 779 | + $comparison = Criteria::IN; |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + return $this |
|
| 783 | + ->addUsingAlias(SubscriptionTableMap::COL_INPUT_UUID, $input->toKeyValue('PrimaryKey', 'Uuid'), $comparison); |
|
| 784 | + } else { |
|
| 785 | + throw new PropelException('filterByInput() only accepts arguments of type \Jalle19\StatusManager\Database\Input or Collection'); |
|
| 786 | + } |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + /** |
|
| 790 | + * Adds a JOIN clause to the query using the Input relation |
|
| 791 | + * |
|
| 792 | + * @param string $relationAlias optional alias for the relation |
|
| 793 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 794 | + * |
|
| 795 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 796 | + */ |
|
| 797 | + public function joinInput($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 798 | + { |
|
| 799 | + $tableMap = $this->getTableMap(); |
|
| 800 | + $relationMap = $tableMap->getRelation('Input'); |
|
| 801 | + |
|
| 802 | + // create a ModelJoin object for this join |
|
| 803 | + $join = new ModelJoin(); |
|
| 804 | + $join->setJoinType($joinType); |
|
| 805 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 806 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 807 | + $join->setPreviousJoin($previousJoin); |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + // add the ModelJoin to the current object |
|
| 811 | + if ($relationAlias) { |
|
| 812 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 813 | + $this->addJoinObject($join, $relationAlias); |
|
| 814 | + } else { |
|
| 815 | + $this->addJoinObject($join, 'Input'); |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + return $this; |
|
| 819 | + } |
|
| 820 | + |
|
| 821 | + /** |
|
| 822 | + * Use the Input relation Input object |
|
| 823 | + * |
|
| 824 | + * @see useQuery() |
|
| 825 | + * |
|
| 826 | + * @param string $relationAlias optional alias for the relation, |
|
| 827 | + * to be used as main alias in the secondary query |
|
| 828 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 829 | + * |
|
| 830 | + * @return \Jalle19\StatusManager\Database\InputQuery A secondary query class using the current class as primary query |
|
| 831 | + */ |
|
| 832 | + public function useInputQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 833 | + { |
|
| 834 | + return $this |
|
| 835 | + ->joinInput($relationAlias, $joinType) |
|
| 836 | + ->useQuery($relationAlias ? $relationAlias : 'Input', '\Jalle19\StatusManager\Database\InputQuery'); |
|
| 837 | + } |
|
| 838 | + |
|
| 839 | + /** |
|
| 840 | + * Filter the query by a related \Jalle19\StatusManager\Database\User object |
|
| 841 | + * |
|
| 842 | + * @param \Jalle19\StatusManager\Database\User|ObjectCollection $user The related object(s) to use as filter |
|
| 843 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 844 | + * |
|
| 845 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 846 | + * |
|
| 847 | + * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 848 | + */ |
|
| 849 | + public function filterByUser($user, $comparison = null) |
|
| 850 | + { |
|
| 851 | + if ($user instanceof \Jalle19\StatusManager\Database\User) { |
|
| 852 | + return $this |
|
| 853 | + ->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $user->getId(), $comparison); |
|
| 854 | + } elseif ($user instanceof ObjectCollection) { |
|
| 855 | + if (null === $comparison) { |
|
| 856 | + $comparison = Criteria::IN; |
|
| 857 | + } |
|
| 858 | + |
|
| 859 | + return $this |
|
| 860 | + ->addUsingAlias(SubscriptionTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); |
|
| 861 | + } else { |
|
| 862 | + throw new PropelException('filterByUser() only accepts arguments of type \Jalle19\StatusManager\Database\User or Collection'); |
|
| 863 | + } |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + /** |
|
| 867 | + * Adds a JOIN clause to the query using the User relation |
|
| 868 | + * |
|
| 869 | + * @param string $relationAlias optional alias for the relation |
|
| 870 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 871 | + * |
|
| 872 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 873 | + */ |
|
| 874 | + public function joinUser($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 875 | + { |
|
| 876 | + $tableMap = $this->getTableMap(); |
|
| 877 | + $relationMap = $tableMap->getRelation('User'); |
|
| 878 | + |
|
| 879 | + // create a ModelJoin object for this join |
|
| 880 | + $join = new ModelJoin(); |
|
| 881 | + $join->setJoinType($joinType); |
|
| 882 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 883 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 884 | + $join->setPreviousJoin($previousJoin); |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + // add the ModelJoin to the current object |
|
| 888 | + if ($relationAlias) { |
|
| 889 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 890 | + $this->addJoinObject($join, $relationAlias); |
|
| 891 | + } else { |
|
| 892 | + $this->addJoinObject($join, 'User'); |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + return $this; |
|
| 896 | + } |
|
| 897 | + |
|
| 898 | + /** |
|
| 899 | + * Use the User relation User object |
|
| 900 | + * |
|
| 901 | + * @see useQuery() |
|
| 902 | + * |
|
| 903 | + * @param string $relationAlias optional alias for the relation, |
|
| 904 | + * to be used as main alias in the secondary query |
|
| 905 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 906 | + * |
|
| 907 | + * @return \Jalle19\StatusManager\Database\UserQuery A secondary query class using the current class as primary query |
|
| 908 | + */ |
|
| 909 | + public function useUserQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) |
|
| 910 | + { |
|
| 911 | + return $this |
|
| 912 | + ->joinUser($relationAlias, $joinType) |
|
| 913 | + ->useQuery($relationAlias ? $relationAlias : 'User', '\Jalle19\StatusManager\Database\UserQuery'); |
|
| 914 | + } |
|
| 915 | + |
|
| 916 | + /** |
|
| 917 | + * Filter the query by a related \Jalle19\StatusManager\Database\Channel object |
|
| 918 | + * |
|
| 919 | + * @param \Jalle19\StatusManager\Database\Channel|ObjectCollection $channel The related object(s) to use as filter |
|
| 920 | + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL |
|
| 921 | + * |
|
| 922 | + * @throws \Propel\Runtime\Exception\PropelException |
|
| 923 | + * |
|
| 924 | + * @return ChildSubscriptionQuery The current query, for fluid interface |
|
| 925 | + */ |
|
| 926 | + public function filterByChannel($channel, $comparison = null) |
|
| 927 | + { |
|
| 928 | + if ($channel instanceof \Jalle19\StatusManager\Database\Channel) { |
|
| 929 | + return $this |
|
| 930 | + ->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channel->getId(), $comparison); |
|
| 931 | + } elseif ($channel instanceof ObjectCollection) { |
|
| 932 | + if (null === $comparison) { |
|
| 933 | + $comparison = Criteria::IN; |
|
| 934 | + } |
|
| 935 | + |
|
| 936 | + return $this |
|
| 937 | + ->addUsingAlias(SubscriptionTableMap::COL_CHANNEL_ID, $channel->toKeyValue('PrimaryKey', 'Id'), $comparison); |
|
| 938 | + } else { |
|
| 939 | + throw new PropelException('filterByChannel() only accepts arguments of type \Jalle19\StatusManager\Database\Channel or Collection'); |
|
| 940 | + } |
|
| 941 | + } |
|
| 942 | + |
|
| 943 | + /** |
|
| 944 | + * Adds a JOIN clause to the query using the Channel relation |
|
| 945 | + * |
|
| 946 | + * @param string $relationAlias optional alias for the relation |
|
| 947 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 948 | + * |
|
| 949 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 950 | + */ |
|
| 951 | + public function joinChannel($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 952 | + { |
|
| 953 | + $tableMap = $this->getTableMap(); |
|
| 954 | + $relationMap = $tableMap->getRelation('Channel'); |
|
| 955 | + |
|
| 956 | + // create a ModelJoin object for this join |
|
| 957 | + $join = new ModelJoin(); |
|
| 958 | + $join->setJoinType($joinType); |
|
| 959 | + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); |
|
| 960 | + if ($previousJoin = $this->getPreviousJoin()) { |
|
| 961 | + $join->setPreviousJoin($previousJoin); |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + // add the ModelJoin to the current object |
|
| 965 | + if ($relationAlias) { |
|
| 966 | + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); |
|
| 967 | + $this->addJoinObject($join, $relationAlias); |
|
| 968 | + } else { |
|
| 969 | + $this->addJoinObject($join, 'Channel'); |
|
| 970 | + } |
|
| 971 | + |
|
| 972 | + return $this; |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + /** |
|
| 976 | + * Use the Channel relation Channel object |
|
| 977 | + * |
|
| 978 | + * @see useQuery() |
|
| 979 | + * |
|
| 980 | + * @param string $relationAlias optional alias for the relation, |
|
| 981 | + * to be used as main alias in the secondary query |
|
| 982 | + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' |
|
| 983 | + * |
|
| 984 | + * @return \Jalle19\StatusManager\Database\ChannelQuery A secondary query class using the current class as primary query |
|
| 985 | + */ |
|
| 986 | + public function useChannelQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) |
|
| 987 | + { |
|
| 988 | + return $this |
|
| 989 | + ->joinChannel($relationAlias, $joinType) |
|
| 990 | + ->useQuery($relationAlias ? $relationAlias : 'Channel', '\Jalle19\StatusManager\Database\ChannelQuery'); |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + /** |
|
| 994 | + * Exclude object from result |
|
| 995 | + * |
|
| 996 | + * @param ChildSubscription $subscription Object to remove from the list of results |
|
| 997 | + * |
|
| 998 | + * @return $this|ChildSubscriptionQuery The current query, for fluid interface |
|
| 999 | + */ |
|
| 1000 | + public function prune($subscription = null) |
|
| 1001 | + { |
|
| 1002 | + if ($subscription) { |
|
| 1003 | + $this->addUsingAlias(SubscriptionTableMap::COL_ID, $subscription->getId(), Criteria::NOT_EQUAL); |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + return $this; |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + /** |
|
| 1010 | + * Deletes all rows from the subscription table. |
|
| 1011 | + * |
|
| 1012 | + * @param ConnectionInterface $con the connection to use |
|
| 1013 | + * @return int The number of affected rows (if supported by underlying database driver). |
|
| 1014 | + */ |
|
| 1015 | + public function doDeleteAll(ConnectionInterface $con = null) |
|
| 1016 | + { |
|
| 1017 | + if (null === $con) { |
|
| 1018 | + $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
| 1019 | + } |
|
| 1020 | + |
|
| 1021 | + // use transaction because $criteria could contain info |
|
| 1022 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 1023 | + return $con->transaction(function () use ($con) { |
|
| 1024 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 1025 | + $affectedRows += parent::doDeleteAll($con); |
|
| 1026 | + // Because this db requires some delete cascade/set null emulation, we have to |
|
| 1027 | + // clear the cached instance *after* the emulation has happened (since |
|
| 1028 | + // instances get re-added by the select statement contained therein). |
|
| 1029 | + SubscriptionTableMap::clearInstancePool(); |
|
| 1030 | + SubscriptionTableMap::clearRelatedInstancePool(); |
|
| 1031 | + |
|
| 1032 | + return $affectedRows; |
|
| 1033 | + }); |
|
| 1034 | + } |
|
| 1035 | + |
|
| 1036 | + /** |
|
| 1037 | + * Performs a DELETE on the database based on the current ModelCriteria |
|
| 1038 | + * |
|
| 1039 | + * @param ConnectionInterface $con the connection to use |
|
| 1040 | + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows |
|
| 1041 | + * if supported by native driver or if emulated using Propel. |
|
| 1042 | + * @throws PropelException Any exceptions caught during processing will be |
|
| 1043 | + * rethrown wrapped into a PropelException. |
|
| 1044 | + */ |
|
| 1045 | + public function delete(ConnectionInterface $con = null) |
|
| 1046 | + { |
|
| 1047 | + if (null === $con) { |
|
| 1048 | + $con = Propel::getServiceContainer()->getWriteConnection(SubscriptionTableMap::DATABASE_NAME); |
|
| 1049 | + } |
|
| 1050 | + |
|
| 1051 | + $criteria = $this; |
|
| 1052 | + |
|
| 1053 | + // Set the correct dbName |
|
| 1054 | + $criteria->setDbName(SubscriptionTableMap::DATABASE_NAME); |
|
| 1055 | + |
|
| 1056 | + // use transaction because $criteria could contain info |
|
| 1057 | + // for more than one table or we could emulating ON DELETE CASCADE, etc. |
|
| 1058 | + return $con->transaction(function () use ($con, $criteria) { |
|
| 1059 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 1060 | + |
|
| 1061 | + SubscriptionTableMap::removeInstanceFromPool($criteria); |
|
| 1062 | + |
|
| 1063 | + $affectedRows += ModelCriteria::delete($con); |
|
| 1064 | + SubscriptionTableMap::clearRelatedInstancePool(); |
|
| 1065 | + |
|
| 1066 | + return $affectedRows; |
|
| 1067 | + }); |
|
| 1068 | + } |
|
| 1070 | 1069 | |
| 1071 | 1070 | } // SubscriptionQuery |
@@ -37,1963 +37,1963 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | abstract class User implements ActiveRecordInterface |
| 39 | 39 | { |
| 40 | - /** |
|
| 41 | - * TableMap class name |
|
| 42 | - */ |
|
| 43 | - const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\UserTableMap'; |
|
| 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 name field. |
|
| 88 | - * |
|
| 89 | - * @var string |
|
| 90 | - */ |
|
| 91 | - protected $name; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @var ChildInstance |
|
| 95 | - */ |
|
| 96 | - protected $aInstance; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @var ObjectCollection|ChildConnection[] Collection to store aggregation of ChildConnection objects. |
|
| 100 | - */ |
|
| 101 | - protected $collConnections; |
|
| 102 | - protected $collConnectionsPartial; |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 106 | - */ |
|
| 107 | - protected $collSubscriptions; |
|
| 108 | - protected $collSubscriptionsPartial; |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Flag to prevent endless save loop, if this object is referenced |
|
| 112 | - * by another object which falls in this transaction. |
|
| 113 | - * |
|
| 114 | - * @var boolean |
|
| 115 | - */ |
|
| 116 | - protected $alreadyInSave = false; |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * An array of objects scheduled for deletion. |
|
| 120 | - * @var ObjectCollection|ChildConnection[] |
|
| 121 | - */ |
|
| 122 | - protected $connectionsScheduledForDeletion = null; |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * An array of objects scheduled for deletion. |
|
| 126 | - * @var ObjectCollection|ChildSubscription[] |
|
| 127 | - */ |
|
| 128 | - protected $subscriptionsScheduledForDeletion = null; |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Initializes internal state of Jalle19\StatusManager\Database\Base\User object. |
|
| 132 | - */ |
|
| 133 | - public function __construct() |
|
| 134 | - { |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Returns whether the object has been modified. |
|
| 139 | - * |
|
| 140 | - * @return boolean True if the object has been modified. |
|
| 141 | - */ |
|
| 142 | - public function isModified() |
|
| 143 | - { |
|
| 144 | - return !!$this->modifiedColumns; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Has specified column been modified? |
|
| 149 | - * |
|
| 150 | - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 151 | - * @return boolean True if $col has been modified. |
|
| 152 | - */ |
|
| 153 | - public function isColumnModified($col) |
|
| 154 | - { |
|
| 155 | - return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Get the columns that have been modified in this object. |
|
| 160 | - * @return array A unique list of the modified column names for this object. |
|
| 161 | - */ |
|
| 162 | - public function getModifiedColumns() |
|
| 163 | - { |
|
| 164 | - return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Returns whether the object has ever been saved. This will |
|
| 169 | - * be false, if the object was retrieved from storage or was created |
|
| 170 | - * and then saved. |
|
| 171 | - * |
|
| 172 | - * @return boolean true, if the object has never been persisted. |
|
| 173 | - */ |
|
| 174 | - public function isNew() |
|
| 175 | - { |
|
| 176 | - return $this->new; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Setter for the isNew attribute. This method will be called |
|
| 181 | - * by Propel-generated children and objects. |
|
| 182 | - * |
|
| 183 | - * @param boolean $b the state of the object. |
|
| 184 | - */ |
|
| 185 | - public function setNew($b) |
|
| 186 | - { |
|
| 187 | - $this->new = (boolean) $b; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Whether this object has been deleted. |
|
| 192 | - * @return boolean The deleted state of this object. |
|
| 193 | - */ |
|
| 194 | - public function isDeleted() |
|
| 195 | - { |
|
| 196 | - return $this->deleted; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * Specify whether this object has been deleted. |
|
| 201 | - * @param boolean $b The deleted state of this object. |
|
| 202 | - * @return void |
|
| 203 | - */ |
|
| 204 | - public function setDeleted($b) |
|
| 205 | - { |
|
| 206 | - $this->deleted = (boolean) $b; |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * Sets the modified state for the object to be false. |
|
| 211 | - * @param string $col If supplied, only the specified column is reset. |
|
| 212 | - * @return void |
|
| 213 | - */ |
|
| 214 | - public function resetModified($col = null) |
|
| 215 | - { |
|
| 216 | - if (null !== $col) { |
|
| 217 | - if (isset($this->modifiedColumns[$col])) { |
|
| 218 | - unset($this->modifiedColumns[$col]); |
|
| 219 | - } |
|
| 220 | - } else { |
|
| 221 | - $this->modifiedColumns = array(); |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 226 | - * Compares this with another <code>User</code> instance. If |
|
| 227 | - * <code>obj</code> is an instance of <code>User</code>, delegates to |
|
| 228 | - * <code>equals(User)</code>. Otherwise, returns <code>false</code>. |
|
| 229 | - * |
|
| 230 | - * @param mixed $obj The object to compare to. |
|
| 231 | - * @return boolean Whether equal to the object specified. |
|
| 232 | - */ |
|
| 233 | - public function equals($obj) |
|
| 234 | - { |
|
| 235 | - if (!$obj instanceof static) { |
|
| 236 | - return false; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - if ($this === $obj) { |
|
| 240 | - return true; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 244 | - return false; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Get the associative array of the virtual columns in this object |
|
| 252 | - * |
|
| 253 | - * @return array |
|
| 254 | - */ |
|
| 255 | - public function getVirtualColumns() |
|
| 256 | - { |
|
| 257 | - return $this->virtualColumns; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * Checks the existence of a virtual column in this object |
|
| 262 | - * |
|
| 263 | - * @param string $name The virtual column name |
|
| 264 | - * @return boolean |
|
| 265 | - */ |
|
| 266 | - public function hasVirtualColumn($name) |
|
| 267 | - { |
|
| 268 | - return array_key_exists($name, $this->virtualColumns); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - /** |
|
| 272 | - * Get the value of a virtual column in this object |
|
| 273 | - * |
|
| 274 | - * @param string $name The virtual column name |
|
| 275 | - * @return mixed |
|
| 276 | - * |
|
| 277 | - * @throws PropelException |
|
| 278 | - */ |
|
| 279 | - public function getVirtualColumn($name) |
|
| 280 | - { |
|
| 281 | - if (!$this->hasVirtualColumn($name)) { |
|
| 282 | - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - return $this->virtualColumns[$name]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * Set the value of a virtual column in this object |
|
| 290 | - * |
|
| 291 | - * @param string $name The virtual column name |
|
| 292 | - * @param mixed $value The value to give to the virtual column |
|
| 293 | - * |
|
| 294 | - * @return $this|User The current object, for fluid interface |
|
| 295 | - */ |
|
| 296 | - public function setVirtualColumn($name, $value) |
|
| 297 | - { |
|
| 298 | - $this->virtualColumns[$name] = $value; |
|
| 299 | - |
|
| 300 | - return $this; |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Logs a message using Propel::log(). |
|
| 305 | - * |
|
| 306 | - * @param string $msg |
|
| 307 | - * @param int $priority One of the Propel::LOG_* logging levels |
|
| 308 | - * @return boolean |
|
| 309 | - */ |
|
| 310 | - protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 311 | - { |
|
| 312 | - return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - /** |
|
| 316 | - * Export the current object properties to a string, using a given parser format |
|
| 317 | - * <code> |
|
| 318 | - * $book = BookQuery::create()->findPk(9012); |
|
| 319 | - * echo $book->exportTo('JSON'); |
|
| 320 | - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 321 | - * </code> |
|
| 322 | - * |
|
| 323 | - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 324 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 325 | - * @return string The exported data |
|
| 326 | - */ |
|
| 327 | - public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 328 | - { |
|
| 329 | - if (!$parser instanceof AbstractParser) { |
|
| 330 | - $parser = AbstractParser::getParser($parser); |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * Clean up internal collections prior to serializing |
|
| 338 | - * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 339 | - */ |
|
| 340 | - public function __sleep() |
|
| 341 | - { |
|
| 342 | - $this->clearAllReferences(); |
|
| 343 | - |
|
| 344 | - $cls = new \ReflectionClass($this); |
|
| 345 | - $propertyNames = []; |
|
| 346 | - $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 347 | - |
|
| 348 | - foreach($serializableProperties as $property) { |
|
| 349 | - $propertyNames[] = $property->getName(); |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - return $propertyNames; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Get the [id] column value. |
|
| 357 | - * |
|
| 358 | - * @return int |
|
| 359 | - */ |
|
| 360 | - public function getId() |
|
| 361 | - { |
|
| 362 | - return $this->id; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * Get the [instance_name] column value. |
|
| 367 | - * |
|
| 368 | - * @return string |
|
| 369 | - */ |
|
| 370 | - public function getInstanceName() |
|
| 371 | - { |
|
| 372 | - return $this->instance_name; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * Get the [name] column value. |
|
| 377 | - * |
|
| 378 | - * @return string |
|
| 379 | - */ |
|
| 380 | - public function getName() |
|
| 381 | - { |
|
| 382 | - return $this->name; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * Set the value of [id] column. |
|
| 387 | - * |
|
| 388 | - * @param int $v new value |
|
| 389 | - * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 390 | - */ |
|
| 391 | - public function setId($v) |
|
| 392 | - { |
|
| 393 | - if ($v !== null) { |
|
| 394 | - $v = (int) $v; |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if ($this->id !== $v) { |
|
| 398 | - $this->id = $v; |
|
| 399 | - $this->modifiedColumns[UserTableMap::COL_ID] = true; |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - return $this; |
|
| 403 | - } // setId() |
|
| 404 | - |
|
| 405 | - /** |
|
| 406 | - * Set the value of [instance_name] column. |
|
| 407 | - * |
|
| 408 | - * @param string $v new value |
|
| 409 | - * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 410 | - */ |
|
| 411 | - public function setInstanceName($v) |
|
| 412 | - { |
|
| 413 | - if ($v !== null) { |
|
| 414 | - $v = (string) $v; |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - if ($this->instance_name !== $v) { |
|
| 418 | - $this->instance_name = $v; |
|
| 419 | - $this->modifiedColumns[UserTableMap::COL_INSTANCE_NAME] = true; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
| 423 | - $this->aInstance = null; |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - return $this; |
|
| 427 | - } // setInstanceName() |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * Set the value of [name] column. |
|
| 431 | - * |
|
| 432 | - * @param string $v new value |
|
| 433 | - * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 434 | - */ |
|
| 435 | - public function setName($v) |
|
| 436 | - { |
|
| 437 | - if ($v !== null) { |
|
| 438 | - $v = (string) $v; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - if ($this->name !== $v) { |
|
| 442 | - $this->name = $v; |
|
| 443 | - $this->modifiedColumns[UserTableMap::COL_NAME] = true; |
|
| 444 | - } |
|
| 445 | - |
|
| 446 | - return $this; |
|
| 447 | - } // setName() |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * Indicates whether the columns in this object are only set to default values. |
|
| 451 | - * |
|
| 452 | - * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 453 | - * modified _and_ has some values set which are non-default. |
|
| 454 | - * |
|
| 455 | - * @return boolean Whether the columns in this object are only been set with default values. |
|
| 456 | - */ |
|
| 457 | - public function hasOnlyDefaultValues() |
|
| 458 | - { |
|
| 459 | - // otherwise, everything was equal, so return TRUE |
|
| 460 | - return true; |
|
| 461 | - } // hasOnlyDefaultValues() |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * Hydrates (populates) the object variables with values from the database resultset. |
|
| 465 | - * |
|
| 466 | - * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 467 | - * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 468 | - * for results of JOIN queries where the resultset row includes columns from two or |
|
| 469 | - * more tables. |
|
| 470 | - * |
|
| 471 | - * @param array $row The row returned by DataFetcher->fetch(). |
|
| 472 | - * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 473 | - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 474 | - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 40 | + /** |
|
| 41 | + * TableMap class name |
|
| 42 | + */ |
|
| 43 | + const TABLE_MAP = '\\Jalle19\\StatusManager\\Database\\Map\\UserTableMap'; |
|
| 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 name field. |
|
| 88 | + * |
|
| 89 | + * @var string |
|
| 90 | + */ |
|
| 91 | + protected $name; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @var ChildInstance |
|
| 95 | + */ |
|
| 96 | + protected $aInstance; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @var ObjectCollection|ChildConnection[] Collection to store aggregation of ChildConnection objects. |
|
| 100 | + */ |
|
| 101 | + protected $collConnections; |
|
| 102 | + protected $collConnectionsPartial; |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @var ObjectCollection|ChildSubscription[] Collection to store aggregation of ChildSubscription objects. |
|
| 106 | + */ |
|
| 107 | + protected $collSubscriptions; |
|
| 108 | + protected $collSubscriptionsPartial; |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Flag to prevent endless save loop, if this object is referenced |
|
| 112 | + * by another object which falls in this transaction. |
|
| 113 | + * |
|
| 114 | + * @var boolean |
|
| 115 | + */ |
|
| 116 | + protected $alreadyInSave = false; |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * An array of objects scheduled for deletion. |
|
| 120 | + * @var ObjectCollection|ChildConnection[] |
|
| 121 | + */ |
|
| 122 | + protected $connectionsScheduledForDeletion = null; |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * An array of objects scheduled for deletion. |
|
| 126 | + * @var ObjectCollection|ChildSubscription[] |
|
| 127 | + */ |
|
| 128 | + protected $subscriptionsScheduledForDeletion = null; |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Initializes internal state of Jalle19\StatusManager\Database\Base\User object. |
|
| 132 | + */ |
|
| 133 | + public function __construct() |
|
| 134 | + { |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Returns whether the object has been modified. |
|
| 139 | + * |
|
| 140 | + * @return boolean True if the object has been modified. |
|
| 141 | + */ |
|
| 142 | + public function isModified() |
|
| 143 | + { |
|
| 144 | + return !!$this->modifiedColumns; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Has specified column been modified? |
|
| 149 | + * |
|
| 150 | + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
|
| 151 | + * @return boolean True if $col has been modified. |
|
| 152 | + */ |
|
| 153 | + public function isColumnModified($col) |
|
| 154 | + { |
|
| 155 | + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Get the columns that have been modified in this object. |
|
| 160 | + * @return array A unique list of the modified column names for this object. |
|
| 161 | + */ |
|
| 162 | + public function getModifiedColumns() |
|
| 163 | + { |
|
| 164 | + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Returns whether the object has ever been saved. This will |
|
| 169 | + * be false, if the object was retrieved from storage or was created |
|
| 170 | + * and then saved. |
|
| 171 | + * |
|
| 172 | + * @return boolean true, if the object has never been persisted. |
|
| 173 | + */ |
|
| 174 | + public function isNew() |
|
| 175 | + { |
|
| 176 | + return $this->new; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Setter for the isNew attribute. This method will be called |
|
| 181 | + * by Propel-generated children and objects. |
|
| 182 | + * |
|
| 183 | + * @param boolean $b the state of the object. |
|
| 184 | + */ |
|
| 185 | + public function setNew($b) |
|
| 186 | + { |
|
| 187 | + $this->new = (boolean) $b; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Whether this object has been deleted. |
|
| 192 | + * @return boolean The deleted state of this object. |
|
| 193 | + */ |
|
| 194 | + public function isDeleted() |
|
| 195 | + { |
|
| 196 | + return $this->deleted; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * Specify whether this object has been deleted. |
|
| 201 | + * @param boolean $b The deleted state of this object. |
|
| 202 | + * @return void |
|
| 203 | + */ |
|
| 204 | + public function setDeleted($b) |
|
| 205 | + { |
|
| 206 | + $this->deleted = (boolean) $b; |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * Sets the modified state for the object to be false. |
|
| 211 | + * @param string $col If supplied, only the specified column is reset. |
|
| 212 | + * @return void |
|
| 213 | + */ |
|
| 214 | + public function resetModified($col = null) |
|
| 215 | + { |
|
| 216 | + if (null !== $col) { |
|
| 217 | + if (isset($this->modifiedColumns[$col])) { |
|
| 218 | + unset($this->modifiedColumns[$col]); |
|
| 219 | + } |
|
| 220 | + } else { |
|
| 221 | + $this->modifiedColumns = array(); |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + /** |
|
| 226 | + * Compares this with another <code>User</code> instance. If |
|
| 227 | + * <code>obj</code> is an instance of <code>User</code>, delegates to |
|
| 228 | + * <code>equals(User)</code>. Otherwise, returns <code>false</code>. |
|
| 229 | + * |
|
| 230 | + * @param mixed $obj The object to compare to. |
|
| 231 | + * @return boolean Whether equal to the object specified. |
|
| 232 | + */ |
|
| 233 | + public function equals($obj) |
|
| 234 | + { |
|
| 235 | + if (!$obj instanceof static) { |
|
| 236 | + return false; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + if ($this === $obj) { |
|
| 240 | + return true; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + if (null === $this->getPrimaryKey() || null === $obj->getPrimaryKey()) { |
|
| 244 | + return false; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + return $this->getPrimaryKey() === $obj->getPrimaryKey(); |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Get the associative array of the virtual columns in this object |
|
| 252 | + * |
|
| 253 | + * @return array |
|
| 254 | + */ |
|
| 255 | + public function getVirtualColumns() |
|
| 256 | + { |
|
| 257 | + return $this->virtualColumns; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * Checks the existence of a virtual column in this object |
|
| 262 | + * |
|
| 263 | + * @param string $name The virtual column name |
|
| 264 | + * @return boolean |
|
| 265 | + */ |
|
| 266 | + public function hasVirtualColumn($name) |
|
| 267 | + { |
|
| 268 | + return array_key_exists($name, $this->virtualColumns); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + /** |
|
| 272 | + * Get the value of a virtual column in this object |
|
| 273 | + * |
|
| 274 | + * @param string $name The virtual column name |
|
| 275 | + * @return mixed |
|
| 276 | + * |
|
| 277 | + * @throws PropelException |
|
| 278 | + */ |
|
| 279 | + public function getVirtualColumn($name) |
|
| 280 | + { |
|
| 281 | + if (!$this->hasVirtualColumn($name)) { |
|
| 282 | + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + return $this->virtualColumns[$name]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * Set the value of a virtual column in this object |
|
| 290 | + * |
|
| 291 | + * @param string $name The virtual column name |
|
| 292 | + * @param mixed $value The value to give to the virtual column |
|
| 293 | + * |
|
| 294 | + * @return $this|User The current object, for fluid interface |
|
| 295 | + */ |
|
| 296 | + public function setVirtualColumn($name, $value) |
|
| 297 | + { |
|
| 298 | + $this->virtualColumns[$name] = $value; |
|
| 299 | + |
|
| 300 | + return $this; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Logs a message using Propel::log(). |
|
| 305 | + * |
|
| 306 | + * @param string $msg |
|
| 307 | + * @param int $priority One of the Propel::LOG_* logging levels |
|
| 308 | + * @return boolean |
|
| 309 | + */ |
|
| 310 | + protected function log($msg, $priority = Propel::LOG_INFO) |
|
| 311 | + { |
|
| 312 | + return Propel::log(get_class($this) . ': ' . $msg, $priority); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + /** |
|
| 316 | + * Export the current object properties to a string, using a given parser format |
|
| 317 | + * <code> |
|
| 318 | + * $book = BookQuery::create()->findPk(9012); |
|
| 319 | + * echo $book->exportTo('JSON'); |
|
| 320 | + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 321 | + * </code> |
|
| 322 | + * |
|
| 323 | + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 324 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
|
| 325 | + * @return string The exported data |
|
| 326 | + */ |
|
| 327 | + public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 328 | + { |
|
| 329 | + if (!$parser instanceof AbstractParser) { |
|
| 330 | + $parser = AbstractParser::getParser($parser); |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * Clean up internal collections prior to serializing |
|
| 338 | + * Avoids recursive loops that turn into segmentation faults when serializing |
|
| 339 | + */ |
|
| 340 | + public function __sleep() |
|
| 341 | + { |
|
| 342 | + $this->clearAllReferences(); |
|
| 343 | + |
|
| 344 | + $cls = new \ReflectionClass($this); |
|
| 345 | + $propertyNames = []; |
|
| 346 | + $serializableProperties = array_diff($cls->getProperties(), $cls->getProperties(\ReflectionProperty::IS_STATIC)); |
|
| 347 | + |
|
| 348 | + foreach($serializableProperties as $property) { |
|
| 349 | + $propertyNames[] = $property->getName(); |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + return $propertyNames; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Get the [id] column value. |
|
| 357 | + * |
|
| 358 | + * @return int |
|
| 359 | + */ |
|
| 360 | + public function getId() |
|
| 361 | + { |
|
| 362 | + return $this->id; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * Get the [instance_name] column value. |
|
| 367 | + * |
|
| 368 | + * @return string |
|
| 369 | + */ |
|
| 370 | + public function getInstanceName() |
|
| 371 | + { |
|
| 372 | + return $this->instance_name; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * Get the [name] column value. |
|
| 377 | + * |
|
| 378 | + * @return string |
|
| 379 | + */ |
|
| 380 | + public function getName() |
|
| 381 | + { |
|
| 382 | + return $this->name; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * Set the value of [id] column. |
|
| 387 | + * |
|
| 388 | + * @param int $v new value |
|
| 389 | + * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 390 | + */ |
|
| 391 | + public function setId($v) |
|
| 392 | + { |
|
| 393 | + if ($v !== null) { |
|
| 394 | + $v = (int) $v; |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if ($this->id !== $v) { |
|
| 398 | + $this->id = $v; |
|
| 399 | + $this->modifiedColumns[UserTableMap::COL_ID] = true; |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + return $this; |
|
| 403 | + } // setId() |
|
| 404 | + |
|
| 405 | + /** |
|
| 406 | + * Set the value of [instance_name] column. |
|
| 407 | + * |
|
| 408 | + * @param string $v new value |
|
| 409 | + * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 410 | + */ |
|
| 411 | + public function setInstanceName($v) |
|
| 412 | + { |
|
| 413 | + if ($v !== null) { |
|
| 414 | + $v = (string) $v; |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + if ($this->instance_name !== $v) { |
|
| 418 | + $this->instance_name = $v; |
|
| 419 | + $this->modifiedColumns[UserTableMap::COL_INSTANCE_NAME] = true; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + if ($this->aInstance !== null && $this->aInstance->getName() !== $v) { |
|
| 423 | + $this->aInstance = null; |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + return $this; |
|
| 427 | + } // setInstanceName() |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * Set the value of [name] column. |
|
| 431 | + * |
|
| 432 | + * @param string $v new value |
|
| 433 | + * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 434 | + */ |
|
| 435 | + public function setName($v) |
|
| 436 | + { |
|
| 437 | + if ($v !== null) { |
|
| 438 | + $v = (string) $v; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + if ($this->name !== $v) { |
|
| 442 | + $this->name = $v; |
|
| 443 | + $this->modifiedColumns[UserTableMap::COL_NAME] = true; |
|
| 444 | + } |
|
| 445 | + |
|
| 446 | + return $this; |
|
| 447 | + } // setName() |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * Indicates whether the columns in this object are only set to default values. |
|
| 451 | + * |
|
| 452 | + * This method can be used in conjunction with isModified() to indicate whether an object is both |
|
| 453 | + * modified _and_ has some values set which are non-default. |
|
| 454 | + * |
|
| 455 | + * @return boolean Whether the columns in this object are only been set with default values. |
|
| 456 | + */ |
|
| 457 | + public function hasOnlyDefaultValues() |
|
| 458 | + { |
|
| 459 | + // otherwise, everything was equal, so return TRUE |
|
| 460 | + return true; |
|
| 461 | + } // hasOnlyDefaultValues() |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * Hydrates (populates) the object variables with values from the database resultset. |
|
| 465 | + * |
|
| 466 | + * An offset (0-based "start column") is specified so that objects can be hydrated |
|
| 467 | + * with a subset of the columns in the resultset rows. This is needed, for example, |
|
| 468 | + * for results of JOIN queries where the resultset row includes columns from two or |
|
| 469 | + * more tables. |
|
| 470 | + * |
|
| 471 | + * @param array $row The row returned by DataFetcher->fetch(). |
|
| 472 | + * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
|
| 473 | + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
|
| 474 | + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
|
| 475 | 475 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
| 476 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 477 | - * |
|
| 478 | - * @return int next starting column |
|
| 479 | - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 480 | - */ |
|
| 481 | - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 482 | - { |
|
| 483 | - try { |
|
| 484 | - |
|
| 485 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : UserTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 486 | - $this->id = (null !== $col) ? (int) $col : null; |
|
| 487 | - |
|
| 488 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : UserTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 489 | - $this->instance_name = (null !== $col) ? (string) $col : null; |
|
| 490 | - |
|
| 491 | - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : UserTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 492 | - $this->name = (null !== $col) ? (string) $col : null; |
|
| 493 | - $this->resetModified(); |
|
| 494 | - |
|
| 495 | - $this->setNew(false); |
|
| 496 | - |
|
| 497 | - if ($rehydrate) { |
|
| 498 | - $this->ensureConsistency(); |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - return $startcol + 3; // 3 = UserTableMap::NUM_HYDRATE_COLUMNS. |
|
| 502 | - |
|
| 503 | - } catch (Exception $e) { |
|
| 504 | - throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\User'), 0, $e); |
|
| 505 | - } |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - /** |
|
| 509 | - * Checks and repairs the internal consistency of the object. |
|
| 510 | - * |
|
| 511 | - * This method is executed after an already-instantiated object is re-hydrated |
|
| 512 | - * from the database. It exists to check any foreign keys to make sure that |
|
| 513 | - * the objects related to the current object are correct based on foreign key. |
|
| 514 | - * |
|
| 515 | - * You can override this method in the stub class, but you should always invoke |
|
| 516 | - * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 517 | - * in case your model changes. |
|
| 518 | - * |
|
| 519 | - * @throws PropelException |
|
| 520 | - */ |
|
| 521 | - public function ensureConsistency() |
|
| 522 | - { |
|
| 523 | - if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
| 524 | - $this->aInstance = null; |
|
| 525 | - } |
|
| 526 | - } // ensureConsistency |
|
| 527 | - |
|
| 528 | - /** |
|
| 529 | - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 530 | - * |
|
| 531 | - * This will only work if the object has been saved and has a valid primary key set. |
|
| 532 | - * |
|
| 533 | - * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 534 | - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 535 | - * @return void |
|
| 536 | - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 537 | - */ |
|
| 538 | - public function reload($deep = false, ConnectionInterface $con = null) |
|
| 539 | - { |
|
| 540 | - if ($this->isDeleted()) { |
|
| 541 | - throw new PropelException("Cannot reload a deleted object."); |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - if ($this->isNew()) { |
|
| 545 | - throw new PropelException("Cannot reload an unsaved object."); |
|
| 546 | - } |
|
| 547 | - |
|
| 548 | - if ($con === null) { |
|
| 549 | - $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME); |
|
| 550 | - } |
|
| 551 | - |
|
| 552 | - // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 553 | - // already in the pool. |
|
| 554 | - |
|
| 555 | - $dataFetcher = ChildUserQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 556 | - $row = $dataFetcher->fetch(); |
|
| 557 | - $dataFetcher->close(); |
|
| 558 | - if (!$row) { |
|
| 559 | - throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 560 | - } |
|
| 561 | - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 562 | - |
|
| 563 | - if ($deep) { // also de-associate any related objects? |
|
| 564 | - |
|
| 565 | - $this->aInstance = null; |
|
| 566 | - $this->collConnections = null; |
|
| 567 | - |
|
| 568 | - $this->collSubscriptions = null; |
|
| 569 | - |
|
| 570 | - } // if (deep) |
|
| 571 | - } |
|
| 572 | - |
|
| 573 | - /** |
|
| 574 | - * Removes this object from datastore and sets delete attribute. |
|
| 575 | - * |
|
| 576 | - * @param ConnectionInterface $con |
|
| 577 | - * @return void |
|
| 578 | - * @throws PropelException |
|
| 579 | - * @see User::setDeleted() |
|
| 580 | - * @see User::isDeleted() |
|
| 581 | - */ |
|
| 582 | - public function delete(ConnectionInterface $con = null) |
|
| 583 | - { |
|
| 584 | - if ($this->isDeleted()) { |
|
| 585 | - throw new PropelException("This object has already been deleted."); |
|
| 586 | - } |
|
| 587 | - |
|
| 588 | - if ($con === null) { |
|
| 589 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - $con->transaction(function () use ($con) { |
|
| 593 | - $deleteQuery = ChildUserQuery::create() |
|
| 594 | - ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 595 | - $ret = $this->preDelete($con); |
|
| 596 | - if ($ret) { |
|
| 597 | - $deleteQuery->delete($con); |
|
| 598 | - $this->postDelete($con); |
|
| 599 | - $this->setDeleted(true); |
|
| 600 | - } |
|
| 601 | - }); |
|
| 602 | - } |
|
| 603 | - |
|
| 604 | - /** |
|
| 605 | - * Persists this object to the database. |
|
| 606 | - * |
|
| 607 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 608 | - * All modified related objects will also be persisted in the doSave() |
|
| 609 | - * method. This method wraps all precipitate database operations in a |
|
| 610 | - * single transaction. |
|
| 611 | - * |
|
| 612 | - * @param ConnectionInterface $con |
|
| 613 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 614 | - * @throws PropelException |
|
| 615 | - * @see doSave() |
|
| 616 | - */ |
|
| 617 | - public function save(ConnectionInterface $con = null) |
|
| 618 | - { |
|
| 619 | - if ($this->isDeleted()) { |
|
| 620 | - throw new PropelException("You cannot save an object that has been deleted."); |
|
| 621 | - } |
|
| 622 | - |
|
| 623 | - if ($con === null) { |
|
| 624 | - $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
| 625 | - } |
|
| 626 | - |
|
| 627 | - return $con->transaction(function () use ($con) { |
|
| 628 | - $isInsert = $this->isNew(); |
|
| 629 | - $ret = $this->preSave($con); |
|
| 630 | - if ($isInsert) { |
|
| 631 | - $ret = $ret && $this->preInsert($con); |
|
| 632 | - } else { |
|
| 633 | - $ret = $ret && $this->preUpdate($con); |
|
| 634 | - } |
|
| 635 | - if ($ret) { |
|
| 636 | - $affectedRows = $this->doSave($con); |
|
| 637 | - if ($isInsert) { |
|
| 638 | - $this->postInsert($con); |
|
| 639 | - } else { |
|
| 640 | - $this->postUpdate($con); |
|
| 641 | - } |
|
| 642 | - $this->postSave($con); |
|
| 643 | - UserTableMap::addInstanceToPool($this); |
|
| 644 | - } else { |
|
| 645 | - $affectedRows = 0; |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - return $affectedRows; |
|
| 649 | - }); |
|
| 650 | - } |
|
| 651 | - |
|
| 652 | - /** |
|
| 653 | - * Performs the work of inserting or updating the row in the database. |
|
| 654 | - * |
|
| 655 | - * If the object is new, it inserts it; otherwise an update is performed. |
|
| 656 | - * All related objects are also updated in this method. |
|
| 657 | - * |
|
| 658 | - * @param ConnectionInterface $con |
|
| 659 | - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 660 | - * @throws PropelException |
|
| 661 | - * @see save() |
|
| 662 | - */ |
|
| 663 | - protected function doSave(ConnectionInterface $con) |
|
| 664 | - { |
|
| 665 | - $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 666 | - if (!$this->alreadyInSave) { |
|
| 667 | - $this->alreadyInSave = true; |
|
| 668 | - |
|
| 669 | - // We call the save method on the following object(s) if they |
|
| 670 | - // were passed to this object by their corresponding set |
|
| 671 | - // method. This object relates to these object(s) by a |
|
| 672 | - // foreign key reference. |
|
| 673 | - |
|
| 674 | - if ($this->aInstance !== null) { |
|
| 675 | - if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
| 676 | - $affectedRows += $this->aInstance->save($con); |
|
| 677 | - } |
|
| 678 | - $this->setInstance($this->aInstance); |
|
| 679 | - } |
|
| 680 | - |
|
| 681 | - if ($this->isNew() || $this->isModified()) { |
|
| 682 | - // persist changes |
|
| 683 | - if ($this->isNew()) { |
|
| 684 | - $this->doInsert($con); |
|
| 685 | - $affectedRows += 1; |
|
| 686 | - } else { |
|
| 687 | - $affectedRows += $this->doUpdate($con); |
|
| 688 | - } |
|
| 689 | - $this->resetModified(); |
|
| 690 | - } |
|
| 691 | - |
|
| 692 | - if ($this->connectionsScheduledForDeletion !== null) { |
|
| 693 | - if (!$this->connectionsScheduledForDeletion->isEmpty()) { |
|
| 694 | - foreach ($this->connectionsScheduledForDeletion as $connection) { |
|
| 695 | - // need to save related object because we set the relation to null |
|
| 696 | - $connection->save($con); |
|
| 697 | - } |
|
| 698 | - $this->connectionsScheduledForDeletion = null; |
|
| 699 | - } |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - if ($this->collConnections !== null) { |
|
| 703 | - foreach ($this->collConnections as $referrerFK) { |
|
| 704 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 705 | - $affectedRows += $referrerFK->save($con); |
|
| 706 | - } |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 711 | - if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 712 | - foreach ($this->subscriptionsScheduledForDeletion as $subscription) { |
|
| 713 | - // need to save related object because we set the relation to null |
|
| 714 | - $subscription->save($con); |
|
| 715 | - } |
|
| 716 | - $this->subscriptionsScheduledForDeletion = null; |
|
| 717 | - } |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - if ($this->collSubscriptions !== null) { |
|
| 721 | - foreach ($this->collSubscriptions as $referrerFK) { |
|
| 722 | - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 723 | - $affectedRows += $referrerFK->save($con); |
|
| 724 | - } |
|
| 725 | - } |
|
| 726 | - } |
|
| 727 | - |
|
| 728 | - $this->alreadyInSave = false; |
|
| 729 | - |
|
| 730 | - } |
|
| 731 | - |
|
| 732 | - return $affectedRows; |
|
| 733 | - } // doSave() |
|
| 734 | - |
|
| 735 | - /** |
|
| 736 | - * Insert the row in the database. |
|
| 737 | - * |
|
| 738 | - * @param ConnectionInterface $con |
|
| 739 | - * |
|
| 740 | - * @throws PropelException |
|
| 741 | - * @see doSave() |
|
| 742 | - */ |
|
| 743 | - protected function doInsert(ConnectionInterface $con) |
|
| 744 | - { |
|
| 745 | - $modifiedColumns = array(); |
|
| 746 | - $index = 0; |
|
| 747 | - |
|
| 748 | - $this->modifiedColumns[UserTableMap::COL_ID] = true; |
|
| 749 | - if (null !== $this->id) { |
|
| 750 | - throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')'); |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - // check the columns in natural order for more readable SQL queries |
|
| 754 | - if ($this->isColumnModified(UserTableMap::COL_ID)) { |
|
| 755 | - $modifiedColumns[':p' . $index++] = 'id'; |
|
| 756 | - } |
|
| 757 | - if ($this->isColumnModified(UserTableMap::COL_INSTANCE_NAME)) { |
|
| 758 | - $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
| 759 | - } |
|
| 760 | - if ($this->isColumnModified(UserTableMap::COL_NAME)) { |
|
| 761 | - $modifiedColumns[':p' . $index++] = 'name'; |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - $sql = sprintf( |
|
| 765 | - 'INSERT INTO user (%s) VALUES (%s)', |
|
| 766 | - implode(', ', $modifiedColumns), |
|
| 767 | - implode(', ', array_keys($modifiedColumns)) |
|
| 768 | - ); |
|
| 769 | - |
|
| 770 | - try { |
|
| 771 | - $stmt = $con->prepare($sql); |
|
| 772 | - foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 773 | - switch ($columnName) { |
|
| 774 | - case 'id': |
|
| 775 | - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
| 776 | - break; |
|
| 777 | - case 'instance_name': |
|
| 778 | - $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
| 779 | - break; |
|
| 780 | - case 'name': |
|
| 781 | - $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
|
| 782 | - break; |
|
| 783 | - } |
|
| 784 | - } |
|
| 785 | - $stmt->execute(); |
|
| 786 | - } catch (Exception $e) { |
|
| 787 | - Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 788 | - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 789 | - } |
|
| 790 | - |
|
| 791 | - try { |
|
| 792 | - $pk = $con->lastInsertId(); |
|
| 793 | - } catch (Exception $e) { |
|
| 794 | - throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
| 795 | - } |
|
| 796 | - $this->setId($pk); |
|
| 797 | - |
|
| 798 | - $this->setNew(false); |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - /** |
|
| 802 | - * Update the row in the database. |
|
| 803 | - * |
|
| 804 | - * @param ConnectionInterface $con |
|
| 805 | - * |
|
| 806 | - * @return Integer Number of updated rows |
|
| 807 | - * @see doSave() |
|
| 808 | - */ |
|
| 809 | - protected function doUpdate(ConnectionInterface $con) |
|
| 810 | - { |
|
| 811 | - $selectCriteria = $this->buildPkeyCriteria(); |
|
| 812 | - $valuesCriteria = $this->buildCriteria(); |
|
| 813 | - |
|
| 814 | - return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - /** |
|
| 818 | - * Retrieves a field from the object by name passed in as a string. |
|
| 819 | - * |
|
| 820 | - * @param string $name name |
|
| 821 | - * @param string $type The type of fieldname the $name is of: |
|
| 822 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 823 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 824 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 825 | - * @return mixed Value of field. |
|
| 826 | - */ |
|
| 827 | - public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 828 | - { |
|
| 829 | - $pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 830 | - $field = $this->getByPosition($pos); |
|
| 831 | - |
|
| 832 | - return $field; |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - /** |
|
| 836 | - * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 837 | - * Zero-based. |
|
| 838 | - * |
|
| 839 | - * @param int $pos position in xml schema |
|
| 840 | - * @return mixed Value of field at $pos |
|
| 841 | - */ |
|
| 842 | - public function getByPosition($pos) |
|
| 843 | - { |
|
| 844 | - switch ($pos) { |
|
| 845 | - case 0: |
|
| 846 | - return $this->getId(); |
|
| 847 | - break; |
|
| 848 | - case 1: |
|
| 849 | - return $this->getInstanceName(); |
|
| 850 | - break; |
|
| 851 | - case 2: |
|
| 852 | - return $this->getName(); |
|
| 853 | - break; |
|
| 854 | - default: |
|
| 855 | - return null; |
|
| 856 | - break; |
|
| 857 | - } // switch() |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - /** |
|
| 861 | - * Exports the object as an array. |
|
| 862 | - * |
|
| 863 | - * You can specify the key type of the array by passing one of the class |
|
| 864 | - * type constants. |
|
| 865 | - * |
|
| 866 | - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 867 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 868 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 869 | - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 870 | - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 871 | - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 872 | - * |
|
| 873 | - * @return array an associative array containing the field names (as keys) and field values |
|
| 874 | - */ |
|
| 875 | - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 876 | - { |
|
| 877 | - |
|
| 878 | - if (isset($alreadyDumpedObjects['User'][$this->hashCode()])) { |
|
| 879 | - return '*RECURSION*'; |
|
| 880 | - } |
|
| 881 | - $alreadyDumpedObjects['User'][$this->hashCode()] = true; |
|
| 882 | - $keys = UserTableMap::getFieldNames($keyType); |
|
| 883 | - $result = array( |
|
| 884 | - $keys[0] => $this->getId(), |
|
| 885 | - $keys[1] => $this->getInstanceName(), |
|
| 886 | - $keys[2] => $this->getName(), |
|
| 887 | - ); |
|
| 888 | - $virtualColumns = $this->virtualColumns; |
|
| 889 | - foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 890 | - $result[$key] = $virtualColumn; |
|
| 891 | - } |
|
| 892 | - |
|
| 893 | - if ($includeForeignObjects) { |
|
| 894 | - if (null !== $this->aInstance) { |
|
| 895 | - |
|
| 896 | - switch ($keyType) { |
|
| 897 | - case TableMap::TYPE_CAMELNAME: |
|
| 898 | - $key = 'instance'; |
|
| 899 | - break; |
|
| 900 | - case TableMap::TYPE_FIELDNAME: |
|
| 901 | - $key = 'instance'; |
|
| 902 | - break; |
|
| 903 | - default: |
|
| 904 | - $key = 'Instance'; |
|
| 905 | - } |
|
| 906 | - |
|
| 907 | - $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
| 908 | - } |
|
| 909 | - if (null !== $this->collConnections) { |
|
| 910 | - |
|
| 911 | - switch ($keyType) { |
|
| 912 | - case TableMap::TYPE_CAMELNAME: |
|
| 913 | - $key = 'connections'; |
|
| 914 | - break; |
|
| 915 | - case TableMap::TYPE_FIELDNAME: |
|
| 916 | - $key = 'connections'; |
|
| 917 | - break; |
|
| 918 | - default: |
|
| 919 | - $key = 'Connections'; |
|
| 920 | - } |
|
| 921 | - |
|
| 922 | - $result[$key] = $this->collConnections->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 923 | - } |
|
| 924 | - if (null !== $this->collSubscriptions) { |
|
| 925 | - |
|
| 926 | - switch ($keyType) { |
|
| 927 | - case TableMap::TYPE_CAMELNAME: |
|
| 928 | - $key = 'subscriptions'; |
|
| 929 | - break; |
|
| 930 | - case TableMap::TYPE_FIELDNAME: |
|
| 931 | - $key = 'subscriptions'; |
|
| 932 | - break; |
|
| 933 | - default: |
|
| 934 | - $key = 'Subscriptions'; |
|
| 935 | - } |
|
| 936 | - |
|
| 937 | - $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 938 | - } |
|
| 939 | - } |
|
| 940 | - |
|
| 941 | - return $result; |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - /** |
|
| 945 | - * Sets a field from the object by name passed in as a string. |
|
| 946 | - * |
|
| 947 | - * @param string $name |
|
| 948 | - * @param mixed $value field value |
|
| 949 | - * @param string $type The type of fieldname the $name is of: |
|
| 950 | - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 951 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 952 | - * Defaults to TableMap::TYPE_PHPNAME. |
|
| 953 | - * @return $this|\Jalle19\StatusManager\Database\User |
|
| 954 | - */ |
|
| 955 | - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 956 | - { |
|
| 957 | - $pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 958 | - |
|
| 959 | - return $this->setByPosition($pos, $value); |
|
| 960 | - } |
|
| 961 | - |
|
| 962 | - /** |
|
| 963 | - * Sets a field from the object by Position as specified in the xml schema. |
|
| 964 | - * Zero-based. |
|
| 965 | - * |
|
| 966 | - * @param int $pos position in xml schema |
|
| 967 | - * @param mixed $value field value |
|
| 968 | - * @return $this|\Jalle19\StatusManager\Database\User |
|
| 969 | - */ |
|
| 970 | - public function setByPosition($pos, $value) |
|
| 971 | - { |
|
| 972 | - switch ($pos) { |
|
| 973 | - case 0: |
|
| 974 | - $this->setId($value); |
|
| 975 | - break; |
|
| 976 | - case 1: |
|
| 977 | - $this->setInstanceName($value); |
|
| 978 | - break; |
|
| 979 | - case 2: |
|
| 980 | - $this->setName($value); |
|
| 981 | - break; |
|
| 982 | - } // switch() |
|
| 983 | - |
|
| 984 | - return $this; |
|
| 985 | - } |
|
| 986 | - |
|
| 987 | - /** |
|
| 988 | - * Populates the object using an array. |
|
| 989 | - * |
|
| 990 | - * This is particularly useful when populating an object from one of the |
|
| 991 | - * request arrays (e.g. $_POST). This method goes through the column |
|
| 992 | - * names, checking to see whether a matching key exists in populated |
|
| 993 | - * array. If so the setByName() method is called for that column. |
|
| 994 | - * |
|
| 995 | - * You can specify the key type of the array by additionally passing one |
|
| 996 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 997 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 998 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 999 | - * |
|
| 1000 | - * @param array $arr An array to populate the object from. |
|
| 1001 | - * @param string $keyType The type of keys the array uses. |
|
| 1002 | - * @return void |
|
| 1003 | - */ |
|
| 1004 | - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1005 | - { |
|
| 1006 | - $keys = UserTableMap::getFieldNames($keyType); |
|
| 1007 | - |
|
| 1008 | - if (array_key_exists($keys[0], $arr)) { |
|
| 1009 | - $this->setId($arr[$keys[0]]); |
|
| 1010 | - } |
|
| 1011 | - if (array_key_exists($keys[1], $arr)) { |
|
| 1012 | - $this->setInstanceName($arr[$keys[1]]); |
|
| 1013 | - } |
|
| 1014 | - if (array_key_exists($keys[2], $arr)) { |
|
| 1015 | - $this->setName($arr[$keys[2]]); |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1018 | - |
|
| 1019 | - /** |
|
| 1020 | - * Populate the current object from a string, using a given parser format |
|
| 1021 | - * <code> |
|
| 1022 | - * $book = new Book(); |
|
| 1023 | - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 1024 | - * </code> |
|
| 1025 | - * |
|
| 1026 | - * You can specify the key type of the array by additionally passing one |
|
| 1027 | - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1028 | - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1029 | - * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1030 | - * |
|
| 1031 | - * @param mixed $parser A AbstractParser instance, |
|
| 1032 | - * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 1033 | - * @param string $data The source data to import from |
|
| 1034 | - * @param string $keyType The type of keys the array uses. |
|
| 1035 | - * |
|
| 1036 | - * @return $this|\Jalle19\StatusManager\Database\User The current object, for fluid interface |
|
| 1037 | - */ |
|
| 1038 | - public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1039 | - { |
|
| 1040 | - if (!$parser instanceof AbstractParser) { |
|
| 1041 | - $parser = AbstractParser::getParser($parser); |
|
| 1042 | - } |
|
| 1043 | - |
|
| 1044 | - $this->fromArray($parser->toArray($data), $keyType); |
|
| 1045 | - |
|
| 1046 | - return $this; |
|
| 1047 | - } |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1051 | - * |
|
| 1052 | - * @return Criteria The Criteria object containing all modified values. |
|
| 1053 | - */ |
|
| 1054 | - public function buildCriteria() |
|
| 1055 | - { |
|
| 1056 | - $criteria = new Criteria(UserTableMap::DATABASE_NAME); |
|
| 1057 | - |
|
| 1058 | - if ($this->isColumnModified(UserTableMap::COL_ID)) { |
|
| 1059 | - $criteria->add(UserTableMap::COL_ID, $this->id); |
|
| 1060 | - } |
|
| 1061 | - if ($this->isColumnModified(UserTableMap::COL_INSTANCE_NAME)) { |
|
| 1062 | - $criteria->add(UserTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
| 1063 | - } |
|
| 1064 | - if ($this->isColumnModified(UserTableMap::COL_NAME)) { |
|
| 1065 | - $criteria->add(UserTableMap::COL_NAME, $this->name); |
|
| 1066 | - } |
|
| 1067 | - |
|
| 1068 | - return $criteria; |
|
| 1069 | - } |
|
| 1070 | - |
|
| 1071 | - /** |
|
| 1072 | - * Builds a Criteria object containing the primary key for this object. |
|
| 1073 | - * |
|
| 1074 | - * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1075 | - * of whether or not they have been modified. |
|
| 1076 | - * |
|
| 1077 | - * @throws LogicException if no primary key is defined |
|
| 1078 | - * |
|
| 1079 | - * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1080 | - */ |
|
| 1081 | - public function buildPkeyCriteria() |
|
| 1082 | - { |
|
| 1083 | - $criteria = ChildUserQuery::create(); |
|
| 1084 | - $criteria->add(UserTableMap::COL_ID, $this->id); |
|
| 1085 | - |
|
| 1086 | - return $criteria; |
|
| 1087 | - } |
|
| 1088 | - |
|
| 1089 | - /** |
|
| 1090 | - * If the primary key is not null, return the hashcode of the |
|
| 1091 | - * primary key. Otherwise, return the hash code of the object. |
|
| 1092 | - * |
|
| 1093 | - * @return int Hashcode |
|
| 1094 | - */ |
|
| 1095 | - public function hashCode() |
|
| 1096 | - { |
|
| 1097 | - $validPk = null !== $this->getId(); |
|
| 1098 | - |
|
| 1099 | - $validPrimaryKeyFKs = 0; |
|
| 1100 | - $primaryKeyFKs = []; |
|
| 1101 | - |
|
| 1102 | - if ($validPk) { |
|
| 1103 | - return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1104 | - } elseif ($validPrimaryKeyFKs) { |
|
| 1105 | - return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1106 | - } |
|
| 1107 | - |
|
| 1108 | - return spl_object_hash($this); |
|
| 1109 | - } |
|
| 1110 | - |
|
| 1111 | - /** |
|
| 1112 | - * Returns the primary key for this object (row). |
|
| 1113 | - * @return int |
|
| 1114 | - */ |
|
| 1115 | - public function getPrimaryKey() |
|
| 1116 | - { |
|
| 1117 | - return $this->getId(); |
|
| 1118 | - } |
|
| 1119 | - |
|
| 1120 | - /** |
|
| 1121 | - * Generic method to set the primary key (id column). |
|
| 1122 | - * |
|
| 1123 | - * @param int $key Primary key. |
|
| 1124 | - * @return void |
|
| 1125 | - */ |
|
| 1126 | - public function setPrimaryKey($key) |
|
| 1127 | - { |
|
| 1128 | - $this->setId($key); |
|
| 1129 | - } |
|
| 1130 | - |
|
| 1131 | - /** |
|
| 1132 | - * Returns true if the primary key for this object is null. |
|
| 1133 | - * @return boolean |
|
| 1134 | - */ |
|
| 1135 | - public function isPrimaryKeyNull() |
|
| 1136 | - { |
|
| 1137 | - return null === $this->getId(); |
|
| 1138 | - } |
|
| 1139 | - |
|
| 1140 | - /** |
|
| 1141 | - * Sets contents of passed object to values from current object. |
|
| 1142 | - * |
|
| 1143 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1144 | - * objects. |
|
| 1145 | - * |
|
| 1146 | - * @param object $copyObj An object of \Jalle19\StatusManager\Database\User (or compatible) type. |
|
| 1147 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1148 | - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1149 | - * @throws PropelException |
|
| 1150 | - */ |
|
| 1151 | - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1152 | - { |
|
| 1153 | - $copyObj->setInstanceName($this->getInstanceName()); |
|
| 1154 | - $copyObj->setName($this->getName()); |
|
| 1155 | - |
|
| 1156 | - if ($deepCopy) { |
|
| 1157 | - // important: temporarily setNew(false) because this affects the behavior of |
|
| 1158 | - // the getter/setter methods for fkey referrer objects. |
|
| 1159 | - $copyObj->setNew(false); |
|
| 1160 | - |
|
| 1161 | - foreach ($this->getConnections() as $relObj) { |
|
| 1162 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1163 | - $copyObj->addConnection($relObj->copy($deepCopy)); |
|
| 1164 | - } |
|
| 1165 | - } |
|
| 1166 | - |
|
| 1167 | - foreach ($this->getSubscriptions() as $relObj) { |
|
| 1168 | - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1169 | - $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1170 | - } |
|
| 1171 | - } |
|
| 1172 | - |
|
| 1173 | - } // if ($deepCopy) |
|
| 1174 | - |
|
| 1175 | - if ($makeNew) { |
|
| 1176 | - $copyObj->setNew(true); |
|
| 1177 | - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
|
| 1178 | - } |
|
| 1179 | - } |
|
| 1180 | - |
|
| 1181 | - /** |
|
| 1182 | - * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1183 | - * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1184 | - * keys that are defined for the table. |
|
| 1185 | - * |
|
| 1186 | - * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1187 | - * objects. |
|
| 1188 | - * |
|
| 1189 | - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1190 | - * @return \Jalle19\StatusManager\Database\User Clone of current object. |
|
| 1191 | - * @throws PropelException |
|
| 1192 | - */ |
|
| 1193 | - public function copy($deepCopy = false) |
|
| 1194 | - { |
|
| 1195 | - // we use get_class(), because this might be a subclass |
|
| 1196 | - $clazz = get_class($this); |
|
| 1197 | - $copyObj = new $clazz(); |
|
| 1198 | - $this->copyInto($copyObj, $deepCopy); |
|
| 1199 | - |
|
| 1200 | - return $copyObj; |
|
| 1201 | - } |
|
| 1202 | - |
|
| 1203 | - /** |
|
| 1204 | - * Declares an association between this object and a ChildInstance object. |
|
| 1205 | - * |
|
| 1206 | - * @param ChildInstance $v |
|
| 1207 | - * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 1208 | - * @throws PropelException |
|
| 1209 | - */ |
|
| 1210 | - public function setInstance(ChildInstance $v = null) |
|
| 1211 | - { |
|
| 1212 | - if ($v === null) { |
|
| 1213 | - $this->setInstanceName(NULL); |
|
| 1214 | - } else { |
|
| 1215 | - $this->setInstanceName($v->getName()); |
|
| 1216 | - } |
|
| 1217 | - |
|
| 1218 | - $this->aInstance = $v; |
|
| 1219 | - |
|
| 1220 | - // Add binding for other direction of this n:n relationship. |
|
| 1221 | - // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
| 1222 | - if ($v !== null) { |
|
| 1223 | - $v->addUser($this); |
|
| 1224 | - } |
|
| 1225 | - |
|
| 1226 | - |
|
| 1227 | - return $this; |
|
| 1228 | - } |
|
| 1229 | - |
|
| 1230 | - |
|
| 1231 | - /** |
|
| 1232 | - * Get the associated ChildInstance object |
|
| 1233 | - * |
|
| 1234 | - * @param ConnectionInterface $con Optional Connection object. |
|
| 1235 | - * @return ChildInstance The associated ChildInstance object. |
|
| 1236 | - * @throws PropelException |
|
| 1237 | - */ |
|
| 1238 | - public function getInstance(ConnectionInterface $con = null) |
|
| 1239 | - { |
|
| 1240 | - if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
| 1241 | - $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
| 1242 | - /* The following can be used additionally to |
|
| 476 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 477 | + * |
|
| 478 | + * @return int next starting column |
|
| 479 | + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|
| 480 | + */ |
|
| 481 | + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
|
| 482 | + { |
|
| 483 | + try { |
|
| 484 | + |
|
| 485 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : UserTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 486 | + $this->id = (null !== $col) ? (int) $col : null; |
|
| 487 | + |
|
| 488 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : UserTableMap::translateFieldName('InstanceName', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 489 | + $this->instance_name = (null !== $col) ? (string) $col : null; |
|
| 490 | + |
|
| 491 | + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : UserTableMap::translateFieldName('Name', TableMap::TYPE_PHPNAME, $indexType)]; |
|
| 492 | + $this->name = (null !== $col) ? (string) $col : null; |
|
| 493 | + $this->resetModified(); |
|
| 494 | + |
|
| 495 | + $this->setNew(false); |
|
| 496 | + |
|
| 497 | + if ($rehydrate) { |
|
| 498 | + $this->ensureConsistency(); |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + return $startcol + 3; // 3 = UserTableMap::NUM_HYDRATE_COLUMNS. |
|
| 502 | + |
|
| 503 | + } catch (Exception $e) { |
|
| 504 | + throw new PropelException(sprintf('Error populating %s object', '\\Jalle19\\StatusManager\\Database\\User'), 0, $e); |
|
| 505 | + } |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + /** |
|
| 509 | + * Checks and repairs the internal consistency of the object. |
|
| 510 | + * |
|
| 511 | + * This method is executed after an already-instantiated object is re-hydrated |
|
| 512 | + * from the database. It exists to check any foreign keys to make sure that |
|
| 513 | + * the objects related to the current object are correct based on foreign key. |
|
| 514 | + * |
|
| 515 | + * You can override this method in the stub class, but you should always invoke |
|
| 516 | + * the base method from the overridden method (i.e. parent::ensureConsistency()), |
|
| 517 | + * in case your model changes. |
|
| 518 | + * |
|
| 519 | + * @throws PropelException |
|
| 520 | + */ |
|
| 521 | + public function ensureConsistency() |
|
| 522 | + { |
|
| 523 | + if ($this->aInstance !== null && $this->instance_name !== $this->aInstance->getName()) { |
|
| 524 | + $this->aInstance = null; |
|
| 525 | + } |
|
| 526 | + } // ensureConsistency |
|
| 527 | + |
|
| 528 | + /** |
|
| 529 | + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
|
| 530 | + * |
|
| 531 | + * This will only work if the object has been saved and has a valid primary key set. |
|
| 532 | + * |
|
| 533 | + * @param boolean $deep (optional) Whether to also de-associated any related objects. |
|
| 534 | + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
|
| 535 | + * @return void |
|
| 536 | + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
|
| 537 | + */ |
|
| 538 | + public function reload($deep = false, ConnectionInterface $con = null) |
|
| 539 | + { |
|
| 540 | + if ($this->isDeleted()) { |
|
| 541 | + throw new PropelException("Cannot reload a deleted object."); |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + if ($this->isNew()) { |
|
| 545 | + throw new PropelException("Cannot reload an unsaved object."); |
|
| 546 | + } |
|
| 547 | + |
|
| 548 | + if ($con === null) { |
|
| 549 | + $con = Propel::getServiceContainer()->getReadConnection(UserTableMap::DATABASE_NAME); |
|
| 550 | + } |
|
| 551 | + |
|
| 552 | + // We don't need to alter the object instance pool; we're just modifying this instance |
|
| 553 | + // already in the pool. |
|
| 554 | + |
|
| 555 | + $dataFetcher = ChildUserQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); |
|
| 556 | + $row = $dataFetcher->fetch(); |
|
| 557 | + $dataFetcher->close(); |
|
| 558 | + if (!$row) { |
|
| 559 | + throw new PropelException('Cannot find matching row in the database to reload object values.'); |
|
| 560 | + } |
|
| 561 | + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate |
|
| 562 | + |
|
| 563 | + if ($deep) { // also de-associate any related objects? |
|
| 564 | + |
|
| 565 | + $this->aInstance = null; |
|
| 566 | + $this->collConnections = null; |
|
| 567 | + |
|
| 568 | + $this->collSubscriptions = null; |
|
| 569 | + |
|
| 570 | + } // if (deep) |
|
| 571 | + } |
|
| 572 | + |
|
| 573 | + /** |
|
| 574 | + * Removes this object from datastore and sets delete attribute. |
|
| 575 | + * |
|
| 576 | + * @param ConnectionInterface $con |
|
| 577 | + * @return void |
|
| 578 | + * @throws PropelException |
|
| 579 | + * @see User::setDeleted() |
|
| 580 | + * @see User::isDeleted() |
|
| 581 | + */ |
|
| 582 | + public function delete(ConnectionInterface $con = null) |
|
| 583 | + { |
|
| 584 | + if ($this->isDeleted()) { |
|
| 585 | + throw new PropelException("This object has already been deleted."); |
|
| 586 | + } |
|
| 587 | + |
|
| 588 | + if ($con === null) { |
|
| 589 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + $con->transaction(function () use ($con) { |
|
| 593 | + $deleteQuery = ChildUserQuery::create() |
|
| 594 | + ->filterByPrimaryKey($this->getPrimaryKey()); |
|
| 595 | + $ret = $this->preDelete($con); |
|
| 596 | + if ($ret) { |
|
| 597 | + $deleteQuery->delete($con); |
|
| 598 | + $this->postDelete($con); |
|
| 599 | + $this->setDeleted(true); |
|
| 600 | + } |
|
| 601 | + }); |
|
| 602 | + } |
|
| 603 | + |
|
| 604 | + /** |
|
| 605 | + * Persists this object to the database. |
|
| 606 | + * |
|
| 607 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 608 | + * All modified related objects will also be persisted in the doSave() |
|
| 609 | + * method. This method wraps all precipitate database operations in a |
|
| 610 | + * single transaction. |
|
| 611 | + * |
|
| 612 | + * @param ConnectionInterface $con |
|
| 613 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 614 | + * @throws PropelException |
|
| 615 | + * @see doSave() |
|
| 616 | + */ |
|
| 617 | + public function save(ConnectionInterface $con = null) |
|
| 618 | + { |
|
| 619 | + if ($this->isDeleted()) { |
|
| 620 | + throw new PropelException("You cannot save an object that has been deleted."); |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + if ($con === null) { |
|
| 624 | + $con = Propel::getServiceContainer()->getWriteConnection(UserTableMap::DATABASE_NAME); |
|
| 625 | + } |
|
| 626 | + |
|
| 627 | + return $con->transaction(function () use ($con) { |
|
| 628 | + $isInsert = $this->isNew(); |
|
| 629 | + $ret = $this->preSave($con); |
|
| 630 | + if ($isInsert) { |
|
| 631 | + $ret = $ret && $this->preInsert($con); |
|
| 632 | + } else { |
|
| 633 | + $ret = $ret && $this->preUpdate($con); |
|
| 634 | + } |
|
| 635 | + if ($ret) { |
|
| 636 | + $affectedRows = $this->doSave($con); |
|
| 637 | + if ($isInsert) { |
|
| 638 | + $this->postInsert($con); |
|
| 639 | + } else { |
|
| 640 | + $this->postUpdate($con); |
|
| 641 | + } |
|
| 642 | + $this->postSave($con); |
|
| 643 | + UserTableMap::addInstanceToPool($this); |
|
| 644 | + } else { |
|
| 645 | + $affectedRows = 0; |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + return $affectedRows; |
|
| 649 | + }); |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + /** |
|
| 653 | + * Performs the work of inserting or updating the row in the database. |
|
| 654 | + * |
|
| 655 | + * If the object is new, it inserts it; otherwise an update is performed. |
|
| 656 | + * All related objects are also updated in this method. |
|
| 657 | + * |
|
| 658 | + * @param ConnectionInterface $con |
|
| 659 | + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|
| 660 | + * @throws PropelException |
|
| 661 | + * @see save() |
|
| 662 | + */ |
|
| 663 | + protected function doSave(ConnectionInterface $con) |
|
| 664 | + { |
|
| 665 | + $affectedRows = 0; // initialize var to track total num of affected rows |
|
| 666 | + if (!$this->alreadyInSave) { |
|
| 667 | + $this->alreadyInSave = true; |
|
| 668 | + |
|
| 669 | + // We call the save method on the following object(s) if they |
|
| 670 | + // were passed to this object by their corresponding set |
|
| 671 | + // method. This object relates to these object(s) by a |
|
| 672 | + // foreign key reference. |
|
| 673 | + |
|
| 674 | + if ($this->aInstance !== null) { |
|
| 675 | + if ($this->aInstance->isModified() || $this->aInstance->isNew()) { |
|
| 676 | + $affectedRows += $this->aInstance->save($con); |
|
| 677 | + } |
|
| 678 | + $this->setInstance($this->aInstance); |
|
| 679 | + } |
|
| 680 | + |
|
| 681 | + if ($this->isNew() || $this->isModified()) { |
|
| 682 | + // persist changes |
|
| 683 | + if ($this->isNew()) { |
|
| 684 | + $this->doInsert($con); |
|
| 685 | + $affectedRows += 1; |
|
| 686 | + } else { |
|
| 687 | + $affectedRows += $this->doUpdate($con); |
|
| 688 | + } |
|
| 689 | + $this->resetModified(); |
|
| 690 | + } |
|
| 691 | + |
|
| 692 | + if ($this->connectionsScheduledForDeletion !== null) { |
|
| 693 | + if (!$this->connectionsScheduledForDeletion->isEmpty()) { |
|
| 694 | + foreach ($this->connectionsScheduledForDeletion as $connection) { |
|
| 695 | + // need to save related object because we set the relation to null |
|
| 696 | + $connection->save($con); |
|
| 697 | + } |
|
| 698 | + $this->connectionsScheduledForDeletion = null; |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + if ($this->collConnections !== null) { |
|
| 703 | + foreach ($this->collConnections as $referrerFK) { |
|
| 704 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 705 | + $affectedRows += $referrerFK->save($con); |
|
| 706 | + } |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + if ($this->subscriptionsScheduledForDeletion !== null) { |
|
| 711 | + if (!$this->subscriptionsScheduledForDeletion->isEmpty()) { |
|
| 712 | + foreach ($this->subscriptionsScheduledForDeletion as $subscription) { |
|
| 713 | + // need to save related object because we set the relation to null |
|
| 714 | + $subscription->save($con); |
|
| 715 | + } |
|
| 716 | + $this->subscriptionsScheduledForDeletion = null; |
|
| 717 | + } |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + if ($this->collSubscriptions !== null) { |
|
| 721 | + foreach ($this->collSubscriptions as $referrerFK) { |
|
| 722 | + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { |
|
| 723 | + $affectedRows += $referrerFK->save($con); |
|
| 724 | + } |
|
| 725 | + } |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + $this->alreadyInSave = false; |
|
| 729 | + |
|
| 730 | + } |
|
| 731 | + |
|
| 732 | + return $affectedRows; |
|
| 733 | + } // doSave() |
|
| 734 | + |
|
| 735 | + /** |
|
| 736 | + * Insert the row in the database. |
|
| 737 | + * |
|
| 738 | + * @param ConnectionInterface $con |
|
| 739 | + * |
|
| 740 | + * @throws PropelException |
|
| 741 | + * @see doSave() |
|
| 742 | + */ |
|
| 743 | + protected function doInsert(ConnectionInterface $con) |
|
| 744 | + { |
|
| 745 | + $modifiedColumns = array(); |
|
| 746 | + $index = 0; |
|
| 747 | + |
|
| 748 | + $this->modifiedColumns[UserTableMap::COL_ID] = true; |
|
| 749 | + if (null !== $this->id) { |
|
| 750 | + throw new PropelException('Cannot insert a value for auto-increment primary key (' . UserTableMap::COL_ID . ')'); |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + // check the columns in natural order for more readable SQL queries |
|
| 754 | + if ($this->isColumnModified(UserTableMap::COL_ID)) { |
|
| 755 | + $modifiedColumns[':p' . $index++] = 'id'; |
|
| 756 | + } |
|
| 757 | + if ($this->isColumnModified(UserTableMap::COL_INSTANCE_NAME)) { |
|
| 758 | + $modifiedColumns[':p' . $index++] = 'instance_name'; |
|
| 759 | + } |
|
| 760 | + if ($this->isColumnModified(UserTableMap::COL_NAME)) { |
|
| 761 | + $modifiedColumns[':p' . $index++] = 'name'; |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + $sql = sprintf( |
|
| 765 | + 'INSERT INTO user (%s) VALUES (%s)', |
|
| 766 | + implode(', ', $modifiedColumns), |
|
| 767 | + implode(', ', array_keys($modifiedColumns)) |
|
| 768 | + ); |
|
| 769 | + |
|
| 770 | + try { |
|
| 771 | + $stmt = $con->prepare($sql); |
|
| 772 | + foreach ($modifiedColumns as $identifier => $columnName) { |
|
| 773 | + switch ($columnName) { |
|
| 774 | + case 'id': |
|
| 775 | + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); |
|
| 776 | + break; |
|
| 777 | + case 'instance_name': |
|
| 778 | + $stmt->bindValue($identifier, $this->instance_name, PDO::PARAM_STR); |
|
| 779 | + break; |
|
| 780 | + case 'name': |
|
| 781 | + $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR); |
|
| 782 | + break; |
|
| 783 | + } |
|
| 784 | + } |
|
| 785 | + $stmt->execute(); |
|
| 786 | + } catch (Exception $e) { |
|
| 787 | + Propel::log($e->getMessage(), Propel::LOG_ERR); |
|
| 788 | + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); |
|
| 789 | + } |
|
| 790 | + |
|
| 791 | + try { |
|
| 792 | + $pk = $con->lastInsertId(); |
|
| 793 | + } catch (Exception $e) { |
|
| 794 | + throw new PropelException('Unable to get autoincrement id.', 0, $e); |
|
| 795 | + } |
|
| 796 | + $this->setId($pk); |
|
| 797 | + |
|
| 798 | + $this->setNew(false); |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + /** |
|
| 802 | + * Update the row in the database. |
|
| 803 | + * |
|
| 804 | + * @param ConnectionInterface $con |
|
| 805 | + * |
|
| 806 | + * @return Integer Number of updated rows |
|
| 807 | + * @see doSave() |
|
| 808 | + */ |
|
| 809 | + protected function doUpdate(ConnectionInterface $con) |
|
| 810 | + { |
|
| 811 | + $selectCriteria = $this->buildPkeyCriteria(); |
|
| 812 | + $valuesCriteria = $this->buildCriteria(); |
|
| 813 | + |
|
| 814 | + return $selectCriteria->doUpdate($valuesCriteria, $con); |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + /** |
|
| 818 | + * Retrieves a field from the object by name passed in as a string. |
|
| 819 | + * |
|
| 820 | + * @param string $name name |
|
| 821 | + * @param string $type The type of fieldname the $name is of: |
|
| 822 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 823 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 824 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 825 | + * @return mixed Value of field. |
|
| 826 | + */ |
|
| 827 | + public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 828 | + { |
|
| 829 | + $pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 830 | + $field = $this->getByPosition($pos); |
|
| 831 | + |
|
| 832 | + return $field; |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + /** |
|
| 836 | + * Retrieves a field from the object by Position as specified in the xml schema. |
|
| 837 | + * Zero-based. |
|
| 838 | + * |
|
| 839 | + * @param int $pos position in xml schema |
|
| 840 | + * @return mixed Value of field at $pos |
|
| 841 | + */ |
|
| 842 | + public function getByPosition($pos) |
|
| 843 | + { |
|
| 844 | + switch ($pos) { |
|
| 845 | + case 0: |
|
| 846 | + return $this->getId(); |
|
| 847 | + break; |
|
| 848 | + case 1: |
|
| 849 | + return $this->getInstanceName(); |
|
| 850 | + break; |
|
| 851 | + case 2: |
|
| 852 | + return $this->getName(); |
|
| 853 | + break; |
|
| 854 | + default: |
|
| 855 | + return null; |
|
| 856 | + break; |
|
| 857 | + } // switch() |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + /** |
|
| 861 | + * Exports the object as an array. |
|
| 862 | + * |
|
| 863 | + * You can specify the key type of the array by passing one of the class |
|
| 864 | + * type constants. |
|
| 865 | + * |
|
| 866 | + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 867 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 868 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 869 | + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
|
| 870 | + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
|
| 871 | + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
|
| 872 | + * |
|
| 873 | + * @return array an associative array containing the field names (as keys) and field values |
|
| 874 | + */ |
|
| 875 | + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
|
| 876 | + { |
|
| 877 | + |
|
| 878 | + if (isset($alreadyDumpedObjects['User'][$this->hashCode()])) { |
|
| 879 | + return '*RECURSION*'; |
|
| 880 | + } |
|
| 881 | + $alreadyDumpedObjects['User'][$this->hashCode()] = true; |
|
| 882 | + $keys = UserTableMap::getFieldNames($keyType); |
|
| 883 | + $result = array( |
|
| 884 | + $keys[0] => $this->getId(), |
|
| 885 | + $keys[1] => $this->getInstanceName(), |
|
| 886 | + $keys[2] => $this->getName(), |
|
| 887 | + ); |
|
| 888 | + $virtualColumns = $this->virtualColumns; |
|
| 889 | + foreach ($virtualColumns as $key => $virtualColumn) { |
|
| 890 | + $result[$key] = $virtualColumn; |
|
| 891 | + } |
|
| 892 | + |
|
| 893 | + if ($includeForeignObjects) { |
|
| 894 | + if (null !== $this->aInstance) { |
|
| 895 | + |
|
| 896 | + switch ($keyType) { |
|
| 897 | + case TableMap::TYPE_CAMELNAME: |
|
| 898 | + $key = 'instance'; |
|
| 899 | + break; |
|
| 900 | + case TableMap::TYPE_FIELDNAME: |
|
| 901 | + $key = 'instance'; |
|
| 902 | + break; |
|
| 903 | + default: |
|
| 904 | + $key = 'Instance'; |
|
| 905 | + } |
|
| 906 | + |
|
| 907 | + $result[$key] = $this->aInstance->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); |
|
| 908 | + } |
|
| 909 | + if (null !== $this->collConnections) { |
|
| 910 | + |
|
| 911 | + switch ($keyType) { |
|
| 912 | + case TableMap::TYPE_CAMELNAME: |
|
| 913 | + $key = 'connections'; |
|
| 914 | + break; |
|
| 915 | + case TableMap::TYPE_FIELDNAME: |
|
| 916 | + $key = 'connections'; |
|
| 917 | + break; |
|
| 918 | + default: |
|
| 919 | + $key = 'Connections'; |
|
| 920 | + } |
|
| 921 | + |
|
| 922 | + $result[$key] = $this->collConnections->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 923 | + } |
|
| 924 | + if (null !== $this->collSubscriptions) { |
|
| 925 | + |
|
| 926 | + switch ($keyType) { |
|
| 927 | + case TableMap::TYPE_CAMELNAME: |
|
| 928 | + $key = 'subscriptions'; |
|
| 929 | + break; |
|
| 930 | + case TableMap::TYPE_FIELDNAME: |
|
| 931 | + $key = 'subscriptions'; |
|
| 932 | + break; |
|
| 933 | + default: |
|
| 934 | + $key = 'Subscriptions'; |
|
| 935 | + } |
|
| 936 | + |
|
| 937 | + $result[$key] = $this->collSubscriptions->toArray(null, false, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); |
|
| 938 | + } |
|
| 939 | + } |
|
| 940 | + |
|
| 941 | + return $result; |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + /** |
|
| 945 | + * Sets a field from the object by name passed in as a string. |
|
| 946 | + * |
|
| 947 | + * @param string $name |
|
| 948 | + * @param mixed $value field value |
|
| 949 | + * @param string $type The type of fieldname the $name is of: |
|
| 950 | + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
|
| 951 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 952 | + * Defaults to TableMap::TYPE_PHPNAME. |
|
| 953 | + * @return $this|\Jalle19\StatusManager\Database\User |
|
| 954 | + */ |
|
| 955 | + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
|
| 956 | + { |
|
| 957 | + $pos = UserTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); |
|
| 958 | + |
|
| 959 | + return $this->setByPosition($pos, $value); |
|
| 960 | + } |
|
| 961 | + |
|
| 962 | + /** |
|
| 963 | + * Sets a field from the object by Position as specified in the xml schema. |
|
| 964 | + * Zero-based. |
|
| 965 | + * |
|
| 966 | + * @param int $pos position in xml schema |
|
| 967 | + * @param mixed $value field value |
|
| 968 | + * @return $this|\Jalle19\StatusManager\Database\User |
|
| 969 | + */ |
|
| 970 | + public function setByPosition($pos, $value) |
|
| 971 | + { |
|
| 972 | + switch ($pos) { |
|
| 973 | + case 0: |
|
| 974 | + $this->setId($value); |
|
| 975 | + break; |
|
| 976 | + case 1: |
|
| 977 | + $this->setInstanceName($value); |
|
| 978 | + break; |
|
| 979 | + case 2: |
|
| 980 | + $this->setName($value); |
|
| 981 | + break; |
|
| 982 | + } // switch() |
|
| 983 | + |
|
| 984 | + return $this; |
|
| 985 | + } |
|
| 986 | + |
|
| 987 | + /** |
|
| 988 | + * Populates the object using an array. |
|
| 989 | + * |
|
| 990 | + * This is particularly useful when populating an object from one of the |
|
| 991 | + * request arrays (e.g. $_POST). This method goes through the column |
|
| 992 | + * names, checking to see whether a matching key exists in populated |
|
| 993 | + * array. If so the setByName() method is called for that column. |
|
| 994 | + * |
|
| 995 | + * You can specify the key type of the array by additionally passing one |
|
| 996 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 997 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 998 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 999 | + * |
|
| 1000 | + * @param array $arr An array to populate the object from. |
|
| 1001 | + * @param string $keyType The type of keys the array uses. |
|
| 1002 | + * @return void |
|
| 1003 | + */ |
|
| 1004 | + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1005 | + { |
|
| 1006 | + $keys = UserTableMap::getFieldNames($keyType); |
|
| 1007 | + |
|
| 1008 | + if (array_key_exists($keys[0], $arr)) { |
|
| 1009 | + $this->setId($arr[$keys[0]]); |
|
| 1010 | + } |
|
| 1011 | + if (array_key_exists($keys[1], $arr)) { |
|
| 1012 | + $this->setInstanceName($arr[$keys[1]]); |
|
| 1013 | + } |
|
| 1014 | + if (array_key_exists($keys[2], $arr)) { |
|
| 1015 | + $this->setName($arr[$keys[2]]); |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + |
|
| 1019 | + /** |
|
| 1020 | + * Populate the current object from a string, using a given parser format |
|
| 1021 | + * <code> |
|
| 1022 | + * $book = new Book(); |
|
| 1023 | + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
|
| 1024 | + * </code> |
|
| 1025 | + * |
|
| 1026 | + * You can specify the key type of the array by additionally passing one |
|
| 1027 | + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
|
| 1028 | + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
|
| 1029 | + * The default key type is the column's TableMap::TYPE_PHPNAME. |
|
| 1030 | + * |
|
| 1031 | + * @param mixed $parser A AbstractParser instance, |
|
| 1032 | + * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
|
| 1033 | + * @param string $data The source data to import from |
|
| 1034 | + * @param string $keyType The type of keys the array uses. |
|
| 1035 | + * |
|
| 1036 | + * @return $this|\Jalle19\StatusManager\Database\User The current object, for fluid interface |
|
| 1037 | + */ |
|
| 1038 | + public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1039 | + { |
|
| 1040 | + if (!$parser instanceof AbstractParser) { |
|
| 1041 | + $parser = AbstractParser::getParser($parser); |
|
| 1042 | + } |
|
| 1043 | + |
|
| 1044 | + $this->fromArray($parser->toArray($data), $keyType); |
|
| 1045 | + |
|
| 1046 | + return $this; |
|
| 1047 | + } |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * Build a Criteria object containing the values of all modified columns in this object. |
|
| 1051 | + * |
|
| 1052 | + * @return Criteria The Criteria object containing all modified values. |
|
| 1053 | + */ |
|
| 1054 | + public function buildCriteria() |
|
| 1055 | + { |
|
| 1056 | + $criteria = new Criteria(UserTableMap::DATABASE_NAME); |
|
| 1057 | + |
|
| 1058 | + if ($this->isColumnModified(UserTableMap::COL_ID)) { |
|
| 1059 | + $criteria->add(UserTableMap::COL_ID, $this->id); |
|
| 1060 | + } |
|
| 1061 | + if ($this->isColumnModified(UserTableMap::COL_INSTANCE_NAME)) { |
|
| 1062 | + $criteria->add(UserTableMap::COL_INSTANCE_NAME, $this->instance_name); |
|
| 1063 | + } |
|
| 1064 | + if ($this->isColumnModified(UserTableMap::COL_NAME)) { |
|
| 1065 | + $criteria->add(UserTableMap::COL_NAME, $this->name); |
|
| 1066 | + } |
|
| 1067 | + |
|
| 1068 | + return $criteria; |
|
| 1069 | + } |
|
| 1070 | + |
|
| 1071 | + /** |
|
| 1072 | + * Builds a Criteria object containing the primary key for this object. |
|
| 1073 | + * |
|
| 1074 | + * Unlike buildCriteria() this method includes the primary key values regardless |
|
| 1075 | + * of whether or not they have been modified. |
|
| 1076 | + * |
|
| 1077 | + * @throws LogicException if no primary key is defined |
|
| 1078 | + * |
|
| 1079 | + * @return Criteria The Criteria object containing value(s) for primary key(s). |
|
| 1080 | + */ |
|
| 1081 | + public function buildPkeyCriteria() |
|
| 1082 | + { |
|
| 1083 | + $criteria = ChildUserQuery::create(); |
|
| 1084 | + $criteria->add(UserTableMap::COL_ID, $this->id); |
|
| 1085 | + |
|
| 1086 | + return $criteria; |
|
| 1087 | + } |
|
| 1088 | + |
|
| 1089 | + /** |
|
| 1090 | + * If the primary key is not null, return the hashcode of the |
|
| 1091 | + * primary key. Otherwise, return the hash code of the object. |
|
| 1092 | + * |
|
| 1093 | + * @return int Hashcode |
|
| 1094 | + */ |
|
| 1095 | + public function hashCode() |
|
| 1096 | + { |
|
| 1097 | + $validPk = null !== $this->getId(); |
|
| 1098 | + |
|
| 1099 | + $validPrimaryKeyFKs = 0; |
|
| 1100 | + $primaryKeyFKs = []; |
|
| 1101 | + |
|
| 1102 | + if ($validPk) { |
|
| 1103 | + return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE)); |
|
| 1104 | + } elseif ($validPrimaryKeyFKs) { |
|
| 1105 | + return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE)); |
|
| 1106 | + } |
|
| 1107 | + |
|
| 1108 | + return spl_object_hash($this); |
|
| 1109 | + } |
|
| 1110 | + |
|
| 1111 | + /** |
|
| 1112 | + * Returns the primary key for this object (row). |
|
| 1113 | + * @return int |
|
| 1114 | + */ |
|
| 1115 | + public function getPrimaryKey() |
|
| 1116 | + { |
|
| 1117 | + return $this->getId(); |
|
| 1118 | + } |
|
| 1119 | + |
|
| 1120 | + /** |
|
| 1121 | + * Generic method to set the primary key (id column). |
|
| 1122 | + * |
|
| 1123 | + * @param int $key Primary key. |
|
| 1124 | + * @return void |
|
| 1125 | + */ |
|
| 1126 | + public function setPrimaryKey($key) |
|
| 1127 | + { |
|
| 1128 | + $this->setId($key); |
|
| 1129 | + } |
|
| 1130 | + |
|
| 1131 | + /** |
|
| 1132 | + * Returns true if the primary key for this object is null. |
|
| 1133 | + * @return boolean |
|
| 1134 | + */ |
|
| 1135 | + public function isPrimaryKeyNull() |
|
| 1136 | + { |
|
| 1137 | + return null === $this->getId(); |
|
| 1138 | + } |
|
| 1139 | + |
|
| 1140 | + /** |
|
| 1141 | + * Sets contents of passed object to values from current object. |
|
| 1142 | + * |
|
| 1143 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1144 | + * objects. |
|
| 1145 | + * |
|
| 1146 | + * @param object $copyObj An object of \Jalle19\StatusManager\Database\User (or compatible) type. |
|
| 1147 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1148 | + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
|
| 1149 | + * @throws PropelException |
|
| 1150 | + */ |
|
| 1151 | + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
|
| 1152 | + { |
|
| 1153 | + $copyObj->setInstanceName($this->getInstanceName()); |
|
| 1154 | + $copyObj->setName($this->getName()); |
|
| 1155 | + |
|
| 1156 | + if ($deepCopy) { |
|
| 1157 | + // important: temporarily setNew(false) because this affects the behavior of |
|
| 1158 | + // the getter/setter methods for fkey referrer objects. |
|
| 1159 | + $copyObj->setNew(false); |
|
| 1160 | + |
|
| 1161 | + foreach ($this->getConnections() as $relObj) { |
|
| 1162 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1163 | + $copyObj->addConnection($relObj->copy($deepCopy)); |
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1166 | + |
|
| 1167 | + foreach ($this->getSubscriptions() as $relObj) { |
|
| 1168 | + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves |
|
| 1169 | + $copyObj->addSubscription($relObj->copy($deepCopy)); |
|
| 1170 | + } |
|
| 1171 | + } |
|
| 1172 | + |
|
| 1173 | + } // if ($deepCopy) |
|
| 1174 | + |
|
| 1175 | + if ($makeNew) { |
|
| 1176 | + $copyObj->setNew(true); |
|
| 1177 | + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value |
|
| 1178 | + } |
|
| 1179 | + } |
|
| 1180 | + |
|
| 1181 | + /** |
|
| 1182 | + * Makes a copy of this object that will be inserted as a new row in table when saved. |
|
| 1183 | + * It creates a new object filling in the simple attributes, but skipping any primary |
|
| 1184 | + * keys that are defined for the table. |
|
| 1185 | + * |
|
| 1186 | + * If desired, this method can also make copies of all associated (fkey referrers) |
|
| 1187 | + * objects. |
|
| 1188 | + * |
|
| 1189 | + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|
| 1190 | + * @return \Jalle19\StatusManager\Database\User Clone of current object. |
|
| 1191 | + * @throws PropelException |
|
| 1192 | + */ |
|
| 1193 | + public function copy($deepCopy = false) |
|
| 1194 | + { |
|
| 1195 | + // we use get_class(), because this might be a subclass |
|
| 1196 | + $clazz = get_class($this); |
|
| 1197 | + $copyObj = new $clazz(); |
|
| 1198 | + $this->copyInto($copyObj, $deepCopy); |
|
| 1199 | + |
|
| 1200 | + return $copyObj; |
|
| 1201 | + } |
|
| 1202 | + |
|
| 1203 | + /** |
|
| 1204 | + * Declares an association between this object and a ChildInstance object. |
|
| 1205 | + * |
|
| 1206 | + * @param ChildInstance $v |
|
| 1207 | + * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 1208 | + * @throws PropelException |
|
| 1209 | + */ |
|
| 1210 | + public function setInstance(ChildInstance $v = null) |
|
| 1211 | + { |
|
| 1212 | + if ($v === null) { |
|
| 1213 | + $this->setInstanceName(NULL); |
|
| 1214 | + } else { |
|
| 1215 | + $this->setInstanceName($v->getName()); |
|
| 1216 | + } |
|
| 1217 | + |
|
| 1218 | + $this->aInstance = $v; |
|
| 1219 | + |
|
| 1220 | + // Add binding for other direction of this n:n relationship. |
|
| 1221 | + // If this object has already been added to the ChildInstance object, it will not be re-added. |
|
| 1222 | + if ($v !== null) { |
|
| 1223 | + $v->addUser($this); |
|
| 1224 | + } |
|
| 1225 | + |
|
| 1226 | + |
|
| 1227 | + return $this; |
|
| 1228 | + } |
|
| 1229 | + |
|
| 1230 | + |
|
| 1231 | + /** |
|
| 1232 | + * Get the associated ChildInstance object |
|
| 1233 | + * |
|
| 1234 | + * @param ConnectionInterface $con Optional Connection object. |
|
| 1235 | + * @return ChildInstance The associated ChildInstance object. |
|
| 1236 | + * @throws PropelException |
|
| 1237 | + */ |
|
| 1238 | + public function getInstance(ConnectionInterface $con = null) |
|
| 1239 | + { |
|
| 1240 | + if ($this->aInstance === null && (($this->instance_name !== "" && $this->instance_name !== null))) { |
|
| 1241 | + $this->aInstance = ChildInstanceQuery::create()->findPk($this->instance_name, $con); |
|
| 1242 | + /* The following can be used additionally to |
|
| 1243 | 1243 | guarantee the related object contains a reference |
| 1244 | 1244 | to this object. This level of coupling may, however, be |
| 1245 | 1245 | undesirable since it could result in an only partially populated collection |
| 1246 | 1246 | in the referenced object. |
| 1247 | 1247 | $this->aInstance->addUsers($this); |
| 1248 | 1248 | */ |
| 1249 | - } |
|
| 1250 | - |
|
| 1251 | - return $this->aInstance; |
|
| 1252 | - } |
|
| 1253 | - |
|
| 1254 | - |
|
| 1255 | - /** |
|
| 1256 | - * Initializes a collection based on the name of a relation. |
|
| 1257 | - * Avoids crafting an 'init[$relationName]s' method name |
|
| 1258 | - * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1259 | - * |
|
| 1260 | - * @param string $relationName The name of the relation to initialize |
|
| 1261 | - * @return void |
|
| 1262 | - */ |
|
| 1263 | - public function initRelation($relationName) |
|
| 1264 | - { |
|
| 1265 | - if ('Connection' == $relationName) { |
|
| 1266 | - return $this->initConnections(); |
|
| 1267 | - } |
|
| 1268 | - if ('Subscription' == $relationName) { |
|
| 1269 | - return $this->initSubscriptions(); |
|
| 1270 | - } |
|
| 1271 | - } |
|
| 1272 | - |
|
| 1273 | - /** |
|
| 1274 | - * Clears out the collConnections collection |
|
| 1275 | - * |
|
| 1276 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1277 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1278 | - * |
|
| 1279 | - * @return void |
|
| 1280 | - * @see addConnections() |
|
| 1281 | - */ |
|
| 1282 | - public function clearConnections() |
|
| 1283 | - { |
|
| 1284 | - $this->collConnections = null; // important to set this to NULL since that means it is uninitialized |
|
| 1285 | - } |
|
| 1286 | - |
|
| 1287 | - /** |
|
| 1288 | - * Reset is the collConnections collection loaded partially. |
|
| 1289 | - */ |
|
| 1290 | - public function resetPartialConnections($v = true) |
|
| 1291 | - { |
|
| 1292 | - $this->collConnectionsPartial = $v; |
|
| 1293 | - } |
|
| 1294 | - |
|
| 1295 | - /** |
|
| 1296 | - * Initializes the collConnections collection. |
|
| 1297 | - * |
|
| 1298 | - * By default this just sets the collConnections collection to an empty array (like clearcollConnections()); |
|
| 1299 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1300 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1301 | - * |
|
| 1302 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1303 | - * the collection even if it is not empty |
|
| 1304 | - * |
|
| 1305 | - * @return void |
|
| 1306 | - */ |
|
| 1307 | - public function initConnections($overrideExisting = true) |
|
| 1308 | - { |
|
| 1309 | - if (null !== $this->collConnections && !$overrideExisting) { |
|
| 1310 | - return; |
|
| 1311 | - } |
|
| 1312 | - |
|
| 1313 | - $collectionClassName = ConnectionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1314 | - |
|
| 1315 | - $this->collConnections = new $collectionClassName; |
|
| 1316 | - $this->collConnections->setModel('\Jalle19\StatusManager\Database\Connection'); |
|
| 1317 | - } |
|
| 1318 | - |
|
| 1319 | - /** |
|
| 1320 | - * Gets an array of ChildConnection objects which contain a foreign key that references this object. |
|
| 1321 | - * |
|
| 1322 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1323 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1324 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1325 | - * If this ChildUser is new, it will return |
|
| 1326 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1327 | - * |
|
| 1328 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1329 | - * @param ConnectionInterface $con optional connection object |
|
| 1330 | - * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1331 | - * @throws PropelException |
|
| 1332 | - */ |
|
| 1333 | - public function getConnections(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1334 | - { |
|
| 1335 | - $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1336 | - if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1337 | - if ($this->isNew() && null === $this->collConnections) { |
|
| 1338 | - // return empty collection |
|
| 1339 | - $this->initConnections(); |
|
| 1340 | - } else { |
|
| 1341 | - $collConnections = ChildConnectionQuery::create(null, $criteria) |
|
| 1342 | - ->filterByUser($this) |
|
| 1343 | - ->find($con); |
|
| 1344 | - |
|
| 1345 | - if (null !== $criteria) { |
|
| 1346 | - if (false !== $this->collConnectionsPartial && count($collConnections)) { |
|
| 1347 | - $this->initConnections(false); |
|
| 1348 | - |
|
| 1349 | - foreach ($collConnections as $obj) { |
|
| 1350 | - if (false == $this->collConnections->contains($obj)) { |
|
| 1351 | - $this->collConnections->append($obj); |
|
| 1352 | - } |
|
| 1353 | - } |
|
| 1354 | - |
|
| 1355 | - $this->collConnectionsPartial = true; |
|
| 1356 | - } |
|
| 1357 | - |
|
| 1358 | - return $collConnections; |
|
| 1359 | - } |
|
| 1360 | - |
|
| 1361 | - if ($partial && $this->collConnections) { |
|
| 1362 | - foreach ($this->collConnections as $obj) { |
|
| 1363 | - if ($obj->isNew()) { |
|
| 1364 | - $collConnections[] = $obj; |
|
| 1365 | - } |
|
| 1366 | - } |
|
| 1367 | - } |
|
| 1368 | - |
|
| 1369 | - $this->collConnections = $collConnections; |
|
| 1370 | - $this->collConnectionsPartial = false; |
|
| 1371 | - } |
|
| 1372 | - } |
|
| 1373 | - |
|
| 1374 | - return $this->collConnections; |
|
| 1375 | - } |
|
| 1376 | - |
|
| 1377 | - /** |
|
| 1378 | - * Sets a collection of ChildConnection objects related by a one-to-many relationship |
|
| 1379 | - * to the current object. |
|
| 1380 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1381 | - * and new objects from the given Propel collection. |
|
| 1382 | - * |
|
| 1383 | - * @param Collection $connections A Propel collection. |
|
| 1384 | - * @param ConnectionInterface $con Optional connection object |
|
| 1385 | - * @return $this|ChildUser The current object (for fluent API support) |
|
| 1386 | - */ |
|
| 1387 | - public function setConnections(Collection $connections, ConnectionInterface $con = null) |
|
| 1388 | - { |
|
| 1389 | - /** @var ChildConnection[] $connectionsToDelete */ |
|
| 1390 | - $connectionsToDelete = $this->getConnections(new Criteria(), $con)->diff($connections); |
|
| 1391 | - |
|
| 1392 | - |
|
| 1393 | - $this->connectionsScheduledForDeletion = $connectionsToDelete; |
|
| 1394 | - |
|
| 1395 | - foreach ($connectionsToDelete as $connectionRemoved) { |
|
| 1396 | - $connectionRemoved->setUser(null); |
|
| 1397 | - } |
|
| 1398 | - |
|
| 1399 | - $this->collConnections = null; |
|
| 1400 | - foreach ($connections as $connection) { |
|
| 1401 | - $this->addConnection($connection); |
|
| 1402 | - } |
|
| 1403 | - |
|
| 1404 | - $this->collConnections = $connections; |
|
| 1405 | - $this->collConnectionsPartial = false; |
|
| 1406 | - |
|
| 1407 | - return $this; |
|
| 1408 | - } |
|
| 1409 | - |
|
| 1410 | - /** |
|
| 1411 | - * Returns the number of related Connection objects. |
|
| 1412 | - * |
|
| 1413 | - * @param Criteria $criteria |
|
| 1414 | - * @param boolean $distinct |
|
| 1415 | - * @param ConnectionInterface $con |
|
| 1416 | - * @return int Count of related Connection objects. |
|
| 1417 | - * @throws PropelException |
|
| 1418 | - */ |
|
| 1419 | - public function countConnections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1420 | - { |
|
| 1421 | - $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1422 | - if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1423 | - if ($this->isNew() && null === $this->collConnections) { |
|
| 1424 | - return 0; |
|
| 1425 | - } |
|
| 1426 | - |
|
| 1427 | - if ($partial && !$criteria) { |
|
| 1428 | - return count($this->getConnections()); |
|
| 1429 | - } |
|
| 1430 | - |
|
| 1431 | - $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1432 | - if ($distinct) { |
|
| 1433 | - $query->distinct(); |
|
| 1434 | - } |
|
| 1435 | - |
|
| 1436 | - return $query |
|
| 1437 | - ->filterByUser($this) |
|
| 1438 | - ->count($con); |
|
| 1439 | - } |
|
| 1440 | - |
|
| 1441 | - return count($this->collConnections); |
|
| 1442 | - } |
|
| 1443 | - |
|
| 1444 | - /** |
|
| 1445 | - * Method called to associate a ChildConnection object to this object |
|
| 1446 | - * through the ChildConnection foreign key attribute. |
|
| 1447 | - * |
|
| 1448 | - * @param ChildConnection $l ChildConnection |
|
| 1449 | - * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 1450 | - */ |
|
| 1451 | - public function addConnection(ChildConnection $l) |
|
| 1452 | - { |
|
| 1453 | - if ($this->collConnections === null) { |
|
| 1454 | - $this->initConnections(); |
|
| 1455 | - $this->collConnectionsPartial = true; |
|
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - if (!$this->collConnections->contains($l)) { |
|
| 1459 | - $this->doAddConnection($l); |
|
| 1460 | - |
|
| 1461 | - if ($this->connectionsScheduledForDeletion and $this->connectionsScheduledForDeletion->contains($l)) { |
|
| 1462 | - $this->connectionsScheduledForDeletion->remove($this->connectionsScheduledForDeletion->search($l)); |
|
| 1463 | - } |
|
| 1464 | - } |
|
| 1465 | - |
|
| 1466 | - return $this; |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - /** |
|
| 1470 | - * @param ChildConnection $connection The ChildConnection object to add. |
|
| 1471 | - */ |
|
| 1472 | - protected function doAddConnection(ChildConnection $connection) |
|
| 1473 | - { |
|
| 1474 | - $this->collConnections[]= $connection; |
|
| 1475 | - $connection->setUser($this); |
|
| 1476 | - } |
|
| 1477 | - |
|
| 1478 | - /** |
|
| 1479 | - * @param ChildConnection $connection The ChildConnection object to remove. |
|
| 1480 | - * @return $this|ChildUser The current object (for fluent API support) |
|
| 1481 | - */ |
|
| 1482 | - public function removeConnection(ChildConnection $connection) |
|
| 1483 | - { |
|
| 1484 | - if ($this->getConnections()->contains($connection)) { |
|
| 1485 | - $pos = $this->collConnections->search($connection); |
|
| 1486 | - $this->collConnections->remove($pos); |
|
| 1487 | - if (null === $this->connectionsScheduledForDeletion) { |
|
| 1488 | - $this->connectionsScheduledForDeletion = clone $this->collConnections; |
|
| 1489 | - $this->connectionsScheduledForDeletion->clear(); |
|
| 1490 | - } |
|
| 1491 | - $this->connectionsScheduledForDeletion[]= $connection; |
|
| 1492 | - $connection->setUser(null); |
|
| 1493 | - } |
|
| 1494 | - |
|
| 1495 | - return $this; |
|
| 1496 | - } |
|
| 1497 | - |
|
| 1498 | - |
|
| 1499 | - /** |
|
| 1500 | - * If this collection has already been initialized with |
|
| 1501 | - * an identical criteria, it returns the collection. |
|
| 1502 | - * Otherwise if this User is new, it will return |
|
| 1503 | - * an empty collection; or if this User has previously |
|
| 1504 | - * been saved, it will retrieve related Connections from storage. |
|
| 1505 | - * |
|
| 1506 | - * This method is protected by default in order to keep the public |
|
| 1507 | - * api reasonable. You can provide public methods for those you |
|
| 1508 | - * actually need in User. |
|
| 1509 | - * |
|
| 1510 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1511 | - * @param ConnectionInterface $con optional connection object |
|
| 1512 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1513 | - * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1514 | - */ |
|
| 1515 | - public function getConnectionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1516 | - { |
|
| 1517 | - $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1518 | - $query->joinWith('Instance', $joinBehavior); |
|
| 1519 | - |
|
| 1520 | - return $this->getConnections($query, $con); |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - /** |
|
| 1524 | - * Clears out the collSubscriptions collection |
|
| 1525 | - * |
|
| 1526 | - * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1527 | - * them to be refetched by subsequent calls to accessor method. |
|
| 1528 | - * |
|
| 1529 | - * @return void |
|
| 1530 | - * @see addSubscriptions() |
|
| 1531 | - */ |
|
| 1532 | - public function clearSubscriptions() |
|
| 1533 | - { |
|
| 1534 | - $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - /** |
|
| 1538 | - * Reset is the collSubscriptions collection loaded partially. |
|
| 1539 | - */ |
|
| 1540 | - public function resetPartialSubscriptions($v = true) |
|
| 1541 | - { |
|
| 1542 | - $this->collSubscriptionsPartial = $v; |
|
| 1543 | - } |
|
| 1544 | - |
|
| 1545 | - /** |
|
| 1546 | - * Initializes the collSubscriptions collection. |
|
| 1547 | - * |
|
| 1548 | - * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 1549 | - * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1550 | - * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1551 | - * |
|
| 1552 | - * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1553 | - * the collection even if it is not empty |
|
| 1554 | - * |
|
| 1555 | - * @return void |
|
| 1556 | - */ |
|
| 1557 | - public function initSubscriptions($overrideExisting = true) |
|
| 1558 | - { |
|
| 1559 | - if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 1560 | - return; |
|
| 1561 | - } |
|
| 1562 | - |
|
| 1563 | - $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1564 | - |
|
| 1565 | - $this->collSubscriptions = new $collectionClassName; |
|
| 1566 | - $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 1567 | - } |
|
| 1568 | - |
|
| 1569 | - /** |
|
| 1570 | - * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 1571 | - * |
|
| 1572 | - * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1573 | - * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1574 | - * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1575 | - * If this ChildUser is new, it will return |
|
| 1576 | - * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1577 | - * |
|
| 1578 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1579 | - * @param ConnectionInterface $con optional connection object |
|
| 1580 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1581 | - * @throws PropelException |
|
| 1582 | - */ |
|
| 1583 | - public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1584 | - { |
|
| 1585 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1586 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1587 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1588 | - // return empty collection |
|
| 1589 | - $this->initSubscriptions(); |
|
| 1590 | - } else { |
|
| 1591 | - $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 1592 | - ->filterByUser($this) |
|
| 1593 | - ->find($con); |
|
| 1594 | - |
|
| 1595 | - if (null !== $criteria) { |
|
| 1596 | - if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 1597 | - $this->initSubscriptions(false); |
|
| 1598 | - |
|
| 1599 | - foreach ($collSubscriptions as $obj) { |
|
| 1600 | - if (false == $this->collSubscriptions->contains($obj)) { |
|
| 1601 | - $this->collSubscriptions->append($obj); |
|
| 1602 | - } |
|
| 1603 | - } |
|
| 1604 | - |
|
| 1605 | - $this->collSubscriptionsPartial = true; |
|
| 1606 | - } |
|
| 1607 | - |
|
| 1608 | - return $collSubscriptions; |
|
| 1609 | - } |
|
| 1610 | - |
|
| 1611 | - if ($partial && $this->collSubscriptions) { |
|
| 1612 | - foreach ($this->collSubscriptions as $obj) { |
|
| 1613 | - if ($obj->isNew()) { |
|
| 1614 | - $collSubscriptions[] = $obj; |
|
| 1615 | - } |
|
| 1616 | - } |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - $this->collSubscriptions = $collSubscriptions; |
|
| 1620 | - $this->collSubscriptionsPartial = false; |
|
| 1621 | - } |
|
| 1622 | - } |
|
| 1623 | - |
|
| 1624 | - return $this->collSubscriptions; |
|
| 1625 | - } |
|
| 1626 | - |
|
| 1627 | - /** |
|
| 1628 | - * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 1629 | - * to the current object. |
|
| 1630 | - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1631 | - * and new objects from the given Propel collection. |
|
| 1632 | - * |
|
| 1633 | - * @param Collection $subscriptions A Propel collection. |
|
| 1634 | - * @param ConnectionInterface $con Optional connection object |
|
| 1635 | - * @return $this|ChildUser The current object (for fluent API support) |
|
| 1636 | - */ |
|
| 1637 | - public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1638 | - { |
|
| 1639 | - /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 1640 | - $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 1641 | - |
|
| 1642 | - |
|
| 1643 | - $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 1644 | - |
|
| 1645 | - foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 1646 | - $subscriptionRemoved->setUser(null); |
|
| 1647 | - } |
|
| 1648 | - |
|
| 1649 | - $this->collSubscriptions = null; |
|
| 1650 | - foreach ($subscriptions as $subscription) { |
|
| 1651 | - $this->addSubscription($subscription); |
|
| 1652 | - } |
|
| 1653 | - |
|
| 1654 | - $this->collSubscriptions = $subscriptions; |
|
| 1655 | - $this->collSubscriptionsPartial = false; |
|
| 1656 | - |
|
| 1657 | - return $this; |
|
| 1658 | - } |
|
| 1659 | - |
|
| 1660 | - /** |
|
| 1661 | - * Returns the number of related Subscription objects. |
|
| 1662 | - * |
|
| 1663 | - * @param Criteria $criteria |
|
| 1664 | - * @param boolean $distinct |
|
| 1665 | - * @param ConnectionInterface $con |
|
| 1666 | - * @return int Count of related Subscription objects. |
|
| 1667 | - * @throws PropelException |
|
| 1668 | - */ |
|
| 1669 | - public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1670 | - { |
|
| 1671 | - $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1672 | - if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1673 | - if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1674 | - return 0; |
|
| 1675 | - } |
|
| 1676 | - |
|
| 1677 | - if ($partial && !$criteria) { |
|
| 1678 | - return count($this->getSubscriptions()); |
|
| 1679 | - } |
|
| 1680 | - |
|
| 1681 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1682 | - if ($distinct) { |
|
| 1683 | - $query->distinct(); |
|
| 1684 | - } |
|
| 1685 | - |
|
| 1686 | - return $query |
|
| 1687 | - ->filterByUser($this) |
|
| 1688 | - ->count($con); |
|
| 1689 | - } |
|
| 1690 | - |
|
| 1691 | - return count($this->collSubscriptions); |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - /** |
|
| 1695 | - * Method called to associate a ChildSubscription object to this object |
|
| 1696 | - * through the ChildSubscription foreign key attribute. |
|
| 1697 | - * |
|
| 1698 | - * @param ChildSubscription $l ChildSubscription |
|
| 1699 | - * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 1700 | - */ |
|
| 1701 | - public function addSubscription(ChildSubscription $l) |
|
| 1702 | - { |
|
| 1703 | - if ($this->collSubscriptions === null) { |
|
| 1704 | - $this->initSubscriptions(); |
|
| 1705 | - $this->collSubscriptionsPartial = true; |
|
| 1706 | - } |
|
| 1707 | - |
|
| 1708 | - if (!$this->collSubscriptions->contains($l)) { |
|
| 1709 | - $this->doAddSubscription($l); |
|
| 1710 | - |
|
| 1711 | - if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 1712 | - $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 1713 | - } |
|
| 1714 | - } |
|
| 1715 | - |
|
| 1716 | - return $this; |
|
| 1717 | - } |
|
| 1718 | - |
|
| 1719 | - /** |
|
| 1720 | - * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 1721 | - */ |
|
| 1722 | - protected function doAddSubscription(ChildSubscription $subscription) |
|
| 1723 | - { |
|
| 1724 | - $this->collSubscriptions[]= $subscription; |
|
| 1725 | - $subscription->setUser($this); |
|
| 1726 | - } |
|
| 1727 | - |
|
| 1728 | - /** |
|
| 1729 | - * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 1730 | - * @return $this|ChildUser The current object (for fluent API support) |
|
| 1731 | - */ |
|
| 1732 | - public function removeSubscription(ChildSubscription $subscription) |
|
| 1733 | - { |
|
| 1734 | - if ($this->getSubscriptions()->contains($subscription)) { |
|
| 1735 | - $pos = $this->collSubscriptions->search($subscription); |
|
| 1736 | - $this->collSubscriptions->remove($pos); |
|
| 1737 | - if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 1738 | - $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 1739 | - $this->subscriptionsScheduledForDeletion->clear(); |
|
| 1740 | - } |
|
| 1741 | - $this->subscriptionsScheduledForDeletion[]= $subscription; |
|
| 1742 | - $subscription->setUser(null); |
|
| 1743 | - } |
|
| 1744 | - |
|
| 1745 | - return $this; |
|
| 1746 | - } |
|
| 1747 | - |
|
| 1748 | - |
|
| 1749 | - /** |
|
| 1750 | - * If this collection has already been initialized with |
|
| 1751 | - * an identical criteria, it returns the collection. |
|
| 1752 | - * Otherwise if this User is new, it will return |
|
| 1753 | - * an empty collection; or if this User has previously |
|
| 1754 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1755 | - * |
|
| 1756 | - * This method is protected by default in order to keep the public |
|
| 1757 | - * api reasonable. You can provide public methods for those you |
|
| 1758 | - * actually need in User. |
|
| 1759 | - * |
|
| 1760 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1761 | - * @param ConnectionInterface $con optional connection object |
|
| 1762 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1763 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1764 | - */ |
|
| 1765 | - public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1766 | - { |
|
| 1767 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1768 | - $query->joinWith('Instance', $joinBehavior); |
|
| 1769 | - |
|
| 1770 | - return $this->getSubscriptions($query, $con); |
|
| 1771 | - } |
|
| 1772 | - |
|
| 1773 | - |
|
| 1774 | - /** |
|
| 1775 | - * If this collection has already been initialized with |
|
| 1776 | - * an identical criteria, it returns the collection. |
|
| 1777 | - * Otherwise if this User is new, it will return |
|
| 1778 | - * an empty collection; or if this User has previously |
|
| 1779 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1780 | - * |
|
| 1781 | - * This method is protected by default in order to keep the public |
|
| 1782 | - * api reasonable. You can provide public methods for those you |
|
| 1783 | - * actually need in User. |
|
| 1784 | - * |
|
| 1785 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1786 | - * @param ConnectionInterface $con optional connection object |
|
| 1787 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1788 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1789 | - */ |
|
| 1790 | - public function getSubscriptionsJoinInput(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1791 | - { |
|
| 1792 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1793 | - $query->joinWith('Input', $joinBehavior); |
|
| 1794 | - |
|
| 1795 | - return $this->getSubscriptions($query, $con); |
|
| 1796 | - } |
|
| 1797 | - |
|
| 1798 | - |
|
| 1799 | - /** |
|
| 1800 | - * If this collection has already been initialized with |
|
| 1801 | - * an identical criteria, it returns the collection. |
|
| 1802 | - * Otherwise if this User is new, it will return |
|
| 1803 | - * an empty collection; or if this User has previously |
|
| 1804 | - * been saved, it will retrieve related Subscriptions from storage. |
|
| 1805 | - * |
|
| 1806 | - * This method is protected by default in order to keep the public |
|
| 1807 | - * api reasonable. You can provide public methods for those you |
|
| 1808 | - * actually need in User. |
|
| 1809 | - * |
|
| 1810 | - * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1811 | - * @param ConnectionInterface $con optional connection object |
|
| 1812 | - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1813 | - * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1814 | - */ |
|
| 1815 | - public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1816 | - { |
|
| 1817 | - $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1818 | - $query->joinWith('Channel', $joinBehavior); |
|
| 1819 | - |
|
| 1820 | - return $this->getSubscriptions($query, $con); |
|
| 1821 | - } |
|
| 1822 | - |
|
| 1823 | - /** |
|
| 1824 | - * Clears the current object, sets all attributes to their default values and removes |
|
| 1825 | - * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 1826 | - * change of those foreign objects when you call `save` there). |
|
| 1827 | - */ |
|
| 1828 | - public function clear() |
|
| 1829 | - { |
|
| 1830 | - if (null !== $this->aInstance) { |
|
| 1831 | - $this->aInstance->removeUser($this); |
|
| 1832 | - } |
|
| 1833 | - $this->id = null; |
|
| 1834 | - $this->instance_name = null; |
|
| 1835 | - $this->name = null; |
|
| 1836 | - $this->alreadyInSave = false; |
|
| 1837 | - $this->clearAllReferences(); |
|
| 1838 | - $this->resetModified(); |
|
| 1839 | - $this->setNew(true); |
|
| 1840 | - $this->setDeleted(false); |
|
| 1841 | - } |
|
| 1842 | - |
|
| 1843 | - /** |
|
| 1844 | - * Resets all references and back-references to other model objects or collections of model objects. |
|
| 1845 | - * |
|
| 1846 | - * This method is used to reset all php object references (not the actual reference in the database). |
|
| 1847 | - * Necessary for object serialisation. |
|
| 1848 | - * |
|
| 1849 | - * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 1850 | - */ |
|
| 1851 | - public function clearAllReferences($deep = false) |
|
| 1852 | - { |
|
| 1853 | - if ($deep) { |
|
| 1854 | - if ($this->collConnections) { |
|
| 1855 | - foreach ($this->collConnections as $o) { |
|
| 1856 | - $o->clearAllReferences($deep); |
|
| 1857 | - } |
|
| 1858 | - } |
|
| 1859 | - if ($this->collSubscriptions) { |
|
| 1860 | - foreach ($this->collSubscriptions as $o) { |
|
| 1861 | - $o->clearAllReferences($deep); |
|
| 1862 | - } |
|
| 1863 | - } |
|
| 1864 | - } // if ($deep) |
|
| 1865 | - |
|
| 1866 | - $this->collConnections = null; |
|
| 1867 | - $this->collSubscriptions = null; |
|
| 1868 | - $this->aInstance = null; |
|
| 1869 | - } |
|
| 1870 | - |
|
| 1871 | - /** |
|
| 1872 | - * Return the string representation of this object |
|
| 1873 | - * |
|
| 1874 | - * @return string |
|
| 1875 | - */ |
|
| 1876 | - public function __toString() |
|
| 1877 | - { |
|
| 1878 | - return (string) $this->exportTo(UserTableMap::DEFAULT_STRING_FORMAT); |
|
| 1879 | - } |
|
| 1880 | - |
|
| 1881 | - /** |
|
| 1882 | - * Code to be run before persisting the object |
|
| 1883 | - * @param ConnectionInterface $con |
|
| 1884 | - * @return boolean |
|
| 1885 | - */ |
|
| 1886 | - public function preSave(ConnectionInterface $con = null) |
|
| 1887 | - { |
|
| 1888 | - return true; |
|
| 1889 | - } |
|
| 1890 | - |
|
| 1891 | - /** |
|
| 1892 | - * Code to be run after persisting the object |
|
| 1893 | - * @param ConnectionInterface $con |
|
| 1894 | - */ |
|
| 1895 | - public function postSave(ConnectionInterface $con = null) |
|
| 1896 | - { |
|
| 1897 | - |
|
| 1898 | - } |
|
| 1899 | - |
|
| 1900 | - /** |
|
| 1901 | - * Code to be run before inserting to database |
|
| 1902 | - * @param ConnectionInterface $con |
|
| 1903 | - * @return boolean |
|
| 1904 | - */ |
|
| 1905 | - public function preInsert(ConnectionInterface $con = null) |
|
| 1906 | - { |
|
| 1907 | - return true; |
|
| 1908 | - } |
|
| 1909 | - |
|
| 1910 | - /** |
|
| 1911 | - * Code to be run after inserting to database |
|
| 1912 | - * @param ConnectionInterface $con |
|
| 1913 | - */ |
|
| 1914 | - public function postInsert(ConnectionInterface $con = null) |
|
| 1915 | - { |
|
| 1916 | - |
|
| 1917 | - } |
|
| 1918 | - |
|
| 1919 | - /** |
|
| 1920 | - * Code to be run before updating the object in database |
|
| 1921 | - * @param ConnectionInterface $con |
|
| 1922 | - * @return boolean |
|
| 1923 | - */ |
|
| 1924 | - public function preUpdate(ConnectionInterface $con = null) |
|
| 1925 | - { |
|
| 1926 | - return true; |
|
| 1927 | - } |
|
| 1928 | - |
|
| 1929 | - /** |
|
| 1930 | - * Code to be run after updating the object in database |
|
| 1931 | - * @param ConnectionInterface $con |
|
| 1932 | - */ |
|
| 1933 | - public function postUpdate(ConnectionInterface $con = null) |
|
| 1934 | - { |
|
| 1935 | - |
|
| 1936 | - } |
|
| 1937 | - |
|
| 1938 | - /** |
|
| 1939 | - * Code to be run before deleting the object in database |
|
| 1940 | - * @param ConnectionInterface $con |
|
| 1941 | - * @return boolean |
|
| 1942 | - */ |
|
| 1943 | - public function preDelete(ConnectionInterface $con = null) |
|
| 1944 | - { |
|
| 1945 | - return true; |
|
| 1946 | - } |
|
| 1947 | - |
|
| 1948 | - /** |
|
| 1949 | - * Code to be run after deleting the object in database |
|
| 1950 | - * @param ConnectionInterface $con |
|
| 1951 | - */ |
|
| 1952 | - public function postDelete(ConnectionInterface $con = null) |
|
| 1953 | - { |
|
| 1954 | - |
|
| 1955 | - } |
|
| 1956 | - |
|
| 1957 | - |
|
| 1958 | - /** |
|
| 1959 | - * Derived method to catches calls to undefined methods. |
|
| 1960 | - * |
|
| 1961 | - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 1962 | - * Allows to define default __call() behavior if you overwrite __call() |
|
| 1963 | - * |
|
| 1964 | - * @param string $name |
|
| 1965 | - * @param mixed $params |
|
| 1966 | - * |
|
| 1967 | - * @return array|string |
|
| 1968 | - */ |
|
| 1969 | - public function __call($name, $params) |
|
| 1970 | - { |
|
| 1971 | - if (0 === strpos($name, 'get')) { |
|
| 1972 | - $virtualColumn = substr($name, 3); |
|
| 1973 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1974 | - return $this->getVirtualColumn($virtualColumn); |
|
| 1975 | - } |
|
| 1976 | - |
|
| 1977 | - $virtualColumn = lcfirst($virtualColumn); |
|
| 1978 | - if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1979 | - return $this->getVirtualColumn($virtualColumn); |
|
| 1980 | - } |
|
| 1981 | - } |
|
| 1982 | - |
|
| 1983 | - if (0 === strpos($name, 'from')) { |
|
| 1984 | - $format = substr($name, 4); |
|
| 1985 | - |
|
| 1986 | - return $this->importFrom($format, reset($params)); |
|
| 1987 | - } |
|
| 1988 | - |
|
| 1989 | - if (0 === strpos($name, 'to')) { |
|
| 1990 | - $format = substr($name, 2); |
|
| 1991 | - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 1992 | - |
|
| 1993 | - return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 1994 | - } |
|
| 1995 | - |
|
| 1996 | - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 1997 | - } |
|
| 1249 | + } |
|
| 1250 | + |
|
| 1251 | + return $this->aInstance; |
|
| 1252 | + } |
|
| 1253 | + |
|
| 1254 | + |
|
| 1255 | + /** |
|
| 1256 | + * Initializes a collection based on the name of a relation. |
|
| 1257 | + * Avoids crafting an 'init[$relationName]s' method name |
|
| 1258 | + * that wouldn't work when StandardEnglishPluralizer is used. |
|
| 1259 | + * |
|
| 1260 | + * @param string $relationName The name of the relation to initialize |
|
| 1261 | + * @return void |
|
| 1262 | + */ |
|
| 1263 | + public function initRelation($relationName) |
|
| 1264 | + { |
|
| 1265 | + if ('Connection' == $relationName) { |
|
| 1266 | + return $this->initConnections(); |
|
| 1267 | + } |
|
| 1268 | + if ('Subscription' == $relationName) { |
|
| 1269 | + return $this->initSubscriptions(); |
|
| 1270 | + } |
|
| 1271 | + } |
|
| 1272 | + |
|
| 1273 | + /** |
|
| 1274 | + * Clears out the collConnections collection |
|
| 1275 | + * |
|
| 1276 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1277 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1278 | + * |
|
| 1279 | + * @return void |
|
| 1280 | + * @see addConnections() |
|
| 1281 | + */ |
|
| 1282 | + public function clearConnections() |
|
| 1283 | + { |
|
| 1284 | + $this->collConnections = null; // important to set this to NULL since that means it is uninitialized |
|
| 1285 | + } |
|
| 1286 | + |
|
| 1287 | + /** |
|
| 1288 | + * Reset is the collConnections collection loaded partially. |
|
| 1289 | + */ |
|
| 1290 | + public function resetPartialConnections($v = true) |
|
| 1291 | + { |
|
| 1292 | + $this->collConnectionsPartial = $v; |
|
| 1293 | + } |
|
| 1294 | + |
|
| 1295 | + /** |
|
| 1296 | + * Initializes the collConnections collection. |
|
| 1297 | + * |
|
| 1298 | + * By default this just sets the collConnections collection to an empty array (like clearcollConnections()); |
|
| 1299 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1300 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1301 | + * |
|
| 1302 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1303 | + * the collection even if it is not empty |
|
| 1304 | + * |
|
| 1305 | + * @return void |
|
| 1306 | + */ |
|
| 1307 | + public function initConnections($overrideExisting = true) |
|
| 1308 | + { |
|
| 1309 | + if (null !== $this->collConnections && !$overrideExisting) { |
|
| 1310 | + return; |
|
| 1311 | + } |
|
| 1312 | + |
|
| 1313 | + $collectionClassName = ConnectionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1314 | + |
|
| 1315 | + $this->collConnections = new $collectionClassName; |
|
| 1316 | + $this->collConnections->setModel('\Jalle19\StatusManager\Database\Connection'); |
|
| 1317 | + } |
|
| 1318 | + |
|
| 1319 | + /** |
|
| 1320 | + * Gets an array of ChildConnection objects which contain a foreign key that references this object. |
|
| 1321 | + * |
|
| 1322 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1323 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1324 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1325 | + * If this ChildUser is new, it will return |
|
| 1326 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1327 | + * |
|
| 1328 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1329 | + * @param ConnectionInterface $con optional connection object |
|
| 1330 | + * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1331 | + * @throws PropelException |
|
| 1332 | + */ |
|
| 1333 | + public function getConnections(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1334 | + { |
|
| 1335 | + $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1336 | + if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1337 | + if ($this->isNew() && null === $this->collConnections) { |
|
| 1338 | + // return empty collection |
|
| 1339 | + $this->initConnections(); |
|
| 1340 | + } else { |
|
| 1341 | + $collConnections = ChildConnectionQuery::create(null, $criteria) |
|
| 1342 | + ->filterByUser($this) |
|
| 1343 | + ->find($con); |
|
| 1344 | + |
|
| 1345 | + if (null !== $criteria) { |
|
| 1346 | + if (false !== $this->collConnectionsPartial && count($collConnections)) { |
|
| 1347 | + $this->initConnections(false); |
|
| 1348 | + |
|
| 1349 | + foreach ($collConnections as $obj) { |
|
| 1350 | + if (false == $this->collConnections->contains($obj)) { |
|
| 1351 | + $this->collConnections->append($obj); |
|
| 1352 | + } |
|
| 1353 | + } |
|
| 1354 | + |
|
| 1355 | + $this->collConnectionsPartial = true; |
|
| 1356 | + } |
|
| 1357 | + |
|
| 1358 | + return $collConnections; |
|
| 1359 | + } |
|
| 1360 | + |
|
| 1361 | + if ($partial && $this->collConnections) { |
|
| 1362 | + foreach ($this->collConnections as $obj) { |
|
| 1363 | + if ($obj->isNew()) { |
|
| 1364 | + $collConnections[] = $obj; |
|
| 1365 | + } |
|
| 1366 | + } |
|
| 1367 | + } |
|
| 1368 | + |
|
| 1369 | + $this->collConnections = $collConnections; |
|
| 1370 | + $this->collConnectionsPartial = false; |
|
| 1371 | + } |
|
| 1372 | + } |
|
| 1373 | + |
|
| 1374 | + return $this->collConnections; |
|
| 1375 | + } |
|
| 1376 | + |
|
| 1377 | + /** |
|
| 1378 | + * Sets a collection of ChildConnection objects related by a one-to-many relationship |
|
| 1379 | + * to the current object. |
|
| 1380 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1381 | + * and new objects from the given Propel collection. |
|
| 1382 | + * |
|
| 1383 | + * @param Collection $connections A Propel collection. |
|
| 1384 | + * @param ConnectionInterface $con Optional connection object |
|
| 1385 | + * @return $this|ChildUser The current object (for fluent API support) |
|
| 1386 | + */ |
|
| 1387 | + public function setConnections(Collection $connections, ConnectionInterface $con = null) |
|
| 1388 | + { |
|
| 1389 | + /** @var ChildConnection[] $connectionsToDelete */ |
|
| 1390 | + $connectionsToDelete = $this->getConnections(new Criteria(), $con)->diff($connections); |
|
| 1391 | + |
|
| 1392 | + |
|
| 1393 | + $this->connectionsScheduledForDeletion = $connectionsToDelete; |
|
| 1394 | + |
|
| 1395 | + foreach ($connectionsToDelete as $connectionRemoved) { |
|
| 1396 | + $connectionRemoved->setUser(null); |
|
| 1397 | + } |
|
| 1398 | + |
|
| 1399 | + $this->collConnections = null; |
|
| 1400 | + foreach ($connections as $connection) { |
|
| 1401 | + $this->addConnection($connection); |
|
| 1402 | + } |
|
| 1403 | + |
|
| 1404 | + $this->collConnections = $connections; |
|
| 1405 | + $this->collConnectionsPartial = false; |
|
| 1406 | + |
|
| 1407 | + return $this; |
|
| 1408 | + } |
|
| 1409 | + |
|
| 1410 | + /** |
|
| 1411 | + * Returns the number of related Connection objects. |
|
| 1412 | + * |
|
| 1413 | + * @param Criteria $criteria |
|
| 1414 | + * @param boolean $distinct |
|
| 1415 | + * @param ConnectionInterface $con |
|
| 1416 | + * @return int Count of related Connection objects. |
|
| 1417 | + * @throws PropelException |
|
| 1418 | + */ |
|
| 1419 | + public function countConnections(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1420 | + { |
|
| 1421 | + $partial = $this->collConnectionsPartial && !$this->isNew(); |
|
| 1422 | + if (null === $this->collConnections || null !== $criteria || $partial) { |
|
| 1423 | + if ($this->isNew() && null === $this->collConnections) { |
|
| 1424 | + return 0; |
|
| 1425 | + } |
|
| 1426 | + |
|
| 1427 | + if ($partial && !$criteria) { |
|
| 1428 | + return count($this->getConnections()); |
|
| 1429 | + } |
|
| 1430 | + |
|
| 1431 | + $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1432 | + if ($distinct) { |
|
| 1433 | + $query->distinct(); |
|
| 1434 | + } |
|
| 1435 | + |
|
| 1436 | + return $query |
|
| 1437 | + ->filterByUser($this) |
|
| 1438 | + ->count($con); |
|
| 1439 | + } |
|
| 1440 | + |
|
| 1441 | + return count($this->collConnections); |
|
| 1442 | + } |
|
| 1443 | + |
|
| 1444 | + /** |
|
| 1445 | + * Method called to associate a ChildConnection object to this object |
|
| 1446 | + * through the ChildConnection foreign key attribute. |
|
| 1447 | + * |
|
| 1448 | + * @param ChildConnection $l ChildConnection |
|
| 1449 | + * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 1450 | + */ |
|
| 1451 | + public function addConnection(ChildConnection $l) |
|
| 1452 | + { |
|
| 1453 | + if ($this->collConnections === null) { |
|
| 1454 | + $this->initConnections(); |
|
| 1455 | + $this->collConnectionsPartial = true; |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + if (!$this->collConnections->contains($l)) { |
|
| 1459 | + $this->doAddConnection($l); |
|
| 1460 | + |
|
| 1461 | + if ($this->connectionsScheduledForDeletion and $this->connectionsScheduledForDeletion->contains($l)) { |
|
| 1462 | + $this->connectionsScheduledForDeletion->remove($this->connectionsScheduledForDeletion->search($l)); |
|
| 1463 | + } |
|
| 1464 | + } |
|
| 1465 | + |
|
| 1466 | + return $this; |
|
| 1467 | + } |
|
| 1468 | + |
|
| 1469 | + /** |
|
| 1470 | + * @param ChildConnection $connection The ChildConnection object to add. |
|
| 1471 | + */ |
|
| 1472 | + protected function doAddConnection(ChildConnection $connection) |
|
| 1473 | + { |
|
| 1474 | + $this->collConnections[]= $connection; |
|
| 1475 | + $connection->setUser($this); |
|
| 1476 | + } |
|
| 1477 | + |
|
| 1478 | + /** |
|
| 1479 | + * @param ChildConnection $connection The ChildConnection object to remove. |
|
| 1480 | + * @return $this|ChildUser The current object (for fluent API support) |
|
| 1481 | + */ |
|
| 1482 | + public function removeConnection(ChildConnection $connection) |
|
| 1483 | + { |
|
| 1484 | + if ($this->getConnections()->contains($connection)) { |
|
| 1485 | + $pos = $this->collConnections->search($connection); |
|
| 1486 | + $this->collConnections->remove($pos); |
|
| 1487 | + if (null === $this->connectionsScheduledForDeletion) { |
|
| 1488 | + $this->connectionsScheduledForDeletion = clone $this->collConnections; |
|
| 1489 | + $this->connectionsScheduledForDeletion->clear(); |
|
| 1490 | + } |
|
| 1491 | + $this->connectionsScheduledForDeletion[]= $connection; |
|
| 1492 | + $connection->setUser(null); |
|
| 1493 | + } |
|
| 1494 | + |
|
| 1495 | + return $this; |
|
| 1496 | + } |
|
| 1497 | + |
|
| 1498 | + |
|
| 1499 | + /** |
|
| 1500 | + * If this collection has already been initialized with |
|
| 1501 | + * an identical criteria, it returns the collection. |
|
| 1502 | + * Otherwise if this User is new, it will return |
|
| 1503 | + * an empty collection; or if this User has previously |
|
| 1504 | + * been saved, it will retrieve related Connections from storage. |
|
| 1505 | + * |
|
| 1506 | + * This method is protected by default in order to keep the public |
|
| 1507 | + * api reasonable. You can provide public methods for those you |
|
| 1508 | + * actually need in User. |
|
| 1509 | + * |
|
| 1510 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1511 | + * @param ConnectionInterface $con optional connection object |
|
| 1512 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1513 | + * @return ObjectCollection|ChildConnection[] List of ChildConnection objects |
|
| 1514 | + */ |
|
| 1515 | + public function getConnectionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1516 | + { |
|
| 1517 | + $query = ChildConnectionQuery::create(null, $criteria); |
|
| 1518 | + $query->joinWith('Instance', $joinBehavior); |
|
| 1519 | + |
|
| 1520 | + return $this->getConnections($query, $con); |
|
| 1521 | + } |
|
| 1522 | + |
|
| 1523 | + /** |
|
| 1524 | + * Clears out the collSubscriptions collection |
|
| 1525 | + * |
|
| 1526 | + * This does not modify the database; however, it will remove any associated objects, causing |
|
| 1527 | + * them to be refetched by subsequent calls to accessor method. |
|
| 1528 | + * |
|
| 1529 | + * @return void |
|
| 1530 | + * @see addSubscriptions() |
|
| 1531 | + */ |
|
| 1532 | + public function clearSubscriptions() |
|
| 1533 | + { |
|
| 1534 | + $this->collSubscriptions = null; // important to set this to NULL since that means it is uninitialized |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + /** |
|
| 1538 | + * Reset is the collSubscriptions collection loaded partially. |
|
| 1539 | + */ |
|
| 1540 | + public function resetPartialSubscriptions($v = true) |
|
| 1541 | + { |
|
| 1542 | + $this->collSubscriptionsPartial = $v; |
|
| 1543 | + } |
|
| 1544 | + |
|
| 1545 | + /** |
|
| 1546 | + * Initializes the collSubscriptions collection. |
|
| 1547 | + * |
|
| 1548 | + * By default this just sets the collSubscriptions collection to an empty array (like clearcollSubscriptions()); |
|
| 1549 | + * however, you may wish to override this method in your stub class to provide setting appropriate |
|
| 1550 | + * to your application -- for example, setting the initial array to the values stored in database. |
|
| 1551 | + * |
|
| 1552 | + * @param boolean $overrideExisting If set to true, the method call initializes |
|
| 1553 | + * the collection even if it is not empty |
|
| 1554 | + * |
|
| 1555 | + * @return void |
|
| 1556 | + */ |
|
| 1557 | + public function initSubscriptions($overrideExisting = true) |
|
| 1558 | + { |
|
| 1559 | + if (null !== $this->collSubscriptions && !$overrideExisting) { |
|
| 1560 | + return; |
|
| 1561 | + } |
|
| 1562 | + |
|
| 1563 | + $collectionClassName = SubscriptionTableMap::getTableMap()->getCollectionClassName(); |
|
| 1564 | + |
|
| 1565 | + $this->collSubscriptions = new $collectionClassName; |
|
| 1566 | + $this->collSubscriptions->setModel('\Jalle19\StatusManager\Database\Subscription'); |
|
| 1567 | + } |
|
| 1568 | + |
|
| 1569 | + /** |
|
| 1570 | + * Gets an array of ChildSubscription objects which contain a foreign key that references this object. |
|
| 1571 | + * |
|
| 1572 | + * If the $criteria is not null, it is used to always fetch the results from the database. |
|
| 1573 | + * Otherwise the results are fetched from the database the first time, then cached. |
|
| 1574 | + * Next time the same method is called without $criteria, the cached collection is returned. |
|
| 1575 | + * If this ChildUser is new, it will return |
|
| 1576 | + * an empty collection or the current collection; the criteria is ignored on a new object. |
|
| 1577 | + * |
|
| 1578 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1579 | + * @param ConnectionInterface $con optional connection object |
|
| 1580 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1581 | + * @throws PropelException |
|
| 1582 | + */ |
|
| 1583 | + public function getSubscriptions(Criteria $criteria = null, ConnectionInterface $con = null) |
|
| 1584 | + { |
|
| 1585 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1586 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1587 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1588 | + // return empty collection |
|
| 1589 | + $this->initSubscriptions(); |
|
| 1590 | + } else { |
|
| 1591 | + $collSubscriptions = ChildSubscriptionQuery::create(null, $criteria) |
|
| 1592 | + ->filterByUser($this) |
|
| 1593 | + ->find($con); |
|
| 1594 | + |
|
| 1595 | + if (null !== $criteria) { |
|
| 1596 | + if (false !== $this->collSubscriptionsPartial && count($collSubscriptions)) { |
|
| 1597 | + $this->initSubscriptions(false); |
|
| 1598 | + |
|
| 1599 | + foreach ($collSubscriptions as $obj) { |
|
| 1600 | + if (false == $this->collSubscriptions->contains($obj)) { |
|
| 1601 | + $this->collSubscriptions->append($obj); |
|
| 1602 | + } |
|
| 1603 | + } |
|
| 1604 | + |
|
| 1605 | + $this->collSubscriptionsPartial = true; |
|
| 1606 | + } |
|
| 1607 | + |
|
| 1608 | + return $collSubscriptions; |
|
| 1609 | + } |
|
| 1610 | + |
|
| 1611 | + if ($partial && $this->collSubscriptions) { |
|
| 1612 | + foreach ($this->collSubscriptions as $obj) { |
|
| 1613 | + if ($obj->isNew()) { |
|
| 1614 | + $collSubscriptions[] = $obj; |
|
| 1615 | + } |
|
| 1616 | + } |
|
| 1617 | + } |
|
| 1618 | + |
|
| 1619 | + $this->collSubscriptions = $collSubscriptions; |
|
| 1620 | + $this->collSubscriptionsPartial = false; |
|
| 1621 | + } |
|
| 1622 | + } |
|
| 1623 | + |
|
| 1624 | + return $this->collSubscriptions; |
|
| 1625 | + } |
|
| 1626 | + |
|
| 1627 | + /** |
|
| 1628 | + * Sets a collection of ChildSubscription objects related by a one-to-many relationship |
|
| 1629 | + * to the current object. |
|
| 1630 | + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) |
|
| 1631 | + * and new objects from the given Propel collection. |
|
| 1632 | + * |
|
| 1633 | + * @param Collection $subscriptions A Propel collection. |
|
| 1634 | + * @param ConnectionInterface $con Optional connection object |
|
| 1635 | + * @return $this|ChildUser The current object (for fluent API support) |
|
| 1636 | + */ |
|
| 1637 | + public function setSubscriptions(Collection $subscriptions, ConnectionInterface $con = null) |
|
| 1638 | + { |
|
| 1639 | + /** @var ChildSubscription[] $subscriptionsToDelete */ |
|
| 1640 | + $subscriptionsToDelete = $this->getSubscriptions(new Criteria(), $con)->diff($subscriptions); |
|
| 1641 | + |
|
| 1642 | + |
|
| 1643 | + $this->subscriptionsScheduledForDeletion = $subscriptionsToDelete; |
|
| 1644 | + |
|
| 1645 | + foreach ($subscriptionsToDelete as $subscriptionRemoved) { |
|
| 1646 | + $subscriptionRemoved->setUser(null); |
|
| 1647 | + } |
|
| 1648 | + |
|
| 1649 | + $this->collSubscriptions = null; |
|
| 1650 | + foreach ($subscriptions as $subscription) { |
|
| 1651 | + $this->addSubscription($subscription); |
|
| 1652 | + } |
|
| 1653 | + |
|
| 1654 | + $this->collSubscriptions = $subscriptions; |
|
| 1655 | + $this->collSubscriptionsPartial = false; |
|
| 1656 | + |
|
| 1657 | + return $this; |
|
| 1658 | + } |
|
| 1659 | + |
|
| 1660 | + /** |
|
| 1661 | + * Returns the number of related Subscription objects. |
|
| 1662 | + * |
|
| 1663 | + * @param Criteria $criteria |
|
| 1664 | + * @param boolean $distinct |
|
| 1665 | + * @param ConnectionInterface $con |
|
| 1666 | + * @return int Count of related Subscription objects. |
|
| 1667 | + * @throws PropelException |
|
| 1668 | + */ |
|
| 1669 | + public function countSubscriptions(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) |
|
| 1670 | + { |
|
| 1671 | + $partial = $this->collSubscriptionsPartial && !$this->isNew(); |
|
| 1672 | + if (null === $this->collSubscriptions || null !== $criteria || $partial) { |
|
| 1673 | + if ($this->isNew() && null === $this->collSubscriptions) { |
|
| 1674 | + return 0; |
|
| 1675 | + } |
|
| 1676 | + |
|
| 1677 | + if ($partial && !$criteria) { |
|
| 1678 | + return count($this->getSubscriptions()); |
|
| 1679 | + } |
|
| 1680 | + |
|
| 1681 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1682 | + if ($distinct) { |
|
| 1683 | + $query->distinct(); |
|
| 1684 | + } |
|
| 1685 | + |
|
| 1686 | + return $query |
|
| 1687 | + ->filterByUser($this) |
|
| 1688 | + ->count($con); |
|
| 1689 | + } |
|
| 1690 | + |
|
| 1691 | + return count($this->collSubscriptions); |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + /** |
|
| 1695 | + * Method called to associate a ChildSubscription object to this object |
|
| 1696 | + * through the ChildSubscription foreign key attribute. |
|
| 1697 | + * |
|
| 1698 | + * @param ChildSubscription $l ChildSubscription |
|
| 1699 | + * @return $this|\Jalle19\StatusManager\Database\User The current object (for fluent API support) |
|
| 1700 | + */ |
|
| 1701 | + public function addSubscription(ChildSubscription $l) |
|
| 1702 | + { |
|
| 1703 | + if ($this->collSubscriptions === null) { |
|
| 1704 | + $this->initSubscriptions(); |
|
| 1705 | + $this->collSubscriptionsPartial = true; |
|
| 1706 | + } |
|
| 1707 | + |
|
| 1708 | + if (!$this->collSubscriptions->contains($l)) { |
|
| 1709 | + $this->doAddSubscription($l); |
|
| 1710 | + |
|
| 1711 | + if ($this->subscriptionsScheduledForDeletion and $this->subscriptionsScheduledForDeletion->contains($l)) { |
|
| 1712 | + $this->subscriptionsScheduledForDeletion->remove($this->subscriptionsScheduledForDeletion->search($l)); |
|
| 1713 | + } |
|
| 1714 | + } |
|
| 1715 | + |
|
| 1716 | + return $this; |
|
| 1717 | + } |
|
| 1718 | + |
|
| 1719 | + /** |
|
| 1720 | + * @param ChildSubscription $subscription The ChildSubscription object to add. |
|
| 1721 | + */ |
|
| 1722 | + protected function doAddSubscription(ChildSubscription $subscription) |
|
| 1723 | + { |
|
| 1724 | + $this->collSubscriptions[]= $subscription; |
|
| 1725 | + $subscription->setUser($this); |
|
| 1726 | + } |
|
| 1727 | + |
|
| 1728 | + /** |
|
| 1729 | + * @param ChildSubscription $subscription The ChildSubscription object to remove. |
|
| 1730 | + * @return $this|ChildUser The current object (for fluent API support) |
|
| 1731 | + */ |
|
| 1732 | + public function removeSubscription(ChildSubscription $subscription) |
|
| 1733 | + { |
|
| 1734 | + if ($this->getSubscriptions()->contains($subscription)) { |
|
| 1735 | + $pos = $this->collSubscriptions->search($subscription); |
|
| 1736 | + $this->collSubscriptions->remove($pos); |
|
| 1737 | + if (null === $this->subscriptionsScheduledForDeletion) { |
|
| 1738 | + $this->subscriptionsScheduledForDeletion = clone $this->collSubscriptions; |
|
| 1739 | + $this->subscriptionsScheduledForDeletion->clear(); |
|
| 1740 | + } |
|
| 1741 | + $this->subscriptionsScheduledForDeletion[]= $subscription; |
|
| 1742 | + $subscription->setUser(null); |
|
| 1743 | + } |
|
| 1744 | + |
|
| 1745 | + return $this; |
|
| 1746 | + } |
|
| 1747 | + |
|
| 1748 | + |
|
| 1749 | + /** |
|
| 1750 | + * If this collection has already been initialized with |
|
| 1751 | + * an identical criteria, it returns the collection. |
|
| 1752 | + * Otherwise if this User is new, it will return |
|
| 1753 | + * an empty collection; or if this User has previously |
|
| 1754 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1755 | + * |
|
| 1756 | + * This method is protected by default in order to keep the public |
|
| 1757 | + * api reasonable. You can provide public methods for those you |
|
| 1758 | + * actually need in User. |
|
| 1759 | + * |
|
| 1760 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1761 | + * @param ConnectionInterface $con optional connection object |
|
| 1762 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1763 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1764 | + */ |
|
| 1765 | + public function getSubscriptionsJoinInstance(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1766 | + { |
|
| 1767 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1768 | + $query->joinWith('Instance', $joinBehavior); |
|
| 1769 | + |
|
| 1770 | + return $this->getSubscriptions($query, $con); |
|
| 1771 | + } |
|
| 1772 | + |
|
| 1773 | + |
|
| 1774 | + /** |
|
| 1775 | + * If this collection has already been initialized with |
|
| 1776 | + * an identical criteria, it returns the collection. |
|
| 1777 | + * Otherwise if this User is new, it will return |
|
| 1778 | + * an empty collection; or if this User has previously |
|
| 1779 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1780 | + * |
|
| 1781 | + * This method is protected by default in order to keep the public |
|
| 1782 | + * api reasonable. You can provide public methods for those you |
|
| 1783 | + * actually need in User. |
|
| 1784 | + * |
|
| 1785 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1786 | + * @param ConnectionInterface $con optional connection object |
|
| 1787 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1788 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1789 | + */ |
|
| 1790 | + public function getSubscriptionsJoinInput(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1791 | + { |
|
| 1792 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1793 | + $query->joinWith('Input', $joinBehavior); |
|
| 1794 | + |
|
| 1795 | + return $this->getSubscriptions($query, $con); |
|
| 1796 | + } |
|
| 1797 | + |
|
| 1798 | + |
|
| 1799 | + /** |
|
| 1800 | + * If this collection has already been initialized with |
|
| 1801 | + * an identical criteria, it returns the collection. |
|
| 1802 | + * Otherwise if this User is new, it will return |
|
| 1803 | + * an empty collection; or if this User has previously |
|
| 1804 | + * been saved, it will retrieve related Subscriptions from storage. |
|
| 1805 | + * |
|
| 1806 | + * This method is protected by default in order to keep the public |
|
| 1807 | + * api reasonable. You can provide public methods for those you |
|
| 1808 | + * actually need in User. |
|
| 1809 | + * |
|
| 1810 | + * @param Criteria $criteria optional Criteria object to narrow the query |
|
| 1811 | + * @param ConnectionInterface $con optional connection object |
|
| 1812 | + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) |
|
| 1813 | + * @return ObjectCollection|ChildSubscription[] List of ChildSubscription objects |
|
| 1814 | + */ |
|
| 1815 | + public function getSubscriptionsJoinChannel(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) |
|
| 1816 | + { |
|
| 1817 | + $query = ChildSubscriptionQuery::create(null, $criteria); |
|
| 1818 | + $query->joinWith('Channel', $joinBehavior); |
|
| 1819 | + |
|
| 1820 | + return $this->getSubscriptions($query, $con); |
|
| 1821 | + } |
|
| 1822 | + |
|
| 1823 | + /** |
|
| 1824 | + * Clears the current object, sets all attributes to their default values and removes |
|
| 1825 | + * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
|
| 1826 | + * change of those foreign objects when you call `save` there). |
|
| 1827 | + */ |
|
| 1828 | + public function clear() |
|
| 1829 | + { |
|
| 1830 | + if (null !== $this->aInstance) { |
|
| 1831 | + $this->aInstance->removeUser($this); |
|
| 1832 | + } |
|
| 1833 | + $this->id = null; |
|
| 1834 | + $this->instance_name = null; |
|
| 1835 | + $this->name = null; |
|
| 1836 | + $this->alreadyInSave = false; |
|
| 1837 | + $this->clearAllReferences(); |
|
| 1838 | + $this->resetModified(); |
|
| 1839 | + $this->setNew(true); |
|
| 1840 | + $this->setDeleted(false); |
|
| 1841 | + } |
|
| 1842 | + |
|
| 1843 | + /** |
|
| 1844 | + * Resets all references and back-references to other model objects or collections of model objects. |
|
| 1845 | + * |
|
| 1846 | + * This method is used to reset all php object references (not the actual reference in the database). |
|
| 1847 | + * Necessary for object serialisation. |
|
| 1848 | + * |
|
| 1849 | + * @param boolean $deep Whether to also clear the references on all referrer objects. |
|
| 1850 | + */ |
|
| 1851 | + public function clearAllReferences($deep = false) |
|
| 1852 | + { |
|
| 1853 | + if ($deep) { |
|
| 1854 | + if ($this->collConnections) { |
|
| 1855 | + foreach ($this->collConnections as $o) { |
|
| 1856 | + $o->clearAllReferences($deep); |
|
| 1857 | + } |
|
| 1858 | + } |
|
| 1859 | + if ($this->collSubscriptions) { |
|
| 1860 | + foreach ($this->collSubscriptions as $o) { |
|
| 1861 | + $o->clearAllReferences($deep); |
|
| 1862 | + } |
|
| 1863 | + } |
|
| 1864 | + } // if ($deep) |
|
| 1865 | + |
|
| 1866 | + $this->collConnections = null; |
|
| 1867 | + $this->collSubscriptions = null; |
|
| 1868 | + $this->aInstance = null; |
|
| 1869 | + } |
|
| 1870 | + |
|
| 1871 | + /** |
|
| 1872 | + * Return the string representation of this object |
|
| 1873 | + * |
|
| 1874 | + * @return string |
|
| 1875 | + */ |
|
| 1876 | + public function __toString() |
|
| 1877 | + { |
|
| 1878 | + return (string) $this->exportTo(UserTableMap::DEFAULT_STRING_FORMAT); |
|
| 1879 | + } |
|
| 1880 | + |
|
| 1881 | + /** |
|
| 1882 | + * Code to be run before persisting the object |
|
| 1883 | + * @param ConnectionInterface $con |
|
| 1884 | + * @return boolean |
|
| 1885 | + */ |
|
| 1886 | + public function preSave(ConnectionInterface $con = null) |
|
| 1887 | + { |
|
| 1888 | + return true; |
|
| 1889 | + } |
|
| 1890 | + |
|
| 1891 | + /** |
|
| 1892 | + * Code to be run after persisting the object |
|
| 1893 | + * @param ConnectionInterface $con |
|
| 1894 | + */ |
|
| 1895 | + public function postSave(ConnectionInterface $con = null) |
|
| 1896 | + { |
|
| 1897 | + |
|
| 1898 | + } |
|
| 1899 | + |
|
| 1900 | + /** |
|
| 1901 | + * Code to be run before inserting to database |
|
| 1902 | + * @param ConnectionInterface $con |
|
| 1903 | + * @return boolean |
|
| 1904 | + */ |
|
| 1905 | + public function preInsert(ConnectionInterface $con = null) |
|
| 1906 | + { |
|
| 1907 | + return true; |
|
| 1908 | + } |
|
| 1909 | + |
|
| 1910 | + /** |
|
| 1911 | + * Code to be run after inserting to database |
|
| 1912 | + * @param ConnectionInterface $con |
|
| 1913 | + */ |
|
| 1914 | + public function postInsert(ConnectionInterface $con = null) |
|
| 1915 | + { |
|
| 1916 | + |
|
| 1917 | + } |
|
| 1918 | + |
|
| 1919 | + /** |
|
| 1920 | + * Code to be run before updating the object in database |
|
| 1921 | + * @param ConnectionInterface $con |
|
| 1922 | + * @return boolean |
|
| 1923 | + */ |
|
| 1924 | + public function preUpdate(ConnectionInterface $con = null) |
|
| 1925 | + { |
|
| 1926 | + return true; |
|
| 1927 | + } |
|
| 1928 | + |
|
| 1929 | + /** |
|
| 1930 | + * Code to be run after updating the object in database |
|
| 1931 | + * @param ConnectionInterface $con |
|
| 1932 | + */ |
|
| 1933 | + public function postUpdate(ConnectionInterface $con = null) |
|
| 1934 | + { |
|
| 1935 | + |
|
| 1936 | + } |
|
| 1937 | + |
|
| 1938 | + /** |
|
| 1939 | + * Code to be run before deleting the object in database |
|
| 1940 | + * @param ConnectionInterface $con |
|
| 1941 | + * @return boolean |
|
| 1942 | + */ |
|
| 1943 | + public function preDelete(ConnectionInterface $con = null) |
|
| 1944 | + { |
|
| 1945 | + return true; |
|
| 1946 | + } |
|
| 1947 | + |
|
| 1948 | + /** |
|
| 1949 | + * Code to be run after deleting the object in database |
|
| 1950 | + * @param ConnectionInterface $con |
|
| 1951 | + */ |
|
| 1952 | + public function postDelete(ConnectionInterface $con = null) |
|
| 1953 | + { |
|
| 1954 | + |
|
| 1955 | + } |
|
| 1956 | + |
|
| 1957 | + |
|
| 1958 | + /** |
|
| 1959 | + * Derived method to catches calls to undefined methods. |
|
| 1960 | + * |
|
| 1961 | + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
|
| 1962 | + * Allows to define default __call() behavior if you overwrite __call() |
|
| 1963 | + * |
|
| 1964 | + * @param string $name |
|
| 1965 | + * @param mixed $params |
|
| 1966 | + * |
|
| 1967 | + * @return array|string |
|
| 1968 | + */ |
|
| 1969 | + public function __call($name, $params) |
|
| 1970 | + { |
|
| 1971 | + if (0 === strpos($name, 'get')) { |
|
| 1972 | + $virtualColumn = substr($name, 3); |
|
| 1973 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1974 | + return $this->getVirtualColumn($virtualColumn); |
|
| 1975 | + } |
|
| 1976 | + |
|
| 1977 | + $virtualColumn = lcfirst($virtualColumn); |
|
| 1978 | + if ($this->hasVirtualColumn($virtualColumn)) { |
|
| 1979 | + return $this->getVirtualColumn($virtualColumn); |
|
| 1980 | + } |
|
| 1981 | + } |
|
| 1982 | + |
|
| 1983 | + if (0 === strpos($name, 'from')) { |
|
| 1984 | + $format = substr($name, 4); |
|
| 1985 | + |
|
| 1986 | + return $this->importFrom($format, reset($params)); |
|
| 1987 | + } |
|
| 1988 | + |
|
| 1989 | + if (0 === strpos($name, 'to')) { |
|
| 1990 | + $format = substr($name, 2); |
|
| 1991 | + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; |
|
| 1992 | + |
|
| 1993 | + return $this->exportTo($format, $includeLazyLoadColumns); |
|
| 1994 | + } |
|
| 1995 | + |
|
| 1996 | + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); |
|
| 1997 | + } |
|
| 1998 | 1998 | |
| 1999 | 1999 | } |
@@ -27,9 +27,9 @@ |
||
| 27 | 27 | public function filterBySubscriptionStatus($instanceName, SubscriptionStatus $status) |
| 28 | 28 | { |
| 29 | 29 | return $this->filterByInstanceName($instanceName) |
| 30 | - ->filterByNetwork(Subscription::parseNetwork($status)) |
|
| 31 | - ->filterByMux(Subscription::parseMux($status)) |
|
| 32 | - ->addDescendingOrderByColumn('started'); |
|
| 30 | + ->filterByNetwork(Subscription::parseNetwork($status)) |
|
| 31 | + ->filterByMux(Subscription::parseMux($status)) |
|
| 32 | + ->addDescendingOrderByColumn('started'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | } |