public function init($config)
    {
        $this->_initiated = true;
        if ($this->isNewRecord()) {
            $this->_tableName = static::getTableName();
            $this->_db = $this->_db ? $this->_db : static::getDb();
            $this->_columns = static::getDb()->getTableColumns($this->_tableName);
            $this->_pk = static::getDb()->getTablePk($this->_tableName);
        } else {
            if (is_array($this->_pk)) {
                $this->_originalPk = [];
                foreach ($this->_pk as $k) {
                    $this->_originalPk[$k] = $this->_attributes[$k];
                }
            } else {
                $this->_originalPk = $this->_attributes[$this->_pk];
            }
            $this->afterLoad();
        }
        $this->applyRelationsAttributes();
        return parent::init($config);
    }
public function init($config)
    {
        $this->_initiated = true;
        if ($this->isNewRecord()) {
            $this->_tableName = static::getTableName();
            $this->_db = $this->_db ? $this->_db : static::getDb();
            $this->_columns = static::getDb()->getTableColumns($this->_tableName);
            $this->_pk = static::getDb()->getTablePk($this->_tableName);
        } else {
            if (is_array($this->_pk)) {
                $this->_originalPk = [];
                foreach ($this->_pk as $k) {
                    $this->_originalPk[$k] = $this->_attributes[$k];
                }
            } else {
                $this->_originalPk = $this->_attributes[$this->_pk];
            }
            $this->afterLoad();
        }
        $this->applyRelationsAttributes();
        return parent::init($config);
    }
public function init ( $ config ) { $ this -> _initiated = true ; if ( $ this -> isNewRecord ( ) ) { $ this -> _tableName = static :: getTableName ( ) ; $ this -> _db = $ this -> _db ? $ this -> _db : static :: getDb ( ) ; $ this -> _columns = static :: getDb ( ) -> getTableColumns ( $ this -> _tableName ) ; $ this -> _pk = static :: getDb ( ) -> getTablePk ( $ this -> _tableName ) ; } else { if ( is_array ( $ this -> _pk ) ) { $ this -> _originalPk = [ ] ; foreach ( $ this -> _pk as $ k ) { $ this -> _originalPk [ $ k ] = $ this -> _attributes [ $ k ] ; } } else { $ this -> _originalPk = $ this -> _attributes [ $ this -> _pk ] ; } $ this -> afterLoad ( ) ; } $ this -> applyRelationsAttributes ( ) ; return parent :: init ( $ config ) ; }
It will check if it's a new record and set required attributes. Also, if it's not a new record
will record originalPk to be later used for updates.
@param array $config
@return null
It will check if it s a new record and set required attributes . Also if it s not a new record will record originalPk to be later used for updates .