示例#1
0
文件: Entity.php 项目: las93/attila
 /**
  * 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();
     }
 }
示例#2
0
文件: Model.php 项目: las93/attila
 /**
  * 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;
 }