/** * @param null $rownum * @param bool $save * @param bool $suppress * * @return array */ public function fetch($rownum = null, $save = false, $suppress = false) { $rows = []; if (!isset($rownum)) { $rownum = Config::get('oci-classes::defaults.paging'); } if ($rownum < 1) { if ($save) { for ($i = 0; true; $i++) { $rows[$i] = $this->next($save); if ($rows[$i] == false) { unset($rows[$i]); break; } } } else { $this->affectedRows = oci_fetch_all($this->resource, $rows, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS); if ($this->affectedRows === false) { $t = count($this->errorStack); $this->errorStack[$t]['error'] = oci_error($this->connection->resource); $this->errorStack[$t]['trace'] = debug_backtrace(0, 3); Error::getMessage(null, $this->errorStack[$t]['trace'], $this->errorStack[$t]['error'], $suppress); return $this->affectedRows; } return $rows; } } else { for ($i = 0; $i < $rownum; $i++) { $rows[$i] = $this->next($save); if ($rows[$i] == false) { unset($rows[$i]); break; } } } return $rows; }
protected function &connect($new = false, $suppress = false) { $this->setConnectionString(); isset($this->connectionSettings['session_mode']) ?: ($this->connectionSettings['session_mode'] = null); if ($new) { $resource = oci_new_connect($this->connectionSettings['username'], $this->connectionSettings['password'], $this->connectionString, $this->connectionSettings['charset'], $this->connectionSettings['session_mode']); if (!$resource) { $t = count($this->errorStack); $this->errorStack[$t]['error'] = oci_error($this->resource); $this->errorStack[$t]['trace'] = debug_backtrace(0, 3); Error::getMessage(null, $this->errorStack[$t]['trace'], $this->errorStack[$t]['error'], $suppress); } return $resource; } else { $this->resource = oci_connect($this->connectionSettings['username'], $this->connectionSettings['password'], $this->connectionString, $this->connectionSettings['charset'], $this->connectionSettings['session_mode']); if (!$this->resource) { $t = count($this->errorStack); $this->errorStack[$t]['error'] = oci_error($this->resource); $this->errorStack[$t]['trace'] = debug_backtrace(0, 3); Error::getMessage(null, $this->errorStack[$t]['trace'], $this->errorStack[$t]['error'], $suppress); } return $this->resource; } }