/** * Fetches a row from the current result set. * * @access public * @return array */ function fetchRow() { $row = @OCIFetchInto($this->result, $result, OCI_ASSOC); if (is_array($row)) { return array_change_key_case($result, CASE_LOWER); } return false; }
/** * Fetches a row from the current result set. * * @access public * @return array */ function fetchRow() { if (is_resource($this->result)) { if (@OCIFetchInto($this->result, $result, OCI_ASSOC)) { return array_change_key_case($result, CASE_LOWER); } } else { return false; } }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function oci8Adapter($d) { parent::RecordSetAdapter($d); $fieldcount = ocinumcols($d); for ($j = 0; $j < $fieldcount; $j++) { $this->columnNames[] = ocicolumnname($d, $j + 1); } $i = 0; while (OCIFetchInto($d, $line, OCI_NUM + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) { $this->rows[] = $line; } }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function oci8Adapter($d) { parent::RecordSetAdapter($d); $fieldcount = ocinumcols($d); $ob = ""; $be = $this->isBigEndian; $fc = pack('N', $fieldcount); $i = 0; while (OCIFetchInto($d, $line, OCI_NUM + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) { // write all of the array elements $ob .= "\n" . $fc; foreach ($line as $value) { // write all of the array elements if (is_string($value)) { // type as string $os = $this->_directCharsetHandler->transliterate($value); //string flag, string length, and string $len = strlen($os); if ($len < 65536) { $ob .= "" . pack('n', $len) . $os; } else { $ob .= "\f" . pack('N', $len) . $os; } } elseif (is_float($value) || is_int($value)) { // type as double $b = pack('d', $value); // pack the bytes if ($be) { // if we are a big-endian processor $r = strrev($b); } else { // add the bytes to the output $r = $b; } $ob .= "" . $r; } elseif (is_bool($value)) { //type as bool $ob .= ""; $ob .= pack('c', $value); } elseif (is_null($value)) { // null $ob .= ""; } } $i++; } $this->serializedData = $ob; for ($j = 0; $j < $fieldcount; $j++) { $this->columnNames[] = $this->_charsetHandler->transliterate(ocicolumnname($d, $j + 1)); } $this->numRows = $i; }
public function read($id) { $query = "SELECT " . self::$_table["saveHandler"]["options"]["dataColumn"] . " FROM " . self::$_table["saveHandler"]["options"]["name"] . " WHERE " . self::$_table["saveHandler"]["options"]["primary"][0] . " = '" . $id . "'"; $stmt = OCIParse(self::$_db, $query); if ($stmt) { $result = OCIExecute($stmt); if (OCIFetchInto($stmt, $result, OCI_ASSOC + OCI_RETURN_LOBS)) { $ret = $result[self::$_table["saveHandler"]["options"]["dataColumn"]]; } else { $ret = false; } OCIFreeStatement($stmt); } else { $ret = false; } return $ret; }
/** * @name registro_db * @param string cadena_sql * @param int numero * @return boolean * @access public */ function registro_db($cadena_sql, $numero) { unset($this->registro); if (!is_resource($this->enlace)) { return FALSE; } //echo "Ejemplo: ".$cadena_sql."<br>"; $cadenaParser = OCIParse($this->enlace, $cadena_sql); $busqueda = OCIExecute($cadenaParser); if ($busqueda) { $j = 0; while (OCIFetchInto($cadenaParser, $row, OCI_RETURN_NULLS)) { $a = 0; $un_campo = 0; $campos = count($row); while ($a < $campos) { $this->registro[$j][$un_campo] = $row[$a++]; $un_campo++; } $j++; //$this->registro[$j][$un_campo] = $salida[$j][$un_campo]; //echo $this->registro[$j][$un_campo]; } $this->conteo = $j--; //echo $this->conteo; @OCIFreeCursor($cadenaParser); return $this->conteo; } else { unset($this->registro); $this->error = oci_error(); //echo $this->error(); return 0; } }
/** * Fetch a row and insert the data into an existing array. * * @param $result oci8 result identifier * @param $arr (reference) array where data from the row is stored * @param $fetchmode how the array data should be indexed * @param $rownum the row number to fetch (not yet supported) * * @return int DB_OK on success, a DB error code on failure */ function fetchInto($result, &$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=NULL) { if ($rownum !== NULL) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } if ($fetchmode == DB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } if ($fetchmode & DB_FETCHMODE_ASSOC) { $moredata = @OCIFetchInto($result,$arr,OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS); } else { $moredata = @OCIFetchInto($result,$arr,OCI_RETURN_NULLS+OCI_RETURN_LOBS); } if (!$moredata) { return NULL; } return DB_OK; }
/** * Fill the row buffer * * @param int $rownum row number upto which the buffer should be filled if the row number is null all rows are ready into the buffer * @return boolean true on success, false on failure * @access protected */ function _fillBuffer($rownum = null) { if (isset($this->buffer) && is_array($this->buffer)) { if (is_null($rownum)) { if (!end($this->buffer)) { return false; } } elseif (isset($this->buffer[$rownum])) { return (bool) $this->buffer[$rownum]; } } $row = true; while ((is_null($rownum) || $this->buffer_rownum < $rownum) && ($row = @OCIFetchInto($this->result, $buffer, OCI_RETURN_NULLS))) { ++$this->buffer_rownum; // remove additional column at the end if ($this->offset > 0) { array_pop($buffer); } if (empty($this->types)) { foreach (array_keys($buffer) as $key) { if (is_a($buffer[$key], 'oci-lob')) { $buffer[$key] = $buffer[$key]->load(); } } } $this->buffer[$this->buffer_rownum] = $buffer; } if (!$row) { ++$this->buffer_rownum; $this->buffer[$this->buffer_rownum] = false; return false; } return true; }
function db_fetch_array($res) { global $db_type; global $debug; if ($db_type == "mysql") { $ar = mysql_fetch_array($res, MYSQL_NUM); return $ar; } else { if ($db_type == "oracle") { $ar = array(); OCIFetchInto($res, $ar, OCI_NUM + OCI_RETURN_LOBS); return $ar; } } }
function next_record() { if (0 == OCIFetchInto($this->Parse, $result, OCI_ASSOC + OCI_RETURN_NULLS)) { if ($this->Debug) { printf("<br>ID: %d,Rows: %d<br>\n", $this->Link_ID, $this->num_rows()); } $this->Row += 1; $errno = OCIError($this->Parse); if (1403 == $errno) { # 1043 means no more records found $this->Error = ""; $this->disconnect(); $stat = 0; } else { $this->Error = OCIError($this->Parse); if ($this->Debug) { printf("<br>Error: %s", $this->Error["message"]); } $stat = 0; } } else { for ($ix = 1; $ix <= OCINumcols($this->Parse); $ix++) { $col = strtoupper(OCIColumnname($this->Parse, $ix)); $colreturn = strtolower($col); $this->Record["{$colreturn}"] = $result["{$col}"]; if ($this->Debug) { echo "<b>[{$col}]</b>:" . $result["{$col}"] . "<br>\n"; } } $stat = 1; } return $stat; }
function query($query) { /* this function execute a query on a database MySQL using a SQL statement passed in the variable $query and returns an array $rec with the result recordset. Use this function ONLY with SELECT statements, if you want to execute INSERT or UPDATE use the function query_execute(). */ $rec = array(); include './config/registry_oracle_db.php'; //putenv("ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0"); # open connection to db $conn = oci_connect($user_db, $password_db, $db) or die("Could not connect to Oracle database!") or die(ocierror()); //$rec=array(); # execute the EXEC query $statement = ociparse($conn, $query); $risultato = ociexecute($statement); # open db //$rec=array(); # execute the EXEC query while (OCIFetchInto($statement, $row)) { $rec[] = $row; //print_r($row); } //OCIFetchInto ($statement, $row, OCI_ASSOC); return $rec; # close connection oci_close($conn); }
function addDatasetsFromDatabase($query_result, $ctrlField, $valueField, $datsetParamArray = "", $link = "") { # Initialize variables $paramset = ""; $tempContrl = ""; if (is_array($datsetParamArray) == false) { $datsetParamArray = array(); } # Calculate total no of array elements in datsetParamArray $arrLimit = count($datsetParamArray); $i = 1; $tempParam = ""; if ($this->DataBaseType == "mysql") { ##### For My SQL Connection $FieldArray = explode($this->del, $valueField); if (count($FieldArray) > 1) { ### Muli Series # fetching recordset while ($row = mysql_fetch_array($query_result)) { # Add Category $this->addCategory($row[$ctrlField]); } $k = 0; # Add daatset for multiple fields foreach ($FieldArray as $FieldName) { if ($k < $arrLimit) { $tempParam = $datsetParamArray[$k]; } else { $tempParam = ""; } # Add Dataset with adddataset() function $this->addDataset($FieldName, $tempParam); # rewind query result mysql_data_seek($query_result, 0); while ($row = mysql_fetch_array($query_result)) { # Generating URL link if ($link == "") { $paramset = ""; } else { # Generating URL link from getLinkFromPattern $paramset = "link=" . urlencode($this->getLinkFromPattern($row, $link)); } # add value to dataset $this->addChartData($row[$FieldName], $paramset, ""); } $k++; } } else { ### Single Series # fetching recordset while ($row = mysql_fetch_array($query_result)) { # Creating Control break depending on ctrlField # if ctrlField value changes then dataset will be Generated if ($tempContrl != $row[$ctrlField]) { if ($i <= $arrLimit) { $tempParam = $datsetParamArray[$i - 1]; } else { $tempParam = ""; } # Add Dataset with adddataset() function $this->addDataset($row[$ctrlField], $tempParam); $tempContrl = $row[$ctrlField]; $i++; } # Generating URL link if ($link == "") { $paramset = ""; } else { # Generating URL link from getLinkFromPattern $paramset = "link=" . urlencode($this->getLinkFromPattern($row, $link)); } # add value to dataset $this->addChartData($row[$valueField], $paramset, ""); } } } elseif ($this->DataBaseType == "oracle") { # For Oracle Connection # fetching recordset while (OCIFetchInto($query_result, $row, OCI_ASSOC)) { # Create Control break depending on ctrlField # if ctrlField value changes then dataset will be Generated if ($tempContrl != $row[$ctrlField]) { if ($i <= $arrLimit) { $tempParam = $datsetParamArray[$i - 1]; } else { $tempParam = ""; } # add Dataset $this->addDataset($row[$ctrlField], $tempParam); $tempContrl = $row[$ctrlField]; $i++; } # Generating URL link if ($link == "") { $paramset = ""; } else { # Generating URL link from getLinkFromPattern $paramset = "link=" . urlencode($this->getLinkFromPattern($row, $link)); } # add value to dataset $this->addChartData($row[$valueField], $paramset, ""); } } }
function DBGetQuery($result, $arrayType = 1, $encode = true) { // Devuelve la siguiente fila dentro del result-array.. /* if ($arrayType == 0) $row = oci_fetch_array($result, OCI_NUM + OCI_RETURN_NULLS); if ($arrayType == 1) $row = oci_fetch_array($result, OCI_ASSOC + OCI_RETURN_NULLS); if ($arrayType == 2) $row = oci_fetch_array($result, OCI_ASSOC + OCI_NUM + OCI_RETURN_NULLS); LO IDEAL SERIA USAR ESTO QUE ESTA COMENTADO EN LUGAR DE "OCIFETCHINTO" (QUE QUEDÓ OBSOLETO), PERO HAY QUE TENER CUIDADO, AL MENOS, CON LA FUNCION EXISTESQLORACLE QUE FALLA EN LA ULTIMA LINEA (RETURN (COUNT($ROW) > 0);), SI SE CORRIGE ESO, SE PODRIA USAR.. */ if ($arrayType == 0) { OCIFetchInto($result, $row, OCI_NUM + OCI_RETURN_NULLS); } if ($arrayType == 1) { OCIFetchInto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS); } if ($arrayType == 2) { OCIFetchInto($result, $row, OCI_ASSOC + OCI_NUM + OCI_RETURN_NULLS); } return adminXSS($row, $encode); }
/** * Fetch a row and return data in an array. * * @param resource $result result identifier * @param int $fetchmode how the array data should be indexed * @param int $rownum the row number to fetch * @return mixed data array or NULL on success, a MDB error on failure * @access public */ function fetchInto($result, $fetchmode = MDB_FETCHMODE_DEFAULT, $rownum = NULL) { $result_value = intval($result); if (!isset($this->current_row[$result_value])) { return $this->raiseError(MDB_ERROR, NULL, NULL, 'fetchInto: attemped to fetch on an unknown query result'); } if ($fetchmode == MDB_FETCHMODE_DEFAULT) { $fetchmode = $this->fetchmode; } if (is_null($rownum)) { $rownum = $this->current_row[$result_value] + 1; } if (!isset($this->results[$result_value][$rownum]) && (!isset($this->results[$result_value][$this->highest_fetched_row[$result_value]]) || $this->results[$result_value][$this->highest_fetched_row[$result_value]] !== FALSE)) { if (isset($this->limits[$result_value])) { // upper limit if ($rownum > $this->limits[$result_value][1]) { // are all previous rows fetched so that we can set the end // of the result set and not have any "holes" in between? if ($rownum == 0 || isset($this->results[$result_value]) && count($this->results[$result_value]) == $rownum) { $this->highest_fetched_row[$result_value] = $rownum; $this->current_row[$result_value] = $rownum; $this->results[$result_value][$rownum] = FALSE; } if ($this->options['autofree']) { $this->freeResult($result); } return NULL; } // offset skipping if (MDB::isError($this->_skipLimitOffset($result))) { $this->current_row[$result_value] = 0; $this->results[$result_value] = array(FALSE); if ($this->options['autofree']) { $this->freeResult($result); } return NULL; } } if (isset($this->row_buffer[$result_value])) { ++$this->current_row[$result_value]; $this->results[$result_value][$this->current_row[$result_value]] = $this->row_buffer[$result_value]; unset($this->row_buffer[$result_value]); } if (!isset($this->results[$result_value][$rownum]) && (!isset($this->results[$result_value][$this->highest_fetched_row[$result_value]]) || $this->results[$result_value][$this->highest_fetched_row[$result_value]] !== FALSE)) { while ($this->current_row[$result_value] < $rownum && @OCIFetchInto($result, $buffer, OCI_RETURN_NULLS)) { ++$this->current_row[$result_value]; $this->results[$result_value][$this->current_row[$result_value]] = $buffer; } // end of result set reached if ($this->current_row[$result_value] < $rownum) { ++$this->current_row[$result_value]; $this->results[$result_value][$this->current_row[$result_value]] = FALSE; } } $this->highest_fetched_row[$result_value] = max($this->highest_fetched_row[$result_value], $this->current_row[$result_value]); } else { ++$this->current_row[$result_value]; } if (isset($this->results[$result_value][$rownum]) && $this->results[$result_value][$rownum]) { $row = $this->results[$result_value][$rownum]; } else { if ($this->options['autofree']) { $this->freeResult($result); } return NULL; } if ($fetchmode & MDB_FETCHMODE_ASSOC) { $column_names = $this->getColumnNames($result); foreach ($column_names as $name => $i) { $column_names[$name] = $row[$i]; } $row = $column_names; } if (isset($this->result_types[$result_value])) { $row = $this->convertResultRow($result, $row); } return $row; }
/** * Fill the row buffer * * @param int $rownum row number upto which the buffer should be filled if the row number is null all rows are ready into the buffer * @return boolean true on success, false on failure * @access private */ function _fillBuffer($rownum = null) { if (isset($this->buffer) && is_array($this->buffer)) { if (is_null($rownum)) { if (!end($this->buffer)) { return false; } } else { if (isset($this->buffer[$rownum])) { return (bool) $this->buffer[$rownum]; } } } if (!$this->_skipLimitOffset()) { return false; } $row = true; while ((is_null($rownum) || $this->buffer_rownum < $rownum) && (!isset($this->limits) || $this->buffer_rownum < $this->limits['limit']) && ($row = @OCIFetchInto($this->result, $buffer, OCI_RETURN_NULLS))) { ++$this->buffer_rownum; $this->buffer[$this->buffer_rownum] = $buffer; } if (!$row) { ++$this->buffer_rownum; $this->buffer[$this->buffer_rownum] = false; return false; } elseif (isset($this->limits) && $this->buffer_rownum >= $this->limits['limit']) { ++$this->buffer_rownum; $this->buffer[$this->buffer_rownum] = false; } return true; }
static function fetch_array($query) { $query = OCIFetchInto($query, $row, OCI_BOTH); return $row; }
/** * get a searchresult from the String by searching in all name fields. * Result is saved in the view class. * * Concept: look in the table fm_obj for the number. if it is found look for further information * Concatenate ALL fields of fm_obj in where the number is found with all lines in the two tables * where the ID is equal * */ function getXYZByRoomNumber($searchParam) { $numResults = 0; $sql = "SELECT DISTINCT " . $this->coordColumnX . "," . $this->coordColumnY . "," . $this->roomNamesColumn . "," . $this->roomNumberColumn . "," . $this->personTitelColumn . "," . $this->personNameColumn . "," . $this->personSurnameColumn . "," . $this->aboutStringColumn . " FROM (" . "(SELECT DISTINCT * FROM fm_obj WHERE LOWER(" . $this->roomNumberColumn . ") = LOWER('" . $searchParam . "')) o " . "INNER JOIN fm_stra a USING (OBJ_ID)) " . "LEFT OUTER JOIN fm_stpe p USING (OBJ_ID) "; //print $sql; $stmt = ociparse($this->conn, $sql); ociexecute($stmt); while (OCIFetchInto($stmt, $row, OCI_ASSOC)) { $numResults++; //print_r($row); array_push($this->theView->result, new Room(isset($row[$this->coordColumnX]) && isset($row[$this->coordColumnY]) ? $row[$this->coordColumnX] . " " . $row[$this->coordColumnY] : null, isset($row[$this->roomNamesColumn]) ? $row[$this->roomNamesColumn] : null, isset($row[$this->roomNumberColumn]) ? $row[$this->roomNumberColumn] : null, isset($row[$this->personTitelColumn]) && isset($row[$this->personNameColumn]) && isset($row[$this->personSurnameColumn]) ? $row[$this->personTitelColumn] . " " . $row[$this->personNameColumn] . " " . $row[$this->personSurnameColumn] : null, "beispiel.jpg", isset($row[$this->aboutStringColumn]) ? $row[$this->aboutStringColumn] : null)); } //print count($this->theView->rooms); return $numResults; }
function da_sql_fetch_array($statement, $config) { OCIFetchInto($statement, $temprow, OCI_ASSOC); $row = array_change_key_case($temprow, CASE_LOWER); if ($config[sql_debug] == 'true') { print "<b>DEBUG(SQL,OCI DRIVER): Query Result: <pre>"; print_r($row); print "</b></pre>\n"; } return $row; }
function NumberOfRows($result) { $result_value = intval($result); if (!isset($this->current_row[$result_value])) { return $this->SetError("Number of rows", "attemped to obtain the number of rows contained in an unknown query result"); } if (!isset($this->rows[$result_value])) { if (!$this->GetColumnNames($result, $column_names)) { return 0; } if (isset($this->limits[$result_value])) { if (!$this->SkipFirstRows($result)) { $this->rows[$result_value] = 0; return 0; } $limit = $this->limits[$result_value][1]; } else { $limit = 0; } if ($limit == 0 || $this->current_row[$result_value] + 1 < $limit) { if (isset($this->row_buffer[$result_value])) { $this->current_row[$result_value]++; $this->results[$result_value][$this->current_row[$result_value]] = $this->row_buffer[$result_value]; unset($this->row_buffer[$result_value]); } for (; ($limit == 0 || $this->current_row[$result_value] + 1 < $limit) && OCIFetchInto($result, $this->results[$result_value][$this->current_row[$result_value] + 1]); $this->current_row[$result_value]++) { } } $this->rows[$result_value] = $this->current_row[$result_value] + 1; } return $this->rows[$result_value]; }
function DBGetQuery($result, $arrayType = 1, $encode = true) { // Devuelve la siguiente fila dentro del result-array.. if ($arrayType == 0) { OCIFetchInto($result, $row, OCI_NUM + OCI_RETURN_NULLS); } if ($arrayType == 1) { OCIFetchInto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS); } if ($arrayType == 2) { OCIFetchInto($result, $row, OCI_ASSOC + OCI_NUM + OCI_RETURN_NULLS); } return adminXSS($row, $encode); }
/** * Fetch a row and insert the data into an existing array. * * @param $result oci8 result identifier * @param $arr (reference) array where data from the row is stored * @param $fetchmode how the array data should be indexed * @param $rownum the row number to fetch (not yet supported) * * @return int DB_OK on success, a DB error code on failure */ function fetchInto($result, &$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum = NULL) { if ($rownum !== NULL) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } if ($fetchmode & DB_FETCHMODE_ASSOC) { $moredata = @OCIFetchInto($result, $arr, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS); if ($moredata && $this->options['optimize'] == 'portability') { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $moredata = @OCIFetchInto($result, $arr, OCI_RETURN_NULLS + OCI_RETURN_LOBS); } if (!$moredata) { return NULL; } return DB_OK; }
function GetLastInsertID($sTable) { if (!($res = OCIParse($this->conn, "select currval(seq_{$sTable})"))) { trigger_error("Error parsing insert ID query!"); return $this->ReportError($this->conn); } if (OCIExecute($res)) { @OCIFetchInto($res, $Record, OCI_NUM | OCI_ASSOC | OCI_RETURN_NULLS); @OCIFreeStatement($res); return $Record[0]; } trigger_error("Error executing insert ID query!"); return $this->ReportError($res); }
function addDataFromDatabase($query_result, $db_field_ChartData, $db_field_CategoryNames = "", $strParam = "", $LinkPlaceHolder = "") { $paramset = ""; if ($this->DataBaseType == "mysql") { # fetching recordset till eof while ($row = mysql_fetch_array($query_result)) { if ($LinkPlaceHolder == "") { $paramset = ""; } else { # Getting link $paramset = "link=" . urlencode($this->getLinkFromPattern($row, $LinkPlaceHolder)); } if ($strParam = "") { $strParam = $paramset; } else { $strParam .= ";" . $paramset; } # covert to set element and save to $partXML if ($db_field_CategoryNames == "") { $data = @$row[$db_field_ChartData]; if ($strParam != "") { $this->addChartData($this->encodeSpecialChars($data), $strParam); } else { $this->addChartData($this->encodeSpecialChars($data)); } } else { $data = @$row[$db_field_ChartData]; $label = @$row[$db_field_CategoryNames]; $this->addChartData($this->encodeSpecialChars($data), "name=" . $this->encodeSpecialChars($label) . ";" . $strParam, ""); } } } elseif ($this->DataBaseType == "oracle") { # fetching recordset till eof while (OCIFetchInto($query_result, $row, OCI_ASSOC)) { if ($LinkPlaceHolder == "") { $paramset = ""; } else { # Getting link $paramset = "link=" . urlencode($this->getLinkFromPattern($row, $LinkPlaceHolder)); } if ($strParam = "") { $strParam = $paramset; } else { $strParam .= ";" . $paramset; } # covert to set element and save to $partXML if ($db_field_CategoryNames == "") { $data = @$row[$db_field_ChartData]; if ($strParam != "") { $this->addChartData($this->encodeSpecialChars($data), $strParam); } else { $this->addChartData($this->encodeSpecialChars($data)); } } else { $data = @$row[$db_field_ChartData]; $label = @$row[$db_field_CategoryNames]; $this->addChartData($this->encodeSpecialChars($data), "name=" . $this->encodeSpecialChars($label) . ";" . $strParam, ""); } } } }
function db_fetch_row($result) { global $DatabaseType; switch ($DatabaseType) { case 'oracle': OCIFetchInto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS); $return = $row; break; case 'postgres': $return = @pg_fetch_array($result); if (is_array($return)) { foreach ($return as $key => $value) { if (is_int($key)) { unset($return[$key]); } } } break; case 'mysql': $return = mysql_fetch_array($result); if (is_array($return)) { foreach ($return as $key => $value) { if (is_int($key)) { unset($return[$key]); } } } break; } return @array_change_key_case($return, CASE_UPPER); }
public function getNextArray($name) { OCIFetchInto($this->result[$name], $row, OCI_ASSOC); return $row; }
function next_record() { /* IF clause added to prevent a error when tried to read an empty "$this->Parse". */ if ($this->autoCount and $this->num_rows() == $this->Row) { return 0; } if (0 == OCIFetchInto($this->Parse, $result, OCI_ASSOC + OCI_RETURN_NULLS)) { if ($this->Debug) { printf("<br>ID: %d, Rows: %d<br>\n", $this->Link_ID, $this->num_rows()); } $this->Row += 1; $errno = OCIError($this->Parse); if (1403 == $errno) { # 1043 means no more records found $this->Error = false; $this->disconnect(); $stat = 0; } else { $this->Error = OCIError($this->Parse); if ($errno && $this->Debug) { printf("<br>Error: %s, %s<br>", $errno, $this->Error["message"]); } $stat = 0; } } else { $this->Record = array(); $totalReg = OCINumcols($this->Parse); for ($ix = 1; $ix <= $totalReg; $ix++) { $col = strtoupper(OCIColumnname($this->Parse, $ix)); $colreturn = strtolower($col); $this->Record[$colreturn] = is_object($result[$col]) ? $result[$col]->load() : $result[$col]; if ($this->Debug) { echo "<b>[{$col}]</b>:" . $result[$col] . "<br>\n"; } } $stat = 1; } return $stat; }
/** * Places a row from the result set into the given array * * Formating of the array and the data therein are configurable. * See DB_result::fetchInto() for more information. * * This method is not meant to be called directly. Use * DB_result::fetchInto() instead. It can't be declared "protected" * because DB_result is a separate object. * * @param resource $result the query result resource * @param array $arr the referenced array to put the data in * @param int $fetchmode how the resulting array should be indexed * @param int $rownum the row number to fetch (0 = first row) * * @return mixed DB_OK on success, NULL when the end of a result set is * reached or on failure * * @see DB_result::fetchInto() */ function fetchInto($result, &$arr, $fetchmode, $rownum = null) { if ($rownum !== null) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } if ($fetchmode & DB_FETCHMODE_ASSOC) { $moredata = @OCIFetchInto($result, $arr, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS); if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $moredata) { $arr = array_change_key_case($arr, CASE_LOWER); } } else { $moredata = OCIFetchInto($result, $arr, OCI_RETURN_NULLS + OCI_RETURN_LOBS); } if (!$moredata) { return null; } if ($this->options['portability'] & DB_PORTABILITY_RTRIM) { $this->_rtrimArrayValues($arr); } if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) { $this->_convertNullArrayValuesToEmpty($arr); } return DB_OK; }
function seek($pos) { $i = 0; while ($i < $pos && @OCIFetchInto($this->Query_ID, $result, OCI_ASSOC + OCI_RETURN_NULLS)) { $i++; } $this->Row += $i; return true; }
/** * Retrieves a single row from the database and returns it as an array. * * <b>Note:</b> We don't use the more useful xxx_fetch_array because not all * databases support this function. * * <b>Note:</b> Use the {@link dbi_error()} function to get error information * if the connection fails. * * @param resource $res The database query resource returned from * the {@link dbi_query()} function. * * @return mixed An array of database columns representing a single row in * the query result or false on an error. */ function dbi_fetch_row($res) { if (strcmp($GLOBALS["db_type"], "mysql") == 0) { return mysql_fetch_array($res); } else { if (strcmp($GLOBALS["db_type"], "mysqli") == 0) { return mysqli_fetch_array($res); } else { if (strcmp($GLOBALS["db_type"], "mssql") == 0) { return mssql_fetch_array($res); } else { if (strcmp($GLOBALS["db_type"], "oracle") == 0) { if (OCIFetchInto($GLOBALS["oracle_statement"], $row, OCI_NUM + OCI_RETURN_NULLS)) { return $row; } return 0; } else { if (strcmp($GLOBALS["db_type"], "postgresql") == 0) { if (@$GLOBALS["postgresql_numrows[\"{$res}\"]"] > @$GLOBALS["postgresql_row[\"{$res}\"]"]) { $r = pg_fetch_array($res, @$GLOBALS["postgresql_row[\"{$res}\"]"]); @$GLOBALS["postgresql_row[\"{$res}\"]"]++; if (!$r) { echo "Unable to fetch row\n"; return ''; } } else { $r = ''; } return $r; } else { if (strcmp($GLOBALS["db_type"], "odbc") == 0) { if (!odbc_fetch_into($res, $ret)) { return false; } return $ret; } else { if (strcmp($GLOBALS["db_type"], "ibm_db2") == 0) { return db2_fetch_array($res); } else { if (strcmp($GLOBALS["db_type"], "ibase") == 0) { return ibase_fetch_row($res); } else { dbi_fatal_error("dbi_fetch_row(): db_type not defined."); } } } } } } } } }
/** * FUNCTION: setDbLoop [** EXPERIMENTAL **] * * Function to create a loop from a Db result resource link. * * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() * @param string $result link to a Db result resource * @param string $db_type, type of db that the result resource belongs to. * @return boolean true/false * @access public */ function setDbLoop($loopname, $result, $db_type = 'MYSQL') { $db_type = strtoupper($db_type); if (!in_array($db_type, $this->allowed_loop_dbs)) { vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type); return false; } $loop_arr = array(); switch ($db_type) { case 'MYSQL': if (get_resource_type($result) != 'mysql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = mysql_fetch_assoc($result)) { $loop_arr[] = $r; } break; case 'POSTGRESQL': if (get_resource_type($result) != 'pgsql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } $nr = function_exists('pg_num_rows') ? pg_num_rows($result) : pg_numrows($result); for ($i = 0; $i < $nr; $i++) { $loop_arr[] = pg_fetch_array($result, $i, PGSQL_ASSOC); } break; case 'INFORMIX': if (!$result) { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = ifx_fetch_row($result, 'NEXT')) { $loop_arr[] = $r; } break; case 'INTERBASE': if (get_resource_type($result) != 'interbase result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = ibase_fetch_row($result)) { $loop_arr[] = $r; } break; case 'INGRES': if (!$result) { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = ingres_fetch_array(INGRES_ASSOC, $result)) { $loop_arr[] = $r; } break; case 'MSSQL': if (get_resource_type($result) != 'mssql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = mssql_fetch_array($result)) { $loop_arr[] = $r; } break; case 'MSQL': if (get_resource_type($result) != 'msql result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = msql_fetch_array($result, MSQL_ASSOC)) { $loop_arr[] = $r; } break; case 'OCI8': if (get_resource_type($result) != 'oci8 statement') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while (OCIFetchInto($result, $r, OCI_ASSOC + OCI_RETURN_LOBS)) { $loop_arr[] = $r; } break; case 'ORACLE': if (get_resource_type($result) != 'oracle Cursor') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while (ora_fetch_into($result, $r, ORA_FETCHINTO_ASSOC)) { $loop_arr[] = $r; } break; case 'OVRIMOS': if (!$result) { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while (ovrimos_fetch_into($result, $r, 'NEXT')) { $loop_arr[] = $r; } break; case 'SYBASE': if (get_resource_type($result) != 'sybase-db result') { vlibTemplateError::raiseError('VT_WARNING_INVALID_RESOURCE', WARNING, $db_type); return false; } while ($r = sybase_fetch_array($result)) { $loop_arr[] = $r; } break; } $this->setLoop($loopname, $loop_arr); return true; }