/** * Constructor * * @access public * @return object */ public function __construct() { $this->_loadPrimaryKeyName(LibEntity::getPrimaryKeyName($this)); $this->_loadPrimaryKeyNameWithoutMapping(LibEntity::getPrimaryKeyNameWithoutMapping($this)); /** * Trigger on a model to initialize it. You could fill entity with it. */ if (method_exists(get_called_class(), 'initialize')) { if (!isset(self::$_aInitialize[get_called_class()])) { static::initialize(); self::$_aInitialize[get_called_class()] = true; } } /** * Trigger on a model to initialize it every time you construct it */ if (method_exists(get_called_class(), 'onConstruct')) { static::onConstruct(); } }
/** * update Entity and get it * * @access public * @param object $oEntityCriteria * @return mixed */ public function updateAndGet($oEntity) { $sEntityNamespace = preg_replace('/^(.*)Model\\\\.+$/', '$1Entity\\', get_called_class()); $mResult = $this->update($oEntity); if ($result) { $aEntity = get_object_vars(LibEntity::getRealEntity($oEntity)); $mPrimaryKey = LibEntity::getPrimaryKeyName($aEntity); $mResult = $this->orm->select(array('*'))->from($this->_sTableName)->where(array($mPrimaryKey => $aEntity[$mPrimaryKey]))->load(false, $sEntityNamespace); if ($this->_isFilter()) { foreach ($mResult as $iKey => $oValue) { $mResult[$iKey] = $this->_applyFilter($oValue); } } } return $mResult; }