/** * Mysqli's binding and returning of statement values * Mysqli requires you to bind variables to the extension in order to * get data out. These values have to be references: * * @see http://php.net/manual/en/mysqli-stmt.bind-result.php * @throws Exception\RuntimeException * @return bool */ protected function loadDataFromMysqliStatement() { $data = null; // build the default reference based bind structure, if it does not already exist if ($this->statementBindValues['keys'] === null) { $this->statementBindValues['keys'] = array(); /* @var $resultResource \mysqli_result */ $resultResource = $this->resource->result_metadata(); foreach ($resultResource->fetch_fields() as $col) { $this->statementBindValues['keys'][] = $col->name; } $this->statementBindValues['values'] = array_fill(0, count($this->statementBindValues['keys']), null); $refs = array(); foreach ($this->statementBindValues['values'] as $i => &$f) { $refs[$i] =& $f; } call_user_func_array(array($this->resource, 'bind_result'), $this->statementBindValues['values']); } if (($r = $this->resource->fetch()) === null) { if (!$this->isBuffered) { $this->resource->close(); } return false; } elseif ($r === false) { throw new Exception\RuntimeException($this->resource->error); } // dereference for ($i = 0, $count = count($this->statementBindValues['keys']); $i < $count; $i++) { $this->currentData[$this->statementBindValues['keys'][$i]] = $this->statementBindValues['values'][$i]; } $this->currentComplete = true; $this->nextComplete = true; $this->position++; return true; }