protected function _get_stored_data()
    {
        if (!($prim_key = static::table()->primaryKey()) && !$this->storedAttributes) {
            throw new Exception\RuntimeException(
                "Can't find data without primary key nor storedAttributes"
            );
        }
        
        $query = static::none();
        
        if ($prim_key) {
            $query->where('`'.$prim_key.'` = ?', $this->$prim_key);
        } else {
            $model = new static();
            $cols_names = static::table()->columnNames();
            foreach ($this->storedAttributes as $name => $value) {
                if (in_array($name, $cols_names)) {
                    $model->attributes[$name] = $value;
                }
            }
            
            if (!$model->attributes)
                throw new Exception\RuntimeException(
                    "Model rebuilt from storedAttributes failed"
                );
            else
                return $model;
        }
        
        $current = $query->first();
        
        if (!$current)
            throw new Exception\RuntimeException(
                "Row not found in database (searched with storedAttributes)"
            );
        else
            return $current;
    }
protected function _get_stored_data()
    {
        if (!($prim_key = static::table()->primaryKey()) && !$this->storedAttributes) {
            throw new Exception\RuntimeException(
                "Can't find data without primary key nor storedAttributes"
            );
        }
        
        $query = static::none();
        
        if ($prim_key) {
            $query->where('`'.$prim_key.'` = ?', $this->$prim_key);
        } else {
            $model = new static();
            $cols_names = static::table()->columnNames();
            foreach ($this->storedAttributes as $name => $value) {
                if (in_array($name, $cols_names)) {
                    $model->attributes[$name] = $value;
                }
            }
            
            if (!$model->attributes)
                throw new Exception\RuntimeException(
                    "Model rebuilt from storedAttributes failed"
                );
            else
                return $model;
        }
        
        $current = $query->first();
        
        if (!$current)
            throw new Exception\RuntimeException(
                "Row not found in database (searched with storedAttributes)"
            );
        else
            return $current;
    }
protected function _get_stored_data ( ) { if ( ! ( $ prim_key = static :: table ( ) -> primaryKey ( ) ) && ! $ this -> storedAttributes ) { throw new Exception \ RuntimeException ( "Can't find data without primary key nor storedAttributes" ) ; } $ query = static :: none ( ) ; if ( $ prim_key ) { $ query -> where ( '`' . $ prim_key . '` = ?' , $ this -> $ prim_key ) ; } else { $ model = new static ( ) ; $ cols_names = static :: table ( ) -> columnNames ( ) ; foreach ( $ this -> storedAttributes as $ name => $ value ) { if ( in_array ( $ name , $ cols_names ) ) { $ model -> attributes [ $ name ] = $ value ; } } if ( ! $ model -> attributes ) throw new Exception \ RuntimeException ( "Model rebuilt from storedAttributes failed" ) ; else return $ model ; } $ current = $ query -> first ( ) ; if ( ! $ current ) throw new Exception \ RuntimeException ( "Row not found in database (searched with storedAttributes)" ) ; else return $ current ; }
Returns model's current data in the database or using storedAttributes.
Returns model s current data in the database or using storedAttributes .