private static function _getByPosition($position, $conditions=null)
    {
        self::_checkLoaded();

        $builder          = self::_makeBuilder();
        $builder->fields  = self::extractColumns();
        $builder->order   = $position=="first" ? self::getOrder() : self::getReversedOrder();
        $builder->where   = self::_extractWhereConditions($conditions);
        $vals             = self::extractWhereValues($conditions);

        $cls  = get_called_class();
        $stmt = self::executePrepared($builder, $vals);
        $data = $stmt->fetch(\PDO::FETCH_ASSOC);

        if (!$data) {
            return null;
        }
        return new $cls($data);
    }
private static function _getByPosition($position, $conditions=null)
    {
        self::_checkLoaded();

        $builder          = self::_makeBuilder();
        $builder->fields  = self::extractColumns();
        $builder->order   = $position=="first" ? self::getOrder() : self::getReversedOrder();
        $builder->where   = self::_extractWhereConditions($conditions);
        $vals             = self::extractWhereValues($conditions);

        $cls  = get_called_class();
        $stmt = self::executePrepared($builder, $vals);
        $data = $stmt->fetch(\PDO::FETCH_ASSOC);

        if (!$data) {
            return null;
        }
        return new $cls($data);
    }
private static function _getByPosition ( $ position , $ conditions = null ) { self :: _checkLoaded ( ) ; $ builder = self :: _makeBuilder ( ) ; $ builder -> fields = self :: extractColumns ( ) ; $ builder -> order = $ position == "first" ? self :: getOrder ( ) : self :: getReversedOrder ( ) ; $ builder -> where = self :: _extractWhereConditions ( $ conditions ) ; $ vals = self :: extractWhereValues ( $ conditions ) ; $ cls = get_called_class ( ) ; $ stmt = self :: executePrepared ( $ builder , $ vals ) ; $ data = $ stmt -> fetch ( \ PDO :: FETCH_ASSOC ) ; if ( ! $ data ) { return null ; } return new $ cls ( $ data ) ; }
Get result by position - first or last

@param string $position   "first" or "last"
@param mixed  $conditions to extract

@return result or null
Get result by position - first or last