コード例 #1
0
 public function query($sql, RowMapper $mapper, $arguments = null)
 {
     $records = array();
     $sql = $this->prepareArgs($sql, $arguments);
     $results = $this->driver->query($sql, $this->getConnection());
     while ($row = $this->driver->resultSetObject($results)) {
         $record = $mapper->mapRow($row);
         Args::notNull($record, 'row mapper return value');
         array_push($records, $record);
     }
     return $records;
 }
コード例 #2
0
 public function queryForList($sql, RowMapper $rowMapper = null, $params = null)
 {
     $stmt = $this->prepareStmt($sql, $params);
     $liste = $stmt->fetchAll(\PDO::FETCH_ASSOC);
     $listeRetour = array();
     $i = 1;
     foreach ($liste as $line) {
         if ($rowMapper != null) {
             $listeRetour[] = $rowMapper->mapRow($this->getResultSet($line), $i++);
         } else {
             $listeRetour[] = array_shift($line);
         }
     }
     return $listeRetour;
 }