You are here

public function QPDB::queryInto in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/Extension/QPDB.php \QPDB::queryInto()
  2. 7.2 QueryPath/Extension/QPDB.php \QPDB::queryInto()

File

QueryPath/Extension/QPDB.php, line 68

Class

QPDB

Code

public function queryInto($sql, $args = array(), $template = NULL) {
  $stmt = $this->db
    ->prepare($sql);
  $stmt
    ->setFetchMode(PDO::FETCH_ASSOC);
  $stmt
    ->execute($args);
  if (empty($template)) {
    foreach ($stmt as $row) {
      foreach ($row as $datum) {
        $this->qp
          ->append($datum);
      }
    }
  }
  else {
    foreach ($stmt as $row) {
      $this->qp
        ->tpl($template, $row);
    }
  }
  $stmt
    ->closeCursor();
  return $this->qp;
}