Doctrine_Record::load PHP Méthode

load() public méthode

Used to move a record from PROXY to CLEAN/DIRTY state.
public load ( array $data = [] ) : boolean
$data array overwriting data to load in the record. Instance is hydrated from the table if not specified.
Résultat boolean
    public function load(array $data = array())
    {
        // only load the data from database if the Doctrine_Record is in proxy state
        if ($this->exists() && $this->isInProxyState()) {
            $id = $this->identifier();
            if (!is_array($id)) {
                $id = array($id);
            }
            if (empty($id)) {
                return false;
            }
            $data = empty($data) ? $this->getTable()->find($id, Doctrine_Core::HYDRATE_ARRAY) : $data;
            foreach ($data as $field => $value) {
                if (!array_key_exists($field, $this->_data) || $this->_data[$field] === self::$_null) {
                    $this->_data[$field] = $value;
                }
            }
            if ($this->isModified()) {
                $this->_state = Doctrine_Record::STATE_DIRTY;
            } else {
                if (!$this->isInProxyState()) {
                    $this->_state = Doctrine_Record::STATE_CLEAN;
                }
            }
            return true;
        }
        return false;
    }