123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <?php
- abstract class BaseObject
- {
-
- protected $_new = true;
-
- protected $_deleted = false;
-
- protected $modifiedColumns = array();
-
-
- protected $virtualColumns = array();
-
-
- public function __construct() {
- }
-
- public function isModified()
- {
- return !empty($this->modifiedColumns);
- }
-
- public function isColumnModified($col)
- {
- return in_array($col, $this->modifiedColumns);
- }
-
- public function getModifiedColumns()
- {
- return array_unique($this->modifiedColumns);
- }
-
- public function isNew()
- {
- return $this->_new;
- }
-
- public function setNew($b)
- {
- $this->_new = (boolean) $b;
- }
-
- public function isDeleted()
- {
- return $this->_deleted;
- }
-
- public function setDeleted($b)
- {
- $this->_deleted = (boolean) $b;
- }
-
- public function preSave(PropelPDO $con = null)
- {
- return true;
- }
-
- public function postSave(PropelPDO $con = null) { }
-
- public function preInsert(PropelPDO $con = null)
- {
- return true;
- }
-
-
- public function postInsert(PropelPDO $con = null) { }
-
- public function preUpdate(PropelPDO $con = null)
- {
- return true;
- }
-
- public function postUpdate(PropelPDO $con = null) { }
-
- public function preDelete(PropelPDO $con = null)
- {
- return true;
- }
-
- public function postDelete(PropelPDO $con = null) { }
-
-
- public function resetModified($col = null)
- {
- if ($col !== null) {
- while (($offset = array_search($col, $this->modifiedColumns)) !== false) {
- array_splice($this->modifiedColumns, $offset, 1);
- }
- } else {
- $this->modifiedColumns = array();
- }
- }
-
- public function equals($obj)
- {
- $thisclazz = get_class($this);
- if (is_object($obj) && $obj instanceof $thisclazz) {
- if ($this === $obj) {
- return true;
- } elseif ($this->getPrimaryKey() === null || $obj->getPrimaryKey() === null) {
- return false;
- } else {
- return ($this->getPrimaryKey() === $obj->getPrimaryKey());
- }
- } else {
- return false;
- }
- }
-
- public function hashCode()
- {
- $ok = $this->getPrimaryKey();
- if ($ok === null) {
- return crc32(serialize($this));
- }
- return crc32(serialize($ok));
- }
-
-
- public function getVirtualColumns()
- {
- return $this->virtualColumns;
- }
-
- public function hasVirtualColumn($name)
- {
- return array_key_exists($name, $this->virtualColumns);
- }
-
-
- public function getVirtualColumn($name)
- {
- if (!$this->hasVirtualColumn($name)) {
- throw new PropelException('Cannot get value of inexistent virtual column ' . $name);
- }
- return $this->virtualColumns[$name];
- }
-
-
- public function setVirtualColumn($name, $value)
- {
- $this->virtualColumns[$name] = $value;
- return $this;
- }
-
- protected function log($msg, $priority = Propel::LOG_INFO)
- {
- return Propel::log(get_class($this) . ': ' . $msg, $priority);
- }
-
-
- public function __sleep()
- {
- $this->clearAllReferences();
- return array_keys(get_object_vars($this));
- }
- }
|