public function tryLoad($id)
    {
        if (!$this->persistence) {
            throw new Exception(['Model is not associated with any database']);
        }

        if (!$this->persistence->hasMethod('tryLoad')) {
            throw new Exception('Persistence does not support tryLoad()');
        }

        if ($this->loaded()) {
            $this->unload();
        }

        $this->data = $this->persistence->tryLoad($this, $id);
        if ($this->data) {
            $this->id = $id;

            $ret = $this->hook('afterLoad');
            if ($ret === false) {
                return $this->unload();
            } elseif (is_object($ret)) {
                return $ret;
            }
        } else {
            $this->unload();
        }

        return $this;
    }
public function tryLoad($id)
    {
        if (!$this->persistence) {
            throw new Exception(['Model is not associated with any database']);
        }

        if (!$this->persistence->hasMethod('tryLoad')) {
            throw new Exception('Persistence does not support tryLoad()');
        }

        if ($this->loaded()) {
            $this->unload();
        }

        $this->data = $this->persistence->tryLoad($this, $id);
        if ($this->data) {
            $this->id = $id;

            $ret = $this->hook('afterLoad');
            if ($ret === false) {
                return $this->unload();
            } elseif (is_object($ret)) {
                return $ret;
            }
        } else {
            $this->unload();
        }

        return $this;
    }
public function tryLoad ( $ id ) { if ( ! $ this -> persistence ) { throw new Exception ( [ 'Model is not associated with any database' ] ) ; } if ( ! $ this -> persistence -> hasMethod ( 'tryLoad' ) ) { throw new Exception ( 'Persistence does not support tryLoad()' ) ; } if ( $ this -> loaded ( ) ) { $ this -> unload ( ) ; } $ this -> data = $ this -> persistence -> tryLoad ( $ this , $ id ) ; if ( $ this -> data ) { $ this -> id = $ id ; $ ret = $ this -> hook ( 'afterLoad' ) ; if ( $ ret === false ) { return $ this -> unload ( ) ; } elseif ( is_object ( $ ret ) ) { return $ ret ; } } else { $ this -> unload ( ) ; } return $ this ; }
Try to load record.
Will not throw exception if record doesn't exist.

@param mixed $id

@return $this
Try to load record . Will not throw exception if record doesn t exist .