| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
require_once 'propel/om/BaseObject.php'; |
|---|
| 4 |
|
|---|
| 5 |
require_once 'propel/om/Persistent.php'; |
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
include_once 'propel/util/Criteria.php'; |
|---|
| 9 |
|
|---|
| 10 |
include_once 'model/SnippetTagPeer.php'; |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
abstract class BaseSnippetTag extends BaseObject implements Persistent { |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
* The Peer class. |
|---|
| 24 |
* Instance provides a convenient way of calling static methods on a class |
|---|
| 25 |
* that calling code may not be able to identify. |
|---|
| 26 |
* @var SnippetTagPeer |
|---|
| 27 |
*/ |
|---|
| 28 |
protected static $peer; |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
* The value for the id field. |
|---|
| 33 |
* @var int |
|---|
| 34 |
*/ |
|---|
| 35 |
protected $id; |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
* The value for the user_id field. |
|---|
| 40 |
* @var int |
|---|
| 41 |
*/ |
|---|
| 42 |
protected $user_id; |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
* The value for the snippet_id field. |
|---|
| 47 |
* @var int |
|---|
| 48 |
*/ |
|---|
| 49 |
protected $snippet_id; |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
* The value for the name field. |
|---|
| 54 |
* @var string |
|---|
| 55 |
*/ |
|---|
| 56 |
protected $name; |
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* The value for the created_at field. |
|---|
| 61 |
* @var int |
|---|
| 62 |
*/ |
|---|
| 63 |
protected $created_at; |
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 |
* @var SnippetUser |
|---|
| 67 |
*/ |
|---|
| 68 |
protected $aSnippetUser; |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
* @var SnippetSnippet |
|---|
| 72 |
*/ |
|---|
| 73 |
protected $aSnippetSnippet; |
|---|
| 74 |
|
|---|
| 75 |
|
|---|
| 76 |
* Flag to prevent endless save loop, if this object is referenced |
|---|
| 77 |
* by another object which falls in this transaction. |
|---|
| 78 |
* @var boolean |
|---|
| 79 |
*/ |
|---|
| 80 |
protected $alreadyInSave = false; |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
* Flag to prevent endless validation loop, if this object is referenced |
|---|
| 84 |
* by another object which falls in this transaction. |
|---|
| 85 |
* @var boolean |
|---|
| 86 |
*/ |
|---|
| 87 |
protected $alreadyInValidation = false; |
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
* Get the [id] column value. |
|---|
| 91 |
* |
|---|
| 92 |
* @return int |
|---|
| 93 |
*/ |
|---|
| 94 |
public function getId() |
|---|
| 95 |
{ |
|---|
| 96 |
|
|---|
| 97 |
return $this->id; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
* Get the [user_id] column value. |
|---|
| 102 |
* |
|---|
| 103 |
* @return int |
|---|
| 104 |
*/ |
|---|
| 105 |
public function getUserId() |
|---|
| 106 |
{ |
|---|
| 107 |
|
|---|
| 108 |
return $this->user_id; |
|---|
| 109 |
} |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
* Get the [snippet_id] column value. |
|---|
| 113 |
* |
|---|
| 114 |
* @return int |
|---|
| 115 |
*/ |
|---|
| 116 |
public function getSnippetId() |
|---|
| 117 |
{ |
|---|
| 118 |
|
|---|
| 119 |
return $this->snippet_id; |
|---|
| 120 |
} |
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
* Get the [name] column value. |
|---|
| 124 |
* |
|---|
| 125 |
* @return string |
|---|
| 126 |
*/ |
|---|
| 127 |
public function getName() |
|---|
| 128 |
{ |
|---|
| 129 |
|
|---|
| 130 |
return $this->name; |
|---|
| 131 |
} |
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
* Get the [optionally formatted] [created_at] column value. |
|---|
| 135 |
* |
|---|
| 136 |
* @param string $format The date/time format string (either date()-style or strftime()-style). |
|---|
| 137 |
* If format is NULL, then the integer unix timestamp will be returned. |
|---|
| 138 |
* @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL). |
|---|
| 139 |
* @throws PropelException - if unable to convert the date/time to timestamp. |
|---|
| 140 |
*/ |
|---|
| 141 |
public function getCreatedAt($format = 'Y-m-d H:i:s') |
|---|
| 142 |
{ |
|---|
| 143 |
|
|---|
| 144 |
if ($this->created_at === null || $this->created_at === '') { |
|---|
| 145 |
return null; |
|---|
| 146 |
} elseif (!is_int($this->created_at)) { |
|---|
| 147 |
|
|---|
| 148 |
$ts = strtotime($this->created_at); |
|---|
| 149 |
if ($ts === -1 || $ts === false) { |
|---|
| 150 |
throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true)); |
|---|
| 151 |
} |
|---|
| 152 |
} else { |
|---|
| 153 |
$ts = $this->created_at; |
|---|
| 154 |
} |
|---|
| 155 |
if ($format === null) { |
|---|
| 156 |
return $ts; |
|---|
| 157 |
} elseif (strpos($format, '%') !== false) { |
|---|
| 158 |
return strftime($format, $ts); |
|---|
| 159 |
} else { |
|---|
| 160 |
return date($format, $ts); |
|---|
| 161 |
} |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
* Set the value of [id] column. |
|---|
| 166 |
* |
|---|
| 167 |
* @param int $v new value |
|---|
| 168 |
* @return void |
|---|
| 169 |
*/ |
|---|
| 170 |
public function setId($v) |
|---|
| 171 |
{ |
|---|
| 172 |
|
|---|
| 173 |
if ($this->id !== $v) { |
|---|
| 174 |
$this->id = $v; |
|---|
| 175 |
$this->modifiedColumns[] = SnippetTagPeer::ID; |
|---|
| 176 |
} |
|---|
| 177 |
|
|---|
| 178 |
} |
|---|
| 179 |
|
|---|
| 180 |
/** |
|---|
| 181 |
* Set the value of [user_id] column. |
|---|
| 182 |
* |
|---|
| 183 |
* @param int $v new value |
|---|
| 184 |
* @return void |
|---|
| 185 |
*/ |
|---|
| 186 |
public function setUserId($v) |
|---|
| 187 |
{ |
|---|
| 188 |
|
|---|
| 189 |
if ($this->user_id !== $v) { |
|---|
| 190 |
$this->user_id = $v; |
|---|
| 191 |
$this->modifiedColumns[] = SnippetTagPeer::USER_ID; |
|---|
| 192 |
} |
|---|
| 193 |
|
|---|
| 194 |
if ($this->aSnippetUser !== null && $this->aSnippetUser->getId() !== $v) { |
|---|
| 195 |
$this->aSnippetUser = null; |
|---|
| 196 |
} |
|---|
| 197 |
|
|---|
| 198 |
} |
|---|
| 199 |
|
|---|
| 200 |
/** |
|---|
| 201 |
* Set the value of [snippet_id] column. |
|---|
| 202 |
* |
|---|
| 203 |
* @param int $v new value |
|---|
| 204 |
* @return void |
|---|
| 205 |
*/ |
|---|
| 206 |
public function setSnippetId($v) |
|---|
| 207 |
{ |
|---|
| 208 |
|
|---|
| 209 |
if ($this->snippet_id !== $v) { |
|---|
| 210 |
$this->snippet_id = $v; |
|---|
| 211 |
$this->modifiedColumns[] = SnippetTagPeer::SNIPPET_ID; |
|---|
| 212 |
} |
|---|
| 213 |
|
|---|
| 214 |
if ($this->aSnippetSnippet !== null && $this->aSnippetSnippet->getId() !== $v) { |
|---|
| 215 |
$this->aSnippetSnippet = null; |
|---|
| 216 |
} |
|---|
| 217 |
|
|---|
| 218 |
} |
|---|
| 219 |
|
|---|
| 220 |
/** |
|---|
| 221 |
* Set the value of [name] column. |
|---|
| 222 |
* |
|---|
| 223 |
* @param string $v new value |
|---|
| 224 |
* @return void |
|---|
| 225 |
*/ |
|---|
| 226 |
public function setName($v) |
|---|
| 227 |
{ |
|---|
| 228 |
|
|---|
| 229 |
if ($this->name !== $v) { |
|---|
| 230 |
$this->name = $v; |
|---|
| 231 |
$this->modifiedColumns[] = SnippetTagPeer::NAME; |
|---|
| 232 |
} |
|---|
| 233 |
|
|---|
| 234 |
} |
|---|
| 235 |
|
|---|
| 236 |
/** |
|---|
| 237 |
* Set the value of [created_at] column. |
|---|
| 238 |
* |
|---|
| 239 |
* @param int $v new value |
|---|
| 240 |
* @return void |
|---|
| 241 |
*/ |
|---|
| 242 |
public function setCreatedAt($v) |
|---|
| 243 |
{ |
|---|
| 244 |
|
|---|
| 245 |
if ($v !== null && !is_int($v)) { |
|---|
| 246 |
$ts = strtotime($v); |
|---|
| 247 |
if ($ts === -1 || $ts === false) { |
|---|
| 248 |
throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true)); |
|---|
| 249 |
} |
|---|
| 250 |
} else { |
|---|
| 251 |
$ts = $v; |
|---|
| 252 |
} |
|---|
| 253 |
if ($this->created_at !== $ts) { |
|---|
| 254 |
$this->created_at = $ts; |
|---|
| 255 |
$this->modifiedColumns[] = SnippetTagPeer::CREATED_AT; |
|---|
| 256 |
} |
|---|
| 257 |
|
|---|
| 258 |
} |
|---|
| 259 |
|
|---|
| 260 |
/** |
|---|
| 261 |
* Hydrates (populates) the object variables with values from the database resultset. |
|---|
| 262 |
* |
|---|
| 263 |
* An offset (1-based "start column") is specified so that objects can be hydrated |
|---|
| 264 |
* with a subset of the columns in the resultset rows. This is needed, for example, |
|---|
| 265 |
* for results of JOIN queries where the resultset row includes columns from two or |
|---|
| 266 |
* more tables. |
|---|
| 267 |
* |
|---|
| 268 |
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos. |
|---|
| 269 |
* @param int $startcol 1-based offset column which indicates which restultset column to start with. |
|---|
| 270 |
* @return int next starting column |
|---|
| 271 |
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
|---|
| 272 |
*/ |
|---|
| 273 |
public function hydrate(ResultSet $rs, $startcol = 1) |
|---|
| 274 |
{ |
|---|
| 275 |
try { |
|---|
| 276 |
|
|---|
| 277 |
$this->id = $rs->getInt($startcol + 0); |
|---|
| 278 |
|
|---|
| 279 |
$this->user_id = $rs->getInt($startcol + 1); |
|---|
| 280 |
|
|---|
| 281 |
$this->snippet_id = $rs->getInt($startcol + 2); |
|---|
| 282 |
|
|---|
| 283 |
$this->name = $rs->getString($startcol + 3); |
|---|
| 284 |
|
|---|
| 285 |
$this->created_at = $rs->getTimestamp($startcol + 4, null); |
|---|
| 286 |
|
|---|
| 287 |
$this->resetModified(); |
|---|
| 288 |
|
|---|
| 289 |
$this->setNew(false); |
|---|
| 290 |
|
|---|
| 291 |
|
|---|
| 292 |
return $startcol + 5; |
|---|
| 293 |
|
|---|
| 294 |
} catch (Exception $e) { |
|---|
| 295 |
throw new PropelException("Error populating SnippetTag object", $e); |
|---|
| 296 |
} |
|---|
| 297 |
} |
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 |
* Removes this object from datastore and sets delete attribute. |
|---|
| 301 |
* |
|---|
| 302 |
* @param Connection $con |
|---|
| 303 |
* @return void |
|---|
| 304 |
* @throws PropelException |
|---|
| 305 |
* @see BaseObject::setDeleted() |
|---|
| 306 |
* @see BaseObject::isDeleted() |
|---|
| 307 |
*/ |
|---|
| 308 |
public function delete($con = null) |
|---|
| 309 |
{ |
|---|
| 310 |
if ($this->isDeleted()) { |
|---|
| 311 |
throw new PropelException("This object has already been deleted."); |
|---|
| 312 |
} |
|---|
| 313 |
|
|---|
| 314 |
if ($con === null) { |
|---|
| 315 |
$con = Propel::getConnection(SnippetTagPeer::DATABASE_NAME); |
|---|
| 316 |
} |
|---|
| 317 |
|
|---|
| 318 |
try { |
|---|
| 319 |
$con->begin(); |
|---|
| 320 |
SnippetTagPeer::doDelete($this, $con); |
|---|
| 321 |
$this->setDeleted(true); |
|---|
| 322 |
$con->commit(); |
|---|
| 323 |
} catch (PropelException $e) { |
|---|
| 324 |
$con->rollback(); |
|---|
| 325 |
throw $e; |
|---|
| 326 |
} |
|---|
| 327 |
} |
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
* Stores the object in the database. If the object is new, |
|---|
| 331 |
* it inserts it; otherwise an update is performed. This method |
|---|
| 332 |
* wraps the doSave() worker method in a transaction. |
|---|
| 333 |
* |
|---|
| 334 |
* @param Connection $con |
|---|
| 335 |
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|---|
| 336 |
* @throws PropelException |
|---|
| 337 |
* @see doSave() |
|---|
| 338 |
*/ |
|---|
| 339 |
public function save($con = null) |
|---|
| 340 |
{ |
|---|
| 341 |
if ($this->isNew() && !$this->isColumnModified('created_at')) |
|---|
| 342 |
{ |
|---|
| 343 |
$this->setCreatedAt(time()); |
|---|
| 344 |
} |
|---|
| 345 |
|
|---|
| 346 |
if ($this->isDeleted()) { |
|---|
| 347 |
throw new PropelException("You cannot save an object that has been deleted."); |
|---|
| 348 |
} |
|---|
| 349 |
|
|---|
| 350 |
if ($con === null) { |
|---|
| 351 |
$con = Propel::getConnection(SnippetTagPeer::DATABASE_NAME); |
|---|
| 352 |
} |
|---|
| 353 |
|
|---|
| 354 |
try { |
|---|
| 355 |
$con->begin(); |
|---|
| 356 |
$affectedRows = $this->doSave($con); |
|---|
| 357 |
$con->commit(); |
|---|
| 358 |
return $affectedRows; |
|---|
| 359 |
} catch (PropelException $e) { |
|---|
| 360 |
$con->rollback(); |
|---|
| 361 |
throw $e; |
|---|
| 362 |
} |
|---|
| 363 |
} |
|---|
| 364 |
|
|---|
| 365 |
|
|---|
| 366 |
* Stores the object in the database. |
|---|
| 367 |
* |
|---|
| 368 |
* If the object is new, it inserts it; otherwise an update is performed. |
|---|
| 369 |
* All related objects are also updated in this method. |
|---|
| 370 |
* |
|---|
| 371 |
* @param Connection $con |
|---|
| 372 |
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
|---|
| 373 |
* @throws PropelException |
|---|
| 374 |
* @see save() |
|---|
| 375 |
*/ |
|---|
| 376 |
protected function doSave($con) |
|---|
| 377 |
{ |
|---|
| 378 |
$affectedRows = 0; |
|---|
| 379 |
if (!$this->alreadyInSave) { |
|---|
| 380 |
$this->alreadyInSave = true; |
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
// were passed to this object by their coresponding set |
|---|
| 385 |
// method. This object relates to these object(s) by a |
|---|
| 386 |
// foreign key reference. |
|---|
| 387 |
|
|---|
| 388 |
if ($this->aSnippetUser !== null) { |
|---|
| 389 |
if ($this->aSnippetUser->isModified()) { |
|---|
| 390 |
$affectedRows += $this->aSnippetUser->save($con); |
|---|
| 391 |
} |
|---|
| 392 |
$this->setSnippetUser($this->aSnippetUser); |
|---|
| 393 |
} |
|---|
| 394 |
|
|---|
| 395 |
if ($this->aSnippetSnippet !== null) { |
|---|
| 396 |
if ($this->aSnippetSnippet->isModified()) { |
|---|
| 397 |
$affectedRows += $this->aSnippetSnippet->save($con); |
|---|
| 398 |
} |
|---|
| 399 |
$this->setSnippetSnippet($this->aSnippetSnippet); |
|---|
| 400 |
} |
|---|
| 401 |
|
|---|
| 402 |
|
|---|
| 403 |
|
|---|
| 404 |
if ($this->isModified()) { |
|---|
| 405 |
if ($this->isNew()) { |
|---|
| 406 |
$pk = SnippetTagPeer::doInsert($this, $con); |
|---|
| 407 |
$affectedRows += 1; |
|---|
| 408 |
// should always be true here (even though technically |
|---|
| 409 |
// BasePeer::doInsert() can insert multiple rows). |
|---|
| 410 |
|
|---|
| 411 |
$this->setId($pk); |
|---|
| 412 |
|
|---|
| 413 |
$this->setNew(false); |
|---|
| 414 |
} else { |
|---|
| 415 |
$affectedRows += SnippetTagPeer::doUpdate($this, $con); |
|---|
| 416 |
} |
|---|
| 417 |
$this->resetModified(); |
|---|
| 418 |
} |
|---|
| 419 |
|
|---|
| 420 |
$this->alreadyInSave = false; |
|---|
| 421 |
} |
|---|
| 422 |
return $affectedRows; |
|---|
| 423 |
} |
|---|
| 424 |
|
|---|
| 425 |
/** |
|---|
| 426 |
* Array of ValidationFailed objects. |
|---|
| 427 |
* @var array ValidationFailed[] |
|---|
| 428 |
*/ |
|---|
| 429 |
protected $validationFailures = array(); |
|---|
| 430 |
|
|---|
| 431 |
|
|---|
| 432 |
* Gets any ValidationFailed objects that resulted from last call to validate(). |
|---|
| 433 |
* |
|---|
| 434 |
* |
|---|
| 435 |
* @return array ValidationFailed[] |
|---|
| 436 |
* @see validate() |
|---|
| 437 |
*/ |
|---|
| 438 |
public function getValidationFailures() |
|---|
| 439 |
{ |
|---|
| 440 |
return $this->validationFailures; |
|---|
| 441 |
} |
|---|
| 442 |
|
|---|
| 443 |
|
|---|
| 444 |
* Validates the objects modified field values and all objects related to this table. |
|---|
| 445 |
* |
|---|
| 446 |
* If $columns is either a column name or an array of column names |
|---|
| 447 |
* only those columns are validated. |
|---|
| 448 |
* |
|---|
| 449 |
* @param mixed $columns Column name or an array of column names. |
|---|
| 450 |
* @return boolean Whether all columns pass validation. |
|---|
| 451 |
* @see doValidate() |
|---|
| 452 |
* @see getValidationFailures() |
|---|
| 453 |
*/ |
|---|
| 454 |
public function validate($columns = null) |
|---|
| 455 |
{ |
|---|
| 456 |
$res = $this->doValidate($columns); |
|---|
| 457 |
if ($res === true) { |
|---|
| 458 |
$this->validationFailures = array(); |
|---|
| 459 |
return true; |
|---|
| 460 |
} else { |
|---|
| 461 |
$this->validationFailures = $res; |
|---|
| 462 |
return false; |
|---|
| 463 |
} |
|---|
| 464 |
} |
|---|
| 465 |
|
|---|
| 466 |
|
|---|
| 467 |
* This function performs the validation work for complex object models. |
|---|
| 468 |
* |
|---|
| 469 |
* In addition to checking the current object, all related objects will |
|---|
| 470 |
* also be validated. If all pass then <code>true</code> is returned; otherwise |
|---|
| 471 |
* an aggreagated array of ValidationFailed objects will be returned. |
|---|
| 472 |
* |
|---|
| 473 |
* @param array $columns Array of column names to validate. |
|---|
| 474 |
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise. |
|---|
| 475 |
*/ |
|---|
| 476 |
protected function doValidate($columns = null) |
|---|
| 477 |
{ |
|---|
| 478 |
if (!$this->alreadyInValidation) { |
|---|
| 479 |
$this->alreadyInValidation = true; |
|---|
| 480 |
$retval = null; |
|---|
| 481 |
|
|---|
| 482 |
$failureMap = array(); |
|---|
| 483 |
|
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
// were passed to this object by their coresponding set |
|---|
| 487 |
// method. This object relates to these object(s) by a |
|---|
| 488 |
// foreign key reference. |
|---|
| 489 |
|
|---|
| 490 |
if ($this->aSnippetUser !== null) { |
|---|
| 491 |
if (!$this->aSnippetUser->validate($columns)) { |
|---|
| 492 |
$failureMap = array_merge($failureMap, $this->aSnippetUser->getValidationFailures()); |
|---|
| 493 |
} |
|---|
| 494 |
} |
|---|
| 495 |
|
|---|
| 496 |
if ($this->aSnippetSnippet !== null) { |
|---|
| 497 |
if (!$this->aSnippetSnippet->validate($columns)) { |
|---|
| 498 |
$failureMap = array_merge($failureMap, $this->aSnippetSnippet->getValidationFailures()); |
|---|
| 499 |
} |
|---|
| 500 |
} |
|---|
| 501 |
|
|---|
| 502 |
|
|---|
| 503 |
if (($retval = SnippetTagPeer::doValidate($this, $columns)) !== true) { |
|---|
| 504 |
$failureMap = array_merge($failureMap, $retval); |
|---|
| 505 |
} |
|---|
| 506 |
|
|---|
| 507 |
|
|---|
| 508 |
|
|---|
| 509 |
$this->alreadyInValidation = false; |
|---|
| 510 |
} |
|---|
| 511 |
|
|---|
| 512 |
return (!empty($failureMap) ? $failureMap : true); |
|---|
| 513 |
} |
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
* Retrieves a field from the object by name passed in as a string. |
|---|
| 517 |
* |
|---|
| 518 |
* @param string $name name |
|---|
| 519 |
* @param string $type The type of fieldname the $name is of: |
|---|
| 520 |
* one of the class type constants TYPE_PHPNAME, |
|---|
| 521 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 522 |
* @return mixed Value of field. |
|---|
| 523 |
*/ |
|---|
| 524 |
public function getByName($name, $type = BasePeer::TYPE_PHPNAME) |
|---|
| 525 |
{ |
|---|
| 526 |
$pos = SnippetTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); |
|---|
| 527 |
return $this->getByPosition($pos); |
|---|
| 528 |
} |
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
* Retrieves a field from the object by Position as specified in the xml schema. |
|---|
| 532 |
* Zero-based. |
|---|
| 533 |
* |
|---|
| 534 |
* @param int $pos position in xml schema |
|---|
| 535 |
* @return mixed Value of field at $pos |
|---|
| 536 |
*/ |
|---|
| 537 |
public function getByPosition($pos) |
|---|
| 538 |
{ |
|---|
| 539 |
switch($pos) { |
|---|
| 540 |
case 0: |
|---|
| 541 |
return $this->getId(); |
|---|
| 542 |
break; |
|---|
| 543 |
case 1: |
|---|
| 544 |
return $this->getUserId(); |
|---|
| 545 |
break; |
|---|
| 546 |
case 2: |
|---|
| 547 |
return $this->getSnippetId(); |
|---|
| 548 |
break; |
|---|
| 549 |
case 3: |
|---|
| 550 |
return $this->getName(); |
|---|
| 551 |
break; |
|---|
| 552 |
case 4: |
|---|
| 553 |
return $this->getCreatedAt(); |
|---|
| 554 |
break; |
|---|
| 555 |
default: |
|---|
| 556 |
return null; |
|---|
| 557 |
break; |
|---|
| 558 |
} |
|---|
| 559 |
} |
|---|
| 560 |
|
|---|
| 561 |
|
|---|
| 562 |
* Exports the object as an array. |
|---|
| 563 |
* |
|---|
| 564 |
* You can specify the key type of the array by passing one of the class |
|---|
| 565 |
* type constants. |
|---|
| 566 |
* |
|---|
| 567 |
* @param string $keyType One of the class type constants TYPE_PHPNAME, |
|---|
| 568 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 569 |
* @return an associative array containing the field names (as keys) and field values |
|---|
| 570 |
*/ |
|---|
| 571 |
public function toArray($keyType = BasePeer::TYPE_PHPNAME) |
|---|
| 572 |
{ |
|---|
| 573 |
$keys = SnippetTagPeer::getFieldNames($keyType); |
|---|
| 574 |
$result = array( |
|---|
| 575 |
$keys[0] => $this->getId(), |
|---|
| 576 |
$keys[1] => $this->getUserId(), |
|---|
| 577 |
$keys[2] => $this->getSnippetId(), |
|---|
| 578 |
$keys[3] => $this->getName(), |
|---|
| 579 |
$keys[4] => $this->getCreatedAt(), |
|---|
| 580 |
); |
|---|
| 581 |
return $result; |
|---|
| 582 |
} |
|---|
| 583 |
|
|---|
| 584 |
|
|---|
| 585 |
* Sets a field from the object by name passed in as a string. |
|---|
| 586 |
* |
|---|
| 587 |
* @param string $name peer name |
|---|
| 588 |
* @param mixed $value field value |
|---|
| 589 |
* @param string $type The type of fieldname the $name is of: |
|---|
| 590 |
* one of the class type constants TYPE_PHPNAME, |
|---|
| 591 |
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM |
|---|
| 592 |
* @return void |
|---|
| 593 |
*/ |
|---|
| 594 |
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) |
|---|
| 595 |
{ |
|---|
| 596 |
$pos = SnippetTagPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); |
|---|
| 597 |
return $this->setByPosition($pos, $value); |
|---|
| 598 |
} |
|---|
| 599 |
|
|---|
| 600 |
|
|---|
| 601 |
* Sets a field from the object by Position as specified in the xml schema. |
|---|
| 602 |
* Zero-based. |
|---|
| 603 |
* |
|---|
| 604 |
* @param int $pos position in xml schema |
|---|
| 605 |
* @param mixed $value field value |
|---|
| 606 |
* @return void |
|---|
| 607 |
*/ |
|---|
| 608 |
public function setByPosition($pos, $value) |
|---|
| 609 |
{ |
|---|
| 610 |
switch($pos) { |
|---|
| 611 |
case 0: |
|---|
| 612 |
$this->setId($value); |
|---|
| 613 |
break; |
|---|
| 614 |
case 1: |
|---|
| 615 |
$this->setUserId($value); |
|---|
| 616 |
break; |
|---|
| 617 |
case 2: |
|---|
| 618 |
$this->setSnippetId($value); |
|---|
| 619 |
break; |
|---|
| 620 |
case 3: |
|---|
| 621 |
$this->setName($value); |
|---|
| 622 |
break; |
|---|
| 623 |
case 4: |
|---|
| 624 |
$this->setCreatedAt($value); |
|---|
| 625 |
break; |
|---|
| 626 |
} |
|---|
| 627 |
} |
|---|
| 628 |
|
|---|
| 629 |
|
|---|
| 630 |
* Populates the object using an array. |
|---|
| 631 |
* |
|---|
| 632 |
* This is particularly useful when populating an object from one of the |
|---|
| 633 |
* request arrays (e.g. $_POST). This method goes through the column |
|---|
| 634 |
* names, checking to see whether a matching key exists in populated |
|---|
| 635 |
* array. If so the setByName() method is called for that column. |
|---|
| 636 |
* |
|---|
| 637 |
* You can specify the key type of the array by additionally passing one |
|---|
| 638 |
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, |
|---|
| 639 |
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId') |
|---|
| 640 |
* |
|---|
| 641 |
* @param array $arr An array to populate the object from. |
|---|
| 642 |
* @param string $keyType The type of keys the array uses. |
|---|
| 643 |
* @return void |
|---|
| 644 |
*/ |
|---|
| 645 |
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) |
|---|
| 646 |
{ |
|---|
| 647 |
$keys = SnippetTagPeer::getFieldNames($keyType); |
|---|
| 648 |
|
|---|
| 649 |
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); |
|---|
| 650 |
if (array_key_exists($keys[1], $arr)) $this->setUserId($arr[$keys[1]]); |
|---|
| 651 |
if (array_key_exists($keys[2], $arr)) $this->setSnippetId($arr[$keys[2]]); |
|---|
| 652 |
if (array_key_exists($keys[3], $arr)) $this->setName($arr[$keys[3]]); |
|---|
| 653 |
if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); |
|---|
| 654 |
} |
|---|
| 655 |
|
|---|
| 656 |
|
|---|
| 657 |
* Build a Criteria object containing the values of all modified columns in this object. |
|---|
| 658 |
* |
|---|
| 659 |
* @return Criteria The Criteria object containing all modified values. |
|---|
| 660 |
*/ |
|---|
| 661 |
public function buildCriteria() |
|---|
| 662 |
{ |
|---|
| 663 |
$criteria = new Criteria(SnippetTagPeer::DATABASE_NAME); |
|---|
| 664 |
|
|---|
| 665 |
if ($this->isColumnModified(SnippetTagPeer::ID)) $criteria->add(SnippetTagPeer::ID, $this->id); |
|---|
| 666 |
if ($this->isColumnModified(SnippetTagPeer::USER_ID)) $criteria->add(SnippetTagPeer::USER_ID, $this->user_id); |
|---|
| 667 |
if ($this->isColumnModified(SnippetTagPeer::SNIPPET_ID)) $criteria->add(SnippetTagPeer::SNIPPET_ID, $this->snippet_id); |
|---|
| 668 |
if ($this->isColumnModified(SnippetTagPeer::NAME)) $criteria->add(SnippetTagPeer::NAME, $this->name); |
|---|
| 669 |
if ($this->isColumnModified(SnippetTagPeer::CREATED_AT)) $criteria->add(SnippetTagPeer::CREATED_AT, $this->created_at); |
|---|
| 670 |
|
|---|
| 671 |
return $criteria; |
|---|
| 672 |
} |
|---|
| 673 |
|
|---|
| 674 |
|
|---|
| 675 |
* Builds a Criteria object containing the primary key for this object. |
|---|
| 676 |
* |
|---|
| 677 |
* Unlike buildCriteria() this method includes the primary key values regardless |
|---|
| 678 |
* of whether or not they have been modified. |
|---|
| 679 |
* |
|---|
| 680 |
* @return Criteria The Criteria object containing value(s) for primary key(s). |
|---|
| 681 |
*/ |
|---|
| 682 |
public function buildPkeyCriteria() |
|---|
| 683 |
{ |
|---|
| 684 |
$criteria = new Criteria(SnippetTagPeer::DATABASE_NAME); |
|---|
| 685 |
|
|---|
| 686 |
$criteria->add(SnippetTagPeer::ID, $this->id); |
|---|
| 687 |
|
|---|
| 688 |
return $criteria; |
|---|
| 689 |
} |
|---|
| 690 |
|
|---|
| 691 |
|
|---|
| 692 |
* Returns the primary key for this object (row). |
|---|
| 693 |
* @return int |
|---|
| 694 |
*/ |
|---|
| 695 |
public function getPrimaryKey() |
|---|
| 696 |
{ |
|---|
| 697 |
return $this->getId(); |
|---|
| 698 |
} |
|---|
| 699 |
|
|---|
| 700 |
|
|---|
| 701 |
* Generic method to set the primary key (id column). |
|---|
| 702 |
* |
|---|
| 703 |
* @param int $key Primary key. |
|---|
| 704 |
* @return void |
|---|
| 705 |
*/ |
|---|
| 706 |
public function setPrimaryKey($key) |
|---|
| 707 |
{ |
|---|
| 708 |
$this->setId($key); |
|---|
| 709 |
} |
|---|
| 710 |
|
|---|
| 711 |
|
|---|
| 712 |
* Sets contents of passed object to values from current object. |
|---|
| 713 |
* |
|---|
| 714 |
* If desired, this method can also make copies of all associated (fkey referrers) |
|---|
| 715 |
* objects. |
|---|
| 716 |
* |
|---|
| 717 |
* @param object $copyObj An object of SnippetTag (or compatible) type. |
|---|
| 718 |
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|---|
| 719 |
* @throws PropelException |
|---|
| 720 |
*/ |
|---|
| 721 |
public function copyInto($copyObj, $deepCopy = false) |
|---|
| 722 |
{ |
|---|
| 723 |
|
|---|
| 724 |
$copyObj->setUserId($this->user_id); |
|---|
| 725 |
|
|---|
| 726 |
$copyObj->setSnippetId($this->snippet_id); |
|---|
| 727 |
|
|---|
| 728 |
$copyObj->setName($this->name); |
|---|
| 729 |
|
|---|
| 730 |
$copyObj->setCreatedAt($this->created_at); |
|---|
| 731 |
|
|---|
| 732 |
|
|---|
| 733 |
$copyObj->setNew(true); |
|---|
| 734 |
|
|---|
| 735 |
$copyObj->setId(NULL); |
|---|
| 736 |
|
|---|
| 737 |
} |
|---|
| 738 |
|
|---|
| 739 |
|
|---|
| 740 |
* Makes a copy of this object that will be inserted as a new row in table when saved. |
|---|
| 741 |
* It creates a new object filling in the simple attributes, but skipping any primary |
|---|
| 742 |
* keys that are defined for the table. |
|---|
| 743 |
* |
|---|
| 744 |
* If desired, this method can also make copies of all associated (fkey referrers) |
|---|
| 745 |
* objects. |
|---|
| 746 |
* |
|---|
| 747 |
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
|---|
| 748 |
* @return SnippetTag Clone of current object. |
|---|
| 749 |
* @throws PropelException |
|---|
| 750 |
*/ |
|---|
| 751 |
public function copy($deepCopy = false) |
|---|
| 752 |
{ |
|---|
| 753 |
|
|---|
| 754 |
$clazz = get_class($this); |
|---|
| 755 |
$copyObj = new $clazz(); |
|---|
| 756 |
$this->copyInto($copyObj, $deepCopy); |
|---|
| 757 |
return $copyObj; |
|---|
| 758 |
} |
|---|
| 759 |
|
|---|
| 760 |
|
|---|
| 761 |
* Returns a peer instance associated with this om. |
|---|
| 762 |
* |
|---|
| 763 |
* Since Peer classes are not to have any instance attributes, this method returns the |
|---|
| 764 |
* same instance for all member of this class. The method could therefore |
|---|
| 765 |
* be static, but this would prevent one from overriding the behavior. |
|---|
| 766 |
* |
|---|
| 767 |
* @return SnippetTagPeer |
|---|
| 768 |
*/ |
|---|
| 769 |
public function getPeer() |
|---|
| 770 |
{ |
|---|
| 771 |
if (self::$peer === null) { |
|---|
| 772 |
self::$peer = new SnippetTagPeer(); |
|---|
| 773 |
} |
|---|
| 774 |
return self::$peer; |
|---|
| 775 |
} |
|---|
| 776 |
|
|---|
| 777 |
|
|---|
| 778 |
* Declares an association between this object and a SnippetUser object. |
|---|
| 779 |
* |
|---|
| 780 |
* @param SnippetUser $v |
|---|
| 781 |
* @return void |
|---|
| 782 |
* @throws PropelException |
|---|
| 783 |
*/ |
|---|
| 784 |
public function setSnippetUser($v) |
|---|
| 785 |
{ |
|---|
| 786 |
|
|---|
| 787 |
|
|---|
| 788 |
if ($v === null) { |
|---|
| 789 |
$this->setUserId(NULL); |
|---|
| 790 |
} else { |
|---|
| 791 |
$this->setUserId($v->getId()); |
|---|
| 792 |
} |
|---|
| 793 |
|
|---|
| 794 |
|
|---|
| 795 |
$this->aSnippetUser = $v; |
|---|
| 796 |
} |
|---|
| 797 |
|
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 |
* Get the associated SnippetUser object |
|---|
| 801 |
* |
|---|
| 802 |
* @param Connection Optional Connection object. |
|---|
| 803 |
* @return SnippetUser The associated SnippetUser object. |
|---|
| 804 |
* @throws PropelException |
|---|
| 805 |
*/ |
|---|
| 806 |
public function getSnippetUser($con = null) |
|---|
| 807 |
{ |
|---|
| 808 |
|
|---|
| 809 |
include_once 'model/om/BaseSnippetUserPeer.php'; |
|---|
| 810 |
|
|---|
| 811 |
if ($this->aSnippetUser === null && ($this->user_id !== null)) { |
|---|
| 812 |
|
|---|
| 813 |
$this->aSnippetUser = SnippetUserPeer::retrieveByPK($this->user_id, $con); |
|---|
| 814 |
|
|---|
| 815 |
|
|---|
| 816 |
guarantee the related object contains a reference |
|---|
| 817 |
to this object, but this level of coupling |
|---|
| 818 |
may be undesirable in many circumstances. |
|---|
| 819 |
As it can lead to a db query with many results that may |
|---|
| 820 |
never be used. |
|---|
| 821 |
$obj = SnippetUserPeer::retrieveByPK($this->user_id, $con); |
|---|
| 822 |
$obj->addSnippetUsers($this); |
|---|
| 823 |
*/ |
|---|
| 824 |
} |
|---|
| 825 |
return $this->aSnippetUser; |
|---|
| 826 |
} |
|---|
| 827 |
|
|---|
| 828 |
|
|---|
| 829 |
* Declares an association between this object and a SnippetSnippet object. |
|---|
| 830 |
* |
|---|
| 831 |
* @param SnippetSnippet $v |
|---|
| 832 |
* @return void |
|---|
| 833 |
* @throws PropelException |
|---|
| 834 |
*/ |
|---|
| 835 |
public function setSnippetSnippet($v) |
|---|
| 836 |
{ |
|---|
| 837 |
|
|---|
| 838 |
|
|---|
| 839 |
if ($v === null) { |
|---|
| 840 |
$this->setSnippetId(NULL); |
|---|
| 841 |
} else { |
|---|
| 842 |
$this->setSnippetId($v->getId()); |
|---|
| 843 |
} |
|---|
| 844 |
|
|---|
| 845 |
|
|---|
| 846 |
$this->aSnippetSnippet = $v; |
|---|
| 847 |
} |
|---|
| 848 |
|
|---|
| 849 |
|
|---|
| 850 |
|
|---|
| 851 |
* Get the associated SnippetSnippet object |
|---|
| 852 |
* |
|---|
| 853 |
* @param Connection Optional Connection object. |
|---|
| 854 |
* @return SnippetSnippet The associated SnippetSnippet object. |
|---|
| 855 |
* @throws PropelException |
|---|
| 856 |
*/ |
|---|
| 857 |
public function getSnippetSnippet($con = null) |
|---|
| 858 |
{ |
|---|
| 859 |
|
|---|
| 860 |
include_once 'model/om/BaseSnippetSnippetPeer.php'; |
|---|
| 861 |
|
|---|
| 862 |
if ($this->aSnippetSnippet === null && ($this->snippet_id !== null)) { |
|---|
| 863 |
|
|---|
| 864 |
$this->aSnippetSnippet = SnippetSnippetPeer::retrieveByPK($this->snippet_id, $con); |
|---|
| 865 |
|
|---|
| 866 |
|
|---|
| 867 |
guarantee the related object contains a reference |
|---|
| 868 |
to this object, but this level of coupling |
|---|
| 869 |
may be undesirable in many circumstances. |
|---|
| 870 |
As it can lead to a db query with many results that may |
|---|
| 871 |
never be used. |
|---|
| 872 |
$obj = SnippetSnippetPeer::retrieveByPK($this->snippet_id, $con); |
|---|
| 873 |
$obj->addSnippetSnippets($this); |
|---|
| 874 |
*/ |
|---|
| 875 |
} |
|---|
| 876 |
return $this->aSnippetSnippet; |
|---|
| 877 |
} |
|---|
| 878 |
|
|---|
| 879 |
} |
|---|
| 880 |
|
|---|