You are here

protected function QPDrupalDB::addData in QueryPath 6

Same name and namespace in other branches
  1. 7.3 querypath.classes.inc \QPDrupalDB::addData()
  2. 7.2 querypath.classes.inc \QPDrupalDB::addData()
4 calls to QPDrupalDB::addData()
QPDrupalDB::appendColumn in ./querypath.classes.inc
Append the data in the given column(s) to the QueryPath.
QPDrupalDB::columnAfter in ./querypath.classes.inc
Insert data from the given column(s) after each element in the QueryPath.
QPDrupalDB::columnBefore in ./querypath.classes.inc
Insert the data from the given column before each element in the QueryPath.
QPDrupalDB::prependColumn in ./querypath.classes.inc
Prepend the data from the given column into the QueryPath.

File

./querypath.classes.inc, line 104
Classes that are part of the QueryPath module.

Class

QPDrupalDB
Add Drupal database support to QueryPath.

Code

protected function addData($columnName, $qpFunc = 'append', $wrap = NULL) {
  $columns = is_array($columnName) ? $columnName : array(
    $columnName,
  );
  $hasWrap = !empty($wrap);
  if ($this->cycleRows) {
    while (($row = db_fetch_array($this->results)) !== FALSE) {
      foreach ($columns as $col) {
        if (isset($row[$col])) {
          $data = $row[$col];
          if ($hasWrap) {
            $data = qp($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($wrap)
              ->deepest()
              ->append($data)
              ->top();
          }
          $this->qp
            ->{$qpFunc}($data);
        }
      }
    }
  }
  return $this->qp;
}