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

        $items = [];

        $model = $this->model();
        $dbh   = $this->db();

        $this->logger->debug($query);
        $sth = $dbh->prepare($query);

        // @todo Binds
        if (!empty($binds)) {
            unset($binds);
        }

        $sth->execute();
        $sth->setFetchMode(PDO::FETCH_ASSOC);

        $className = get_class($model);
        while ($objData = $sth->fetch()) {
            $obj = new $className;
            $obj->setFlatData($objData);
            $items[] = $obj;
        }

        return $items;
    }
public function loadItemsFromQuery($query, array $binds = [], StorableInterface $item = null)
    {
        if ($item !== null) {
            $this->setModel($item);
        }

        $items = [];

        $model = $this->model();
        $dbh   = $this->db();

        $this->logger->debug($query);
        $sth = $dbh->prepare($query);

        // @todo Binds
        if (!empty($binds)) {
            unset($binds);
        }

        $sth->execute();
        $sth->setFetchMode(PDO::FETCH_ASSOC);

        $className = get_class($model);
        while ($objData = $sth->fetch()) {
            $obj = new $className;
            $obj->setFlatData($objData);
            $items[] = $obj;
        }

        return $items;
    }
public function loadItemsFromQuery ( $ query , array $ binds = [ ] , StorableInterface $ item = null ) { if ( $ item !== null ) { $ this -> setModel ( $ item ) ; } $ items = [ ] ; $ model = $ this -> model ( ) ; $ dbh = $ this -> db ( ) ; $ this -> logger -> debug ( $ query ) ; $ sth = $ dbh -> prepare ( $ query ) ; // @todo Binds if ( ! empty ( $ binds ) ) { unset ( $ binds ) ; } $ sth -> execute ( ) ; $ sth -> setFetchMode ( PDO :: FETCH_ASSOC ) ; $ className = get_class ( $ model ) ; while ( $ objData = $ sth -> fetch ( ) ) { $ obj = new $ className ; $ obj -> setFlatData ( $ objData ) ; $ items [ ] = $ obj ; } return $ items ; }
Load items for the given query statement.

@param  string                 $query The SQL SELECT statement.
@param  array                  $binds This has to be done.
@param  StorableInterface|null $item  Model Item.
@return StorableInterface[]
Load items for the given query statement .