public function load($keys = null, $reset = true)
    {
        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'conditions' => &$keys,
                'reset' => &$reset,
            ]
        );

        if ($reset) {
            $this->reset();
        }

        // If keys empty, use inner values as keys.
        if (empty($keys)) {
            $empty = true;
            $keys = [];

            // If empty, use the value of the current key
            foreach ($this->keys as $key) {
                $empty = $empty && empty($this->$key);
                $keys[$key] = $this->$key;
            }

            // If empty primary key there's is no need to load anything
            if ($empty) {
                return $this;
            }
        }

        $result = $this->getDataMapper()->findOne($keys);

        // Check that we have a result.
        if ($result->isNull()) {
            throw new NoResultException('No result.');
        }

        // Bind the object with the row and return.
        $row = $this->bind($result);

        // Event
        $this->triggerEvent(
            'onAfter' . ucfirst(__FUNCTION__),
            [
                'result' => &$row,
            ]
        );

        return $row;
    }
public function load($keys = null, $reset = true)
    {
        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'conditions' => &$keys,
                'reset' => &$reset,
            ]
        );

        if ($reset) {
            $this->reset();
        }

        // If keys empty, use inner values as keys.
        if (empty($keys)) {
            $empty = true;
            $keys = [];

            // If empty, use the value of the current key
            foreach ($this->keys as $key) {
                $empty = $empty && empty($this->$key);
                $keys[$key] = $this->$key;
            }

            // If empty primary key there's is no need to load anything
            if ($empty) {
                return $this;
            }
        }

        $result = $this->getDataMapper()->findOne($keys);

        // Check that we have a result.
        if ($result->isNull()) {
            throw new NoResultException('No result.');
        }

        // Bind the object with the row and return.
        $row = $this->bind($result);

        // Event
        $this->triggerEvent(
            'onAfter' . ucfirst(__FUNCTION__),
            [
                'result' => &$row,
            ]
        );

        return $row;
    }
public function load ( $ keys = null , $ reset = true ) { // Event $ this -> triggerEvent ( 'onBefore' . ucfirst ( __FUNCTION__ ) , [ 'conditions' => & $ keys , 'reset' => & $ reset , ] ) ; if ( $ reset ) { $ this -> reset ( ) ; } // If keys empty, use inner values as keys. if ( empty ( $ keys ) ) { $ empty = true ; $ keys = [ ] ; // If empty, use the value of the current key foreach ( $ this -> keys as $ key ) { $ empty = $ empty && empty ( $ this -> $ key ) ; $ keys [ $ key ] = $ this -> $ key ; } // If empty primary key there's is no need to load anything if ( $ empty ) { return $ this ; } } $ result = $ this -> getDataMapper ( ) -> findOne ( $ keys ) ; // Check that we have a result. if ( $ result -> isNull ( ) ) { throw new NoResultException ( 'No result.' ) ; } // Bind the object with the row and return. $ row = $ this -> bind ( $ result ) ; // Event $ this -> triggerEvent ( 'onAfter' . ucfirst ( __FUNCTION__ ) , [ 'result' => & $ row , ] ) ; return $ row ; }
Method to load a row from the database by primary key and bind the fields
to the AbstractTable instance properties.

@param   mixed   $keys    An optional primary key value to load the row by, or an array of fields to match.  If
not set the instance property value is used.
@param   boolean $reset   True to reset the default values before loading the new row.

@return  static  Method allows chaining
@throws \Exception
@since   2.0
Method to load a row from the database by primary key and bind the fields to the AbstractTable instance properties .