You are here

protected function QPDB::addData in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/Extension/QPDB.php \QPDB::addData()
  2. 7.2 QueryPath/Extension/QPDB.php \QPDB::addData()
4 calls to QPDB::addData()
QPDB::appendColumn in QueryPath/Extension/QPDB.php
QPDB::columnAfter in QueryPath/Extension/QPDB.php
QPDB::columnBefore in QueryPath/Extension/QPDB.php
QPDB::prependColumn in QueryPath/Extension/QPDB.php

File

QueryPath/Extension/QPDB.php, line 119

Class

QPDB

Code

protected function addData($columnName, $qpFunc = 'append', $wrap = NULL) {
  $columns = is_array($columnName) ? $columnName : array(
    $columnName,
  );
  $hasWrap = !empty($wrap);
  if ($this->cycleRows) {
    while (($row = $this->stmt
      ->fetch(PDO::FETCH_ASSOC)) !== FALSE) {
      foreach ($columns as $col) {
        if (isset($row[$col])) {
          $data = $row[$col];
          if ($hasWrap) {
            $data = qp()
              ->append($wrap)
              ->deepest()
              ->append($data)
              ->top();
          }
          $this->qp
            ->{$qpFunc}($data);
        }
      }
    }
    $this->cycleRows = FALSE;
    $this
      ->doneWithQuery();
  }
  else {
    if ($this->row !== FALSE) {
      foreach ($columns as $col) {
        if (isset($this->row[$col])) {
          $data = $this->row[$col];
          if ($hasWrap) {
            $data = qp()
              ->append($wrap)
              ->deepest()
              ->append($data)
              ->top();
          }
          $this->qp
            ->{$qpFunc}($data);
        }
      }
    }
  }
  return $this->qp;
}