Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Record often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Record, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 33 | abstract class Record implements ActiveRecordInterface |
||
| 34 | { |
||
| 35 | /** |
||
| 36 | * TableMap class name |
||
| 37 | */ |
||
| 38 | const TABLE_MAP = '\\eXpansion\\Bundle\\LocalRecords\\Model\\Map\\RecordTableMap'; |
||
| 39 | |||
| 40 | |||
| 41 | /** |
||
| 42 | * attribute to determine if this object has previously been saved. |
||
| 43 | * @var boolean |
||
| 44 | */ |
||
| 45 | protected $new = true; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * attribute to determine whether this object has been deleted. |
||
| 49 | * @var boolean |
||
| 50 | */ |
||
| 51 | protected $deleted = false; |
||
| 52 | |||
| 53 | /** |
||
| 54 | * The columns that have been modified in current object. |
||
| 55 | * Tracking modified columns allows us to only update modified columns. |
||
| 56 | * @var array |
||
| 57 | */ |
||
| 58 | protected $modifiedColumns = array(); |
||
| 59 | |||
| 60 | /** |
||
| 61 | * The (virtual) columns that are added at runtime |
||
| 62 | * The formatters can add supplementary columns based on a resultset |
||
| 63 | * @var array |
||
| 64 | */ |
||
| 65 | protected $virtualColumns = array(); |
||
| 66 | |||
| 67 | /** |
||
| 68 | * The value for the id field. |
||
| 69 | * |
||
| 70 | * @var int |
||
| 71 | */ |
||
| 72 | protected $id; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * The value for the mapuid field. |
||
| 76 | * |
||
| 77 | * @var string |
||
| 78 | */ |
||
| 79 | protected $mapuid; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * The value for the nblaps field. |
||
| 83 | * |
||
| 84 | * @var int |
||
| 85 | */ |
||
| 86 | protected $nblaps; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * The value for the score field. |
||
| 90 | * |
||
| 91 | * @var int |
||
| 92 | */ |
||
| 93 | protected $score; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * The value for the nbfinish field. |
||
| 97 | * |
||
| 98 | * @var int |
||
| 99 | */ |
||
| 100 | protected $nbfinish; |
||
| 101 | |||
| 102 | /** |
||
| 103 | * The value for the avgscore field. |
||
| 104 | * |
||
| 105 | * @var int |
||
| 106 | */ |
||
| 107 | protected $avgscore; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * The value for the checkpoints field. |
||
| 111 | * |
||
| 112 | * @var string |
||
| 113 | */ |
||
| 114 | protected $checkpoints; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * The value for the player_id field. |
||
| 118 | * |
||
| 119 | * @var int |
||
| 120 | */ |
||
| 121 | protected $player_id; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * The value for the created_at field. |
||
| 125 | * |
||
| 126 | * @var DateTime |
||
| 127 | */ |
||
| 128 | protected $created_at; |
||
| 129 | |||
| 130 | /** |
||
| 131 | * The value for the updated_at field. |
||
| 132 | * |
||
| 133 | * @var DateTime |
||
| 134 | */ |
||
| 135 | protected $updated_at; |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @var Player |
||
| 139 | */ |
||
| 140 | protected $aPlayer; |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Flag to prevent endless save loop, if this object is referenced |
||
| 144 | * by another object which falls in this transaction. |
||
| 145 | * |
||
| 146 | * @var boolean |
||
| 147 | */ |
||
| 148 | protected $alreadyInSave = false; |
||
| 149 | |||
| 150 | /** |
||
| 151 | * Initializes internal state of eXpansion\Bundle\LocalRecords\Model\Base\Record object. |
||
| 152 | */ |
||
| 153 | public function __construct() |
||
| 156 | |||
| 157 | /** |
||
| 158 | * Returns whether the object has been modified. |
||
| 159 | * |
||
| 160 | * @return boolean True if the object has been modified. |
||
| 161 | */ |
||
| 162 | public function isModified() |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Has specified column been modified? |
||
| 169 | * |
||
| 170 | * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID |
||
| 171 | * @return boolean True if $col has been modified. |
||
| 172 | */ |
||
| 173 | public function isColumnModified($col) |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Get the columns that have been modified in this object. |
||
| 180 | * @return array A unique list of the modified column names for this object. |
||
| 181 | */ |
||
| 182 | public function getModifiedColumns() |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Returns whether the object has ever been saved. This will |
||
| 189 | * be false, if the object was retrieved from storage or was created |
||
| 190 | * and then saved. |
||
| 191 | * |
||
| 192 | * @return boolean true, if the object has never been persisted. |
||
| 193 | */ |
||
| 194 | public function isNew() |
||
| 198 | |||
| 199 | /** |
||
| 200 | * Setter for the isNew attribute. This method will be called |
||
| 201 | * by Propel-generated children and objects. |
||
| 202 | * |
||
| 203 | * @param boolean $b the state of the object. |
||
| 204 | */ |
||
| 205 | public function setNew($b) |
||
| 209 | |||
| 210 | /** |
||
| 211 | * Whether this object has been deleted. |
||
| 212 | * @return boolean The deleted state of this object. |
||
| 213 | */ |
||
| 214 | public function isDeleted() |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Specify whether this object has been deleted. |
||
| 221 | * @param boolean $b The deleted state of this object. |
||
| 222 | * @return void |
||
| 223 | */ |
||
| 224 | public function setDeleted($b) |
||
| 228 | |||
| 229 | /** |
||
| 230 | * Sets the modified state for the object to be false. |
||
| 231 | * @param string $col If supplied, only the specified column is reset. |
||
| 232 | * @return void |
||
| 233 | */ |
||
| 234 | View Code Duplication | public function resetModified($col = null) |
|
| 244 | |||
| 245 | /** |
||
| 246 | * Compares this with another <code>Record</code> instance. If |
||
| 247 | * <code>obj</code> is an instance of <code>Record</code>, delegates to |
||
| 248 | * <code>equals(Record)</code>. Otherwise, returns <code>false</code>. |
||
| 249 | * |
||
| 250 | * @param mixed $obj The object to compare to. |
||
| 251 | * @return boolean Whether equal to the object specified. |
||
| 252 | */ |
||
| 253 | View Code Duplication | public function equals($obj) |
|
| 269 | |||
| 270 | /** |
||
| 271 | * Get the associative array of the virtual columns in this object |
||
| 272 | * |
||
| 273 | * @return array |
||
| 274 | */ |
||
| 275 | public function getVirtualColumns() |
||
| 279 | |||
| 280 | /** |
||
| 281 | * Checks the existence of a virtual column in this object |
||
| 282 | * |
||
| 283 | * @param string $name The virtual column name |
||
| 284 | * @return boolean |
||
| 285 | */ |
||
| 286 | public function hasVirtualColumn($name) |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Get the value of a virtual column in this object |
||
| 293 | * |
||
| 294 | * @param string $name The virtual column name |
||
| 295 | * @return mixed |
||
| 296 | * |
||
| 297 | * @throws PropelException |
||
| 298 | */ |
||
| 299 | View Code Duplication | public function getVirtualColumn($name) |
|
| 307 | |||
| 308 | /** |
||
| 309 | * Set the value of a virtual column in this object |
||
| 310 | * |
||
| 311 | * @param string $name The virtual column name |
||
| 312 | * @param mixed $value The value to give to the virtual column |
||
| 313 | * |
||
| 314 | * @return $this|Record The current object, for fluid interface |
||
| 315 | */ |
||
| 316 | public function setVirtualColumn($name, $value) |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Logs a message using Propel::log(). |
||
| 325 | * |
||
| 326 | * @param string $msg |
||
| 327 | * @param int $priority One of the Propel::LOG_* logging levels |
||
| 328 | * @return boolean |
||
| 329 | */ |
||
| 330 | protected function log($msg, $priority = Propel::LOG_INFO) |
||
| 334 | |||
| 335 | /** |
||
| 336 | * Export the current object properties to a string, using a given parser format |
||
| 337 | * <code> |
||
| 338 | * $book = BookQuery::create()->findPk(9012); |
||
| 339 | * echo $book->exportTo('JSON'); |
||
| 340 | * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 341 | * </code> |
||
| 342 | * |
||
| 343 | * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 344 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. |
||
| 345 | * @return string The exported data |
||
| 346 | */ |
||
| 347 | View Code Duplication | public function exportTo($parser, $includeLazyLoadColumns = true) |
|
| 355 | |||
| 356 | /** |
||
| 357 | * Clean up internal collections prior to serializing |
||
| 358 | * Avoids recursive loops that turn into segmentation faults when serializing |
||
| 359 | */ |
||
| 360 | View Code Duplication | public function __sleep() |
|
| 374 | |||
| 375 | /** |
||
| 376 | * Get the [id] column value. |
||
| 377 | * |
||
| 378 | * @return int |
||
| 379 | */ |
||
| 380 | public function getId() |
||
| 384 | |||
| 385 | /** |
||
| 386 | * Get the [mapuid] column value. |
||
| 387 | * |
||
| 388 | * @return string |
||
| 389 | */ |
||
| 390 | public function getMapuid() |
||
| 394 | |||
| 395 | /** |
||
| 396 | * Get the [nblaps] column value. |
||
| 397 | * |
||
| 398 | * @return int |
||
| 399 | */ |
||
| 400 | public function getNblaps() |
||
| 404 | |||
| 405 | /** |
||
| 406 | * Get the [score] column value. |
||
| 407 | * |
||
| 408 | * @return int |
||
| 409 | */ |
||
| 410 | public function getScore() |
||
| 414 | |||
| 415 | /** |
||
| 416 | * Get the [nbfinish] column value. |
||
| 417 | * |
||
| 418 | * @return int |
||
| 419 | */ |
||
| 420 | public function getNbfinish() |
||
| 424 | |||
| 425 | /** |
||
| 426 | * Get the [avgscore] column value. |
||
| 427 | * |
||
| 428 | * @return int |
||
| 429 | */ |
||
| 430 | public function getAvgscore() |
||
| 434 | |||
| 435 | /** |
||
| 436 | * Get the [checkpoints] column value. |
||
| 437 | * |
||
| 438 | * @return string |
||
| 439 | */ |
||
| 440 | public function getCheckpoints() |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Get the [player_id] column value. |
||
| 447 | * |
||
| 448 | * @return int |
||
| 449 | */ |
||
| 450 | public function getPlayerId() |
||
| 454 | |||
| 455 | /** |
||
| 456 | * Get the [optionally formatted] temporal [created_at] 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, and 0 if column value is 0000-00-00 00:00:00 |
||
| 463 | * |
||
| 464 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 465 | */ |
||
| 466 | public function getCreatedAt($format = NULL) |
||
| 474 | |||
| 475 | /** |
||
| 476 | * Get the [optionally formatted] temporal [updated_at] 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, and 0 if column value is 0000-00-00 00:00:00 |
||
| 483 | * |
||
| 484 | * @throws PropelException - if unable to parse/validate the date/time value. |
||
| 485 | */ |
||
| 486 | public function getUpdatedAt($format = NULL) |
||
| 494 | |||
| 495 | /** |
||
| 496 | * Set the value of [id] column. |
||
| 497 | * |
||
| 498 | * @param int $v new value |
||
| 499 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 500 | */ |
||
| 501 | public function setId($v) |
||
| 514 | |||
| 515 | /** |
||
| 516 | * Set the value of [mapuid] column. |
||
| 517 | * |
||
| 518 | * @param string $v new value |
||
| 519 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 520 | */ |
||
| 521 | public function setMapuid($v) |
||
| 534 | |||
| 535 | /** |
||
| 536 | * Set the value of [nblaps] column. |
||
| 537 | * |
||
| 538 | * @param int $v new value |
||
| 539 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 540 | */ |
||
| 541 | public function setNblaps($v) |
||
| 554 | |||
| 555 | /** |
||
| 556 | * Set the value of [score] column. |
||
| 557 | * |
||
| 558 | * @param int $v new value |
||
| 559 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 560 | */ |
||
| 561 | public function setScore($v) |
||
| 574 | |||
| 575 | /** |
||
| 576 | * Set the value of [nbfinish] column. |
||
| 577 | * |
||
| 578 | * @param int $v new value |
||
| 579 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 580 | */ |
||
| 581 | public function setNbfinish($v) |
||
| 594 | |||
| 595 | /** |
||
| 596 | * Set the value of [avgscore] column. |
||
| 597 | * |
||
| 598 | * @param int $v new value |
||
| 599 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 600 | */ |
||
| 601 | public function setAvgscore($v) |
||
| 614 | |||
| 615 | /** |
||
| 616 | * Set the value of [checkpoints] column. |
||
| 617 | * |
||
| 618 | * @param string $v new value |
||
| 619 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 620 | */ |
||
| 621 | public function setCheckpoints($v) |
||
| 634 | |||
| 635 | /** |
||
| 636 | * Set the value of [player_id] column. |
||
| 637 | * |
||
| 638 | * @param int $v new value |
||
| 639 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 640 | */ |
||
| 641 | public function setPlayerId($v) |
||
| 658 | |||
| 659 | /** |
||
| 660 | * Sets the value of [created_at] column to a normalized version of the date/time value specified. |
||
| 661 | * |
||
| 662 | * @param mixed $v string, integer (timestamp), or \DateTimeInterface value. |
||
| 663 | * Empty strings are treated as NULL. |
||
| 664 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 665 | */ |
||
| 666 | View Code Duplication | public function setCreatedAt($v) |
|
| 678 | |||
| 679 | /** |
||
| 680 | * Sets the value of [updated_at] column to a normalized version of the date/time value specified. |
||
| 681 | * |
||
| 682 | * @param mixed $v string, integer (timestamp), or \DateTimeInterface value. |
||
| 683 | * Empty strings are treated as NULL. |
||
| 684 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 685 | */ |
||
| 686 | View Code Duplication | public function setUpdatedAt($v) |
|
| 698 | |||
| 699 | /** |
||
| 700 | * Indicates whether the columns in this object are only set to default values. |
||
| 701 | * |
||
| 702 | * This method can be used in conjunction with isModified() to indicate whether an object is both |
||
| 703 | * modified _and_ has some values set which are non-default. |
||
| 704 | * |
||
| 705 | * @return boolean Whether the columns in this object are only been set with default values. |
||
| 706 | */ |
||
| 707 | public function hasOnlyDefaultValues() |
||
| 712 | |||
| 713 | /** |
||
| 714 | * Hydrates (populates) the object variables with values from the database resultset. |
||
| 715 | * |
||
| 716 | * An offset (0-based "start column") is specified so that objects can be hydrated |
||
| 717 | * with a subset of the columns in the resultset rows. This is needed, for example, |
||
| 718 | * for results of JOIN queries where the resultset row includes columns from two or |
||
| 719 | * more tables. |
||
| 720 | * |
||
| 721 | * @param array $row The row returned by DataFetcher->fetch(). |
||
| 722 | * @param int $startcol 0-based offset column which indicates which restultset column to start with. |
||
| 723 | * @param boolean $rehydrate Whether this object is being re-hydrated from the database. |
||
| 724 | * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). |
||
| 725 | One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 726 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 727 | * |
||
| 728 | * @return int next starting column |
||
| 729 | * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. |
||
| 730 | */ |
||
| 731 | public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) |
||
| 784 | |||
| 785 | /** |
||
| 786 | * Checks and repairs the internal consistency of the object. |
||
| 787 | * |
||
| 788 | * This method is executed after an already-instantiated object is re-hydrated |
||
| 789 | * from the database. It exists to check any foreign keys to make sure that |
||
| 790 | * the objects related to the current object are correct based on foreign key. |
||
| 791 | * |
||
| 792 | * You can override this method in the stub class, but you should always invoke |
||
| 793 | * the base method from the overridden method (i.e. parent::ensureConsistency()), |
||
| 794 | * in case your model changes. |
||
| 795 | * |
||
| 796 | * @throws PropelException |
||
| 797 | */ |
||
| 798 | public function ensureConsistency() |
||
| 804 | |||
| 805 | /** |
||
| 806 | * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. |
||
| 807 | * |
||
| 808 | * This will only work if the object has been saved and has a valid primary key set. |
||
| 809 | * |
||
| 810 | * @param boolean $deep (optional) Whether to also de-associated any related objects. |
||
| 811 | * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. |
||
| 812 | * @return void |
||
| 813 | * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db |
||
| 814 | */ |
||
| 815 | View Code Duplication | public function reload($deep = false, ConnectionInterface $con = null) |
|
| 845 | |||
| 846 | /** |
||
| 847 | * Removes this object from datastore and sets delete attribute. |
||
| 848 | * |
||
| 849 | * @param ConnectionInterface $con |
||
| 850 | * @return void |
||
| 851 | * @throws PropelException |
||
| 852 | * @see Record::setDeleted() |
||
| 853 | * @see Record::isDeleted() |
||
| 854 | */ |
||
| 855 | View Code Duplication | public function delete(ConnectionInterface $con = null) |
|
| 876 | |||
| 877 | /** |
||
| 878 | * Persists this object to the database. |
||
| 879 | * |
||
| 880 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 881 | * All modified related objects will also be persisted in the doSave() |
||
| 882 | * method. This method wraps all precipitate database operations in a |
||
| 883 | * single transaction. |
||
| 884 | * |
||
| 885 | * @param ConnectionInterface $con |
||
| 886 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 887 | * @throws PropelException |
||
| 888 | * @see doSave() |
||
| 889 | */ |
||
| 890 | public function save(ConnectionInterface $con = null) |
||
| 936 | |||
| 937 | /** |
||
| 938 | * Performs the work of inserting or updating the row in the database. |
||
| 939 | * |
||
| 940 | * If the object is new, it inserts it; otherwise an update is performed. |
||
| 941 | * All related objects are also updated in this method. |
||
| 942 | * |
||
| 943 | * @param ConnectionInterface $con |
||
| 944 | * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. |
||
| 945 | * @throws PropelException |
||
| 946 | * @see save() |
||
| 947 | */ |
||
| 948 | protected function doSave(ConnectionInterface $con) |
||
| 983 | |||
| 984 | /** |
||
| 985 | * Insert the row in the database. |
||
| 986 | * |
||
| 987 | * @param ConnectionInterface $con |
||
| 988 | * |
||
| 989 | * @throws PropelException |
||
| 990 | * @see doSave() |
||
| 991 | */ |
||
| 992 | protected function doInsert(ConnectionInterface $con) |
||
| 1091 | |||
| 1092 | /** |
||
| 1093 | * Update the row in the database. |
||
| 1094 | * |
||
| 1095 | * @param ConnectionInterface $con |
||
| 1096 | * |
||
| 1097 | * @return Integer Number of updated rows |
||
| 1098 | * @see doSave() |
||
| 1099 | */ |
||
| 1100 | protected function doUpdate(ConnectionInterface $con) |
||
| 1107 | |||
| 1108 | /** |
||
| 1109 | * Retrieves a field from the object by name passed in as a string. |
||
| 1110 | * |
||
| 1111 | * @param string $name name |
||
| 1112 | * @param string $type The type of fieldname the $name is of: |
||
| 1113 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1114 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1115 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1116 | * @return mixed Value of field. |
||
| 1117 | */ |
||
| 1118 | View Code Duplication | public function getByName($name, $type = TableMap::TYPE_PHPNAME) |
|
| 1125 | |||
| 1126 | /** |
||
| 1127 | * Retrieves a field from the object by Position as specified in the xml schema. |
||
| 1128 | * Zero-based. |
||
| 1129 | * |
||
| 1130 | * @param int $pos position in xml schema |
||
| 1131 | * @return mixed Value of field at $pos |
||
| 1132 | */ |
||
| 1133 | public function getByPosition($pos) |
||
| 1171 | |||
| 1172 | /** |
||
| 1173 | * Exports the object as an array. |
||
| 1174 | * |
||
| 1175 | * You can specify the key type of the array by passing one of the class |
||
| 1176 | * type constants. |
||
| 1177 | * |
||
| 1178 | * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1179 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1180 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1181 | * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. |
||
| 1182 | * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion |
||
| 1183 | * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. |
||
| 1184 | * |
||
| 1185 | * @return array an associative array containing the field names (as keys) and field values |
||
| 1186 | */ |
||
| 1187 | public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) |
||
| 1240 | |||
| 1241 | /** |
||
| 1242 | * Sets a field from the object by name passed in as a string. |
||
| 1243 | * |
||
| 1244 | * @param string $name |
||
| 1245 | * @param mixed $value field value |
||
| 1246 | * @param string $type The type of fieldname the $name is of: |
||
| 1247 | * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME |
||
| 1248 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1249 | * Defaults to TableMap::TYPE_PHPNAME. |
||
| 1250 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record |
||
| 1251 | */ |
||
| 1252 | public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) |
||
| 1258 | |||
| 1259 | /** |
||
| 1260 | * Sets a field from the object by Position as specified in the xml schema. |
||
| 1261 | * Zero-based. |
||
| 1262 | * |
||
| 1263 | * @param int $pos position in xml schema |
||
| 1264 | * @param mixed $value field value |
||
| 1265 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record |
||
| 1266 | */ |
||
| 1267 | public function setByPosition($pos, $value) |
||
| 1304 | |||
| 1305 | /** |
||
| 1306 | * Populates the object using an array. |
||
| 1307 | * |
||
| 1308 | * This is particularly useful when populating an object from one of the |
||
| 1309 | * request arrays (e.g. $_POST). This method goes through the column |
||
| 1310 | * names, checking to see whether a matching key exists in populated |
||
| 1311 | * array. If so the setByName() method is called for that column. |
||
| 1312 | * |
||
| 1313 | * You can specify the key type of the array by additionally passing one |
||
| 1314 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1315 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1316 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1317 | * |
||
| 1318 | * @param array $arr An array to populate the object from. |
||
| 1319 | * @param string $keyType The type of keys the array uses. |
||
| 1320 | * @return void |
||
| 1321 | */ |
||
| 1322 | public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) |
||
| 1357 | |||
| 1358 | /** |
||
| 1359 | * Populate the current object from a string, using a given parser format |
||
| 1360 | * <code> |
||
| 1361 | * $book = new Book(); |
||
| 1362 | * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); |
||
| 1363 | * </code> |
||
| 1364 | * |
||
| 1365 | * You can specify the key type of the array by additionally passing one |
||
| 1366 | * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_CAMELNAME, |
||
| 1367 | * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. |
||
| 1368 | * The default key type is the column's TableMap::TYPE_PHPNAME. |
||
| 1369 | * |
||
| 1370 | * @param mixed $parser A AbstractParser instance, |
||
| 1371 | * or a format name ('XML', 'YAML', 'JSON', 'CSV') |
||
| 1372 | * @param string $data The source data to import from |
||
| 1373 | * @param string $keyType The type of keys the array uses. |
||
| 1374 | * |
||
| 1375 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object, for fluid interface |
||
| 1376 | */ |
||
| 1377 | View Code Duplication | public function importFrom($parser, $data, $keyType = TableMap::TYPE_PHPNAME) |
|
| 1387 | |||
| 1388 | /** |
||
| 1389 | * Build a Criteria object containing the values of all modified columns in this object. |
||
| 1390 | * |
||
| 1391 | * @return Criteria The Criteria object containing all modified values. |
||
| 1392 | */ |
||
| 1393 | public function buildCriteria() |
||
| 1430 | |||
| 1431 | /** |
||
| 1432 | * Builds a Criteria object containing the primary key for this object. |
||
| 1433 | * |
||
| 1434 | * Unlike buildCriteria() this method includes the primary key values regardless |
||
| 1435 | * of whether or not they have been modified. |
||
| 1436 | * |
||
| 1437 | * @throws LogicException if no primary key is defined |
||
| 1438 | * |
||
| 1439 | * @return Criteria The Criteria object containing value(s) for primary key(s). |
||
| 1440 | */ |
||
| 1441 | public function buildPkeyCriteria() |
||
| 1448 | |||
| 1449 | /** |
||
| 1450 | * If the primary key is not null, return the hashcode of the |
||
| 1451 | * primary key. Otherwise, return the hash code of the object. |
||
| 1452 | * |
||
| 1453 | * @return int Hashcode |
||
| 1454 | */ |
||
| 1455 | View Code Duplication | public function hashCode() |
|
| 1470 | |||
| 1471 | /** |
||
| 1472 | * Returns the primary key for this object (row). |
||
| 1473 | * @return int |
||
| 1474 | */ |
||
| 1475 | public function getPrimaryKey() |
||
| 1479 | |||
| 1480 | /** |
||
| 1481 | * Generic method to set the primary key (id column). |
||
| 1482 | * |
||
| 1483 | * @param int $key Primary key. |
||
| 1484 | * @return void |
||
| 1485 | */ |
||
| 1486 | public function setPrimaryKey($key) |
||
| 1490 | |||
| 1491 | /** |
||
| 1492 | * Returns true if the primary key for this object is null. |
||
| 1493 | * @return boolean |
||
| 1494 | */ |
||
| 1495 | public function isPrimaryKeyNull() |
||
| 1499 | |||
| 1500 | /** |
||
| 1501 | * Sets contents of passed object to values from current object. |
||
| 1502 | * |
||
| 1503 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1504 | * objects. |
||
| 1505 | * |
||
| 1506 | * @param object $copyObj An object of \eXpansion\Bundle\LocalRecords\Model\Record (or compatible) type. |
||
| 1507 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1508 | * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. |
||
| 1509 | * @throws PropelException |
||
| 1510 | */ |
||
| 1511 | public function copyInto($copyObj, $deepCopy = false, $makeNew = true) |
||
| 1527 | |||
| 1528 | /** |
||
| 1529 | * Makes a copy of this object that will be inserted as a new row in table when saved. |
||
| 1530 | * It creates a new object filling in the simple attributes, but skipping any primary |
||
| 1531 | * keys that are defined for the table. |
||
| 1532 | * |
||
| 1533 | * If desired, this method can also make copies of all associated (fkey referrers) |
||
| 1534 | * objects. |
||
| 1535 | * |
||
| 1536 | * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. |
||
| 1537 | * @return \eXpansion\Bundle\LocalRecords\Model\Record Clone of current object. |
||
| 1538 | * @throws PropelException |
||
| 1539 | */ |
||
| 1540 | View Code Duplication | public function copy($deepCopy = false) |
|
| 1549 | |||
| 1550 | /** |
||
| 1551 | * Declares an association between this object and a Player object. |
||
| 1552 | * |
||
| 1553 | * @param Player $v |
||
| 1554 | * @return $this|\eXpansion\Bundle\LocalRecords\Model\Record The current object (for fluent API support) |
||
| 1555 | * @throws PropelException |
||
| 1556 | */ |
||
| 1557 | public function setPlayer(Player $v = null) |
||
| 1576 | |||
| 1577 | |||
| 1578 | /** |
||
| 1579 | * Get the associated Player object |
||
| 1580 | * |
||
| 1581 | * @param ConnectionInterface $con Optional Connection object. |
||
| 1582 | * @return Player The associated Player object. |
||
| 1583 | * @throws PropelException |
||
| 1584 | */ |
||
| 1585 | public function getPlayer(ConnectionInterface $con = null) |
||
| 1600 | |||
| 1601 | /** |
||
| 1602 | * Clears the current object, sets all attributes to their default values and removes |
||
| 1603 | * outgoing references as well as back-references (from other objects to this one. Results probably in a database |
||
| 1604 | * change of those foreign objects when you call `save` there). |
||
| 1605 | */ |
||
| 1606 | public function clear() |
||
| 1627 | |||
| 1628 | /** |
||
| 1629 | * Resets all references and back-references to other model objects or collections of model objects. |
||
| 1630 | * |
||
| 1631 | * This method is used to reset all php object references (not the actual reference in the database). |
||
| 1632 | * Necessary for object serialisation. |
||
| 1633 | * |
||
| 1634 | * @param boolean $deep Whether to also clear the references on all referrer objects. |
||
| 1635 | */ |
||
| 1636 | public function clearAllReferences($deep = false) |
||
| 1643 | |||
| 1644 | /** |
||
| 1645 | * Return the string representation of this object |
||
| 1646 | * |
||
| 1647 | * @return string |
||
| 1648 | */ |
||
| 1649 | public function __toString() |
||
| 1653 | |||
| 1654 | // timestampable behavior |
||
| 1655 | |||
| 1656 | /** |
||
| 1657 | * Mark the current object so that the update date doesn't get updated during next save |
||
| 1658 | * |
||
| 1659 | * @return $this|ChildRecord The current object (for fluent API support) |
||
| 1660 | */ |
||
| 1661 | public function keepUpdateDateUnchanged() |
||
| 1667 | |||
| 1668 | /** |
||
| 1669 | * Code to be run before persisting the object |
||
| 1670 | * @param ConnectionInterface $con |
||
| 1671 | * @return boolean |
||
| 1672 | */ |
||
| 1673 | public function preSave(ConnectionInterface $con = null) |
||
| 1680 | |||
| 1681 | /** |
||
| 1682 | * Code to be run after persisting the object |
||
| 1683 | * @param ConnectionInterface $con |
||
| 1684 | */ |
||
| 1685 | public function postSave(ConnectionInterface $con = null) |
||
| 1691 | |||
| 1692 | /** |
||
| 1693 | * Code to be run before inserting to database |
||
| 1694 | * @param ConnectionInterface $con |
||
| 1695 | * @return boolean |
||
| 1696 | */ |
||
| 1697 | public function preInsert(ConnectionInterface $con = null) |
||
| 1704 | |||
| 1705 | /** |
||
| 1706 | * Code to be run after inserting to database |
||
| 1707 | * @param ConnectionInterface $con |
||
| 1708 | */ |
||
| 1709 | public function postInsert(ConnectionInterface $con = null) |
||
| 1715 | |||
| 1716 | /** |
||
| 1717 | * Code to be run before updating the object in database |
||
| 1718 | * @param ConnectionInterface $con |
||
| 1719 | * @return boolean |
||
| 1720 | */ |
||
| 1721 | public function preUpdate(ConnectionInterface $con = null) |
||
| 1728 | |||
| 1729 | /** |
||
| 1730 | * Code to be run after updating the object in database |
||
| 1731 | * @param ConnectionInterface $con |
||
| 1732 | */ |
||
| 1733 | public function postUpdate(ConnectionInterface $con = null) |
||
| 1739 | |||
| 1740 | /** |
||
| 1741 | * Code to be run before deleting the object in database |
||
| 1742 | * @param ConnectionInterface $con |
||
| 1743 | * @return boolean |
||
| 1744 | */ |
||
| 1745 | public function preDelete(ConnectionInterface $con = null) |
||
| 1752 | |||
| 1753 | /** |
||
| 1754 | * Code to be run after deleting the object in database |
||
| 1755 | * @param ConnectionInterface $con |
||
| 1756 | */ |
||
| 1757 | public function postDelete(ConnectionInterface $con = null) |
||
| 1763 | |||
| 1764 | |||
| 1765 | /** |
||
| 1766 | * Derived method to catches calls to undefined methods. |
||
| 1767 | * |
||
| 1768 | * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). |
||
| 1769 | * Allows to define default __call() behavior if you overwrite __call() |
||
| 1770 | * |
||
| 1771 | * @param string $name |
||
| 1772 | * @param mixed $params |
||
| 1773 | * |
||
| 1774 | * @return array|string |
||
| 1775 | */ |
||
| 1776 | View Code Duplication | public function __call($name, $params) |
|
| 1805 | |||
| 1806 | } |
||
| 1807 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.