src/Model.php
public static function find($id, array $columns = ['*'], $options = [])
    {
        // Return a cached instance if one exists
        $cache = self::cache();
        if ($cache->containsAttributes($id, $columns)) {
            return $cache->get($id);
        }

        // Return attributes which are not cached
        $columns = $cache->getNotCachedAttributes($id, $columns);

        // Create a new model
        $model = static::createInstance();
        $model->setId($id);

        // Merge options
        $options = array_merge($options, ['columns' => $columns == ['*'] ? [] : $columns]);

        // Get by id
        try {
            $model->_dal->get($id, $options);
        } catch (Missing404Exception $e) {
            return null;
        }

        // Fill internal attributes
        $model->_exist = true;

        // Put model to cache
        $model = $cache->put($id, $model, $columns);

        return $model;
    }
public static function find($id, array $columns = ['*'], $options = [])
    {
        // Return a cached instance if one exists
        $cache = self::cache();
        if ($cache->containsAttributes($id, $columns)) {
            return $cache->get($id);
        }

        // Return attributes which are not cached
        $columns = $cache->getNotCachedAttributes($id, $columns);

        // Create a new model
        $model = static::createInstance();
        $model->setId($id);

        // Merge options
        $options = array_merge($options, ['columns' => $columns == ['*'] ? [] : $columns]);

        // Get by id
        try {
            $model->_dal->get($id, $options);
        } catch (Missing404Exception $e) {
            return null;
        }

        // Fill internal attributes
        $model->_exist = true;

        // Put model to cache
        $model = $cache->put($id, $model, $columns);

        return $model;
    }
public static function find ( $ id , array $ columns = [ '*' ] , $ options = [ ] ) { // Return a cached instance if one exists $ cache = self :: cache ( ) ; if ( $ cache -> containsAttributes ( $ id , $ columns ) ) { return $ cache -> get ( $ id ) ; } // Return attributes which are not cached $ columns = $ cache -> getNotCachedAttributes ( $ id , $ columns ) ; // Create a new model $ model = static :: createInstance ( ) ; $ model -> setId ( $ id ) ; // Merge options $ options = array_merge ( $ options , [ 'columns' => $ columns == [ '*' ] ? [ ] : $ columns ] ) ; // Get by id try { $ model -> _dal -> get ( $ id , $ options ) ; } catch ( Missing404Exception $ e ) { return null ; } // Fill internal attributes $ model -> _exist = true ; // Put model to cache $ model = $ cache -> put ( $ id , $ model , $ columns ) ; return $ model ; }
Find a model by its primary key.

@param mixed $id
@param array $columns
@param array $options
@return static
Find a model by its primary key .