src/Charcoal/Source/DatabaseSource.php
public function loadItemFromQuery($query, array $binds = [], StorableInterface $item = null)
    {
        if ($item !== null) {
            $this->setModel($item);
        } else {
            $class = get_class($this->model());
            $item = new $class;
        }

        // Missing parameters
        if (!$query) {
            return $item;
        }

        $sth = $this->dbQuery($query, $binds);
        if ($sth === false) {
            throw new PDOException('Could not load item.');
        }

        $data = $sth->fetch(PDO::FETCH_ASSOC);
        if ($data) {
            $item->setFlatData($data);
        }

        return $item;
    }
public function loadItemFromQuery($query, array $binds = [], StorableInterface $item = null)
    {
        if ($item !== null) {
            $this->setModel($item);
        } else {
            $class = get_class($this->model());
            $item = new $class;
        }

        // Missing parameters
        if (!$query) {
            return $item;
        }

        $sth = $this->dbQuery($query, $binds);
        if ($sth === false) {
            throw new PDOException('Could not load item.');
        }

        $data = $sth->fetch(PDO::FETCH_ASSOC);
        if ($data) {
            $item->setFlatData($data);
        }

        return $item;
    }
public function loadItemFromQuery ( $ query , array $ binds = [ ] , StorableInterface $ item = null ) { if ( $ item !== null ) { $ this -> setModel ( $ item ) ; } else { $ class = get_class ( $ this -> model ( ) ) ; $ item = new $ class ; } // Missing parameters if ( ! $ query ) { return $ item ; } $ sth = $ this -> dbQuery ( $ query , $ binds ) ; if ( $ sth === false ) { throw new PDOException ( 'Could not load item.' ) ; } $ data = $ sth -> fetch ( PDO :: FETCH_ASSOC ) ; if ( $ data ) { $ item -> setFlatData ( $ data ) ; } return $ item ; }
Load item by the given query statement.

@param  string            $query The SQL SELECT statement.
@param  array             $binds Optional. The query parameters.
@param  StorableInterface $item  Optional. Item (storable object) to load into.
@throws PDOException If there is a query error.
@return StorableInterface
Load item by the given query statement .