public function field_data() { $retval = array(); for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++) { $F = new stdClass(); $F->name = oci_field_name($this->stmt_id, $c); $F->type = oci_field_type($this->stmt_id, $c); $F->max_length = oci_field_size($this->stmt_id, $c); $retval[] = $F; } return $retval; }
/** * Returns an array of fields according to columns in the result. * * @return \Bitrix\Main\Entity\ScalarField[] */ public function getFields() { if ($this->resultFields == null) { $this->resultFields = array(); if (is_resource($this->resource)) { $numFields = oci_num_fields($this->resource); if ($numFields > 0 && $this->connection) { $helper = $this->connection->getSqlHelper(); for ($i = 1; $i <= $numFields; $i++) { $name = oci_field_name($this->resource, $i); $type = oci_field_type($this->resource, $i); $parameters = array("precision" => oci_field_precision($this->resource, $i), "scale" => oci_field_scale($this->resource, $i), "size" => oci_field_size($this->resource, $i)); $this->resultFields[$name] = $helper->getFieldByColumnType($name, $type, $parameters); } } } } return $this->resultFields; }
function _FetchField($fieldOffset = -1) { global $QUERCUS; $fld = new ADOFieldObject(); if (!empty($QUERCUS)) { $fld->name = oci_field_name($this->_queryID, $fieldOffset); $fld->type = oci_field_type($this->_queryID, $fieldOffset); $fld->max_length = oci_field_size($this->_queryID, $fieldOffset); //if ($fld->name == 'VAL6_NUM_12_4') $fld->type = 'NUMBER'; switch ($fld->type) { case 'string': $fld->type = 'VARCHAR'; break; case 'real': $fld->type = 'NUMBER'; break; } } else { $fieldOffset += 1; $fld->name = oci_field_name($this->_queryID, $fieldOffset); $fld->type = oci_field_type($this->_queryID, $fieldOffset); $fld->max_length = oci_field_size($this->_queryID, $fieldOffset); } switch ($fld->type) { case 'NUMBER': $p = oci_field_precision($this->_queryID, $fieldOffset); $sc = oci_field_scale($this->_queryID, $fieldOffset); if ($p != 0 && $sc == 0) { $fld->type = 'INT'; } $fld->scale = $p; break; case 'CLOB': case 'NCLOB': case 'BLOB': $fld->max_length = -1; break; } return $fld; }
private function _getColumnMeta($stmt, $columnIndex = 0) { $meta['name'] = \strtoupper(oci_field_name($stmt, $columnIndex + 1)); $meta['len'] = oci_field_size($stmt, $columnIndex + 1); $type = oci_field_type($stmt, $columnIndex + 1); $rType = 'C'; if ($type == "VARCHAR") { $rType = 'C'; } elseif ($type == "CHAR") { $rType = 'C'; } elseif ($type == "NUMBER") { $rType = 'N'; } elseif ($type == "DATE") { $rType = 'D'; } elseif ($type == "TIMESTAMP") { $rType = 'D'; } elseif ($type == "BLOB") { $rType = 'O'; } elseif ($type == "CLOB") { $rType = 'O'; } $meta['type'] = $rType; return $meta; }
public function FieldSize($statement, $field) { return oci_field_size($statement, $field); }
/** * Returns metadata for all columns in a result set. * * @return array */ public function getColumnsMeta() { $count = oci_num_fields($this->resultSet); $meta = array(); for ($i = 1; $i <= $count; $i++) { // items 'name' and 'table' are required $meta[] = array('name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'type' => oci_field_type($this->resultSet, $i), 'size' => oci_field_size($this->resultSet, $i), 'scale' => oci_field_scale($this->resultSet, $i), 'precision' => oci_field_precision($this->resultSet, $i)); } return $meta; }
public function getField($field) { set_error_handler(static::getErrorHandler()); $name = oci_field_name($this->resource, $field); $precision = oci_field_precision($this->resource, $field); $scale = oci_field_scale($this->resource, $field); $size = oci_field_size($this->resource, $field); $rawType = oci_field_type_raw($this->resource, $field); $type = oci_field_type($this->resource, $field); $value = oci_field_is_null($this->resource, $field) ? null : oci_result($this->resource, $field); $field = new Oci8Field($name, $value, $size, $precision, $scale, $type, $rawType); restore_error_handler(); return $field; }
public function get_columns($stmt = null) { $stmt = is_null($stmt) ? $this->__cur : $stmt; $cols = array(); $ncol = oci_num_fields($stmt); for ($i = 1; $i <= $ncol; $i++) { $cols[] = array('native_type' => oci_field_type($stmt, $i), 'flags' => array(), 'name' => oci_field_name($stmt, $i), 'len' => oci_field_size($stmt, $i), 'pdo_type' => oci_field_type_raw($stmt, $i)); } return $cols; }
/** * Returns metadata for a column in a result set. * * @param int #column The 0-indexed column in the result set. * @return array Returns an associative array representing the metadata for a single column */ public function getColumnMeta($column) { if (!is_int($column)) { throw new OCIException($this->setErrorInfo('0A000', '9999', "Invalid Column type specfied: {$column}. Expecting an int.")); } $column++; return ['native_type' => oci_field_type($this->stmt, $column), 'driver:decl_type' => oci_field_type_raw($this->stmt, $column), 'name' => oci_field_name($this->stmt, $column), 'len' => oci_field_size($this->stmt, $column), 'precision' => oci_field_precision($this->stmt, $column)]; }
public function columnData() { if (empty($this->query)) { return false; } $columns = array(); for ($i = 1, $c = $this->num_fields(); $i <= $c; $i++) { $field = new stdClass(); $field->name = oci_field_name($this->query, $i); $field->type = oci_field_type($this->query, $i); $field->maxLength = oci_field_size($this->query, $i); $columns[] = $field; } return $columns; }
/** * Returns metadata for a column in a result set. * The array returned by this function is patterned after that * returned by \PDO::getColumnMeta(). It includes the following * elements: * native_type * driver:decl_type * flags * name * table * len * precision * pdo_type * * @param int $column The 0-indexed column in the result set. * @return array An associative array containing the above metadata values * for a single column. */ public function getColumnMeta($column) { // Columns in oci8 are 1-based; add 1 if it's a number if (is_numeric($column)) { $column++; } $meta = array(); $meta['native_type'] = oci_field_type($this->sth, $column); $meta['driver:decl_type'] = oci_field_type_raw($this->sth, $column); $meta['flags'] = array(); $meta['name'] = oci_field_name($this->sth, $column); $meta['table'] = null; $meta['len'] = oci_field_size($this->sth, $column); $meta['precision'] = oci_field_precision($this->sth, $column); $meta['pdo_type'] = null; $meta['is_null'] = oci_field_is_null($this->sth, $column); return $meta; }
public static function getColumnMeta($index, $sql) { if ($sql && $index >= 0) { $newmeta = array(); $newmeta["name"] = oci_field_name($sql, $index + 1); $newmeta["native_type"] = oci_field_type($sql, $index + 1); $newmeta["len"] = oci_field_size($sql, $index + 1); return $newmeta; } return false; }
public function getColumnMeta($column) { if ($column >= $this->columnCount()) { return false; } $column++; $result = array(); $result['native_type'] = oci_field_type($this->_result, $column); if (oci_field_is_null($this->_result, $column)) { $result['flags'] = 'is_null'; } $result['name'] = oci_field_name($this->_result, $column); $result['len'] = oci_field_size($this->_result, $column); $result['precision'] = oci_field_precision($this->_result, $column) . '.' . oci_field_scale($this->_result, $column); $result['pdo_type'] = PDO::PARAM_STR; return $result; }
/** * Returns the length of the specified column * * @access public * @param integer $Column * @return integer */ function getColumnLength($iColumn) { if ((is_int($iColumn) or is_string($iColumn)) && $iColumn < oci_num_fields($id)) { $id = $this->curs_id ? $this->curs_id : $this->stmt_id; if (is_int($iColumn)) { $iColumn++; return oci_field_size($id, $iColumn); } else { return false; } } else { if ($this->db_debug) { log_message('error', 'Class CI_DB_oci10_result ' . "\t" . 'Method ' . __METHOD__ . ' ' . PHP_EOL . "\t\t" . 'Wrong parameter ' . $iColumn . '. Nb Max COlumns : ' . oci_num_fields($id) . PHP_EOL . " Connexion data " . PHP_EOL . " username : "******" hostname : " . $this->hostname . PHP_EOL . " database : " . $this->database . PHP_EOL . " dbdriver : " . $this->dbdriver . PHP_EOL . " dbprefix : " . $this->dbprefix . PHP_EOL . " port : " . $this->port); return $this->display_error('db_wrong_parameter', $iColumn); } return false; } }
public function columnData($col = '') { if (empty($this->query)) { return false; } $columns = []; $count = $this->numFields(); for ($i = 1; $i <= $count; $i++) { $fieldName = oci_field_name($this->query, $i); $columns[$fieldName] = new \stdClass(); $columns[$fieldName]->name = $fieldName; $columns[$fieldName]->type = oci_field_type($this->query, $i); $columns[$fieldName]->maxLength = oci_field_size($this->query, $i); $columns[$fieldName]->primaryKey = NULL; $columns[$fieldName]->default = NULL; } if (isset($columns[$col])) { return $columns[$col]; } return $columns; }
function oracleMetadata(&$db) { $id = $db->Query_ID; $META = new stdClass(); #echo "SQL=".$db->LastSQL."<br>"; #echo "Columnas =".OCINumcols($id)."<br>"; $META->cols = array(); for ($ix = 1; $ix <= OCINumcols($id); $ix++) { $col = oci_field_name($id, $ix); $type = oci_field_type_raw($id, $ix); $presicion = oci_field_precision($id, $ix); $escala = oci_field_scale($id, $ix); $standarType = MetaStandardType("Oracle", $type, $escala); $META->colsbyname["{$col}"] = new stdClass(); $META->colsbyname["{$col}"]->{"type"} = $standarType; $META->colsbyname["{$col}"]->{"precision"} = $presicion; $META->colsbyname["{$col}"]->{"scale"} = $escala; $META->colsbyname["{$col}"]->{"size"} = oci_field_size($id, $ix); $META->colsbyname["{$col}"]->{"is_null"} = oci_field_is_null($id, $ix); $META->colsbyname["{$col}"]->{"type_raw"} = $type; $META->cols[$ix - 1] = new stdClass(); $META->cols[$ix - 1]->{"type"} = $standarType; $META->cols[$ix - 1]->{"precision"} = $presicion; $META->cols[$ix - 1]->{"scale"} = $escala; $META->cols[$ix - 1]->{"size"} = oci_field_size($id, $ix); $META->cols[$ix - 1]->{"is_null"} = oci_field_is_null($id, $ix); $META->cols[$ix - 1]->{"type_raw"} = $type; //if($db->Debug) #echo"<b>[$col]</b>:" #.$META->colsbyname["$col"]->type #.' '.$META->colsbyname["$col"]->size #.' Presicion='.$META->colsbyname["$col"]->precision #.' Ecala='.$META->colsbyname["$col"]->scale #.' '.$META->colsbyname["$col"]->is_null #.' type='.$META->colsbyname["$col"]->type_raw #.' '."<br>\n"; } return $META; }
public function getColumnMeta($column) { if ($column >= $this->columnCount()) { return false; } $column++; $result = array('native_type' => oci_field_type($this->_result, $column), 'name' => oci_field_name($this->_result, $column), 'len' => oci_field_size($this->_result, $column), 'precision' => oci_field_precision($this->_result, $column) . '.' . oci_field_scale($this->_result, $column), 'pdo_type' => EhrlichAndreas_Pdo_Abstract::PARAM_STR); if (oci_field_is_null($this->_result, $column)) { $result['flags'] = 'is_null'; } return $result; }
public function metadata($tablename = null) { $ncols = oci_num_fields($this->statement); if ($ncols) { $column_names = array(); $column_types = array(); $column_sizes = array(); for ($i = 1; $i <= $ncols; $i++) { $column_names[$i] = oci_field_name($this->statement, $i); } for ($i = 1; $i <= $ncols; $i++) { $column_types[$i] = oci_field_type($this->statement, $i); } for ($i = 1; $i <= $ncols; $i++) { $column_sizes[$i] = oci_field_size($this->statement, $i); } return new OracleMetadata($column_names, $column_types, $column_sizes, $this->rows(), $tablename); } else { throw new Exception('No metadata to fetch'); } }
public static function oci_field_size($connection, $statement, $fieldNumber) { self::checkOCIExtension('oci_field_size'); $size = @oci_field_size($statement, $fieldNumber); if ($size === FALSE) { $error = self::oci_error($statement); throw new IllegalStateException(t( "Could not retrieve field's (field number: %fieldNumber) size: %error", array('%fieldNumber' => $fieldNumber, '%error' => t($error['message'])))); } return $size; }
/** * Get column information in the Recordset object. * fetchField() can be used in order to obtain information about fields * in a certain query result. If the field offset isn't specified, the next * field that wasn't yet retrieved by fetchField() is retrieved * * @return object containing field information */ function _FetchField($fieldOffset = -1) { $fld = new ADOFieldObject(); $fieldOffset += 1; $fld->name = oci_field_name($this->_queryID, $fieldOffset); if (ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER) { $fld->name = strtolower($fld->name); } $fld->type = oci_field_type($this->_queryID, $fieldOffset); $fld->max_length = oci_field_size($this->_queryID, $fieldOffset); switch ($fld->type) { case 'NUMBER': $p = oci_field_precision($this->_queryID, $fieldOffset); $sc = oci_field_scale($this->_queryID, $fieldOffset); if ($p != 0 && $sc == 0) { $fld->type = 'INT'; } $fld->scale = $p; break; case 'CLOB': case 'NCLOB': case 'BLOB': $fld->max_length = -1; break; } return $fld; }
function PMA_DBI_field_len($result, $i) { return oci_field_size($result, $i); }
/** * Returns metadata for a column in a result set * * @param integer $column The 0-indexed column in the result set. * * @return array Associative meta data array with the following structure: * * native_type The PHP native type used to represent the column value. * driver:decl_ type The SQL type used to represent the column value in the database. If the column in the result set is the result of a function, this value is not returned by PDOStatement->getColumnMeta(). * flags Any flags set for this column. * name The name of this column as returned by the database. * len The length of this column. Normally -1 for types other than floating point decimals. * precision The numeric precision of this column. Normally 0 for types other than floating point decimals. * pdo_type The type of this column as represented by the PDO::PARAM_* constants. */ public function getColumnMeta($column) { if (is_integer($column)) { $internal_column = $column + 1; } else { $internal_column = $column; } $data = array(); $data['native_type'] = oci_field_type($this->statement, $internal_column); $data['flags'] = ""; $data['len'] = oci_field_size($this->statement, $internal_column); $data['name'] = oci_field_name($this->statement, $internal_column); $data['precision'] = oci_field_precision($this->statement, $internal_column); return $data; }
function field_info($query, $count) { if ($this->debug) { echo "<pre style=\"color : green\">Getting column information {$this->dbpath} <p style=\"color:purple;\"> {$query} </p></pre>"; } $nooffields = 0; //Validate the sql statement and make adjustments switch ($this->dbtype) { /* Firebird Functionality */ case "firebird": //write some things here $col_info = ibase_field_info($query, $count); break; /* SQLite Functionality */ /* SQLite Functionality */ case "sqlite": putenv("TMP=" . $this->tmppath); $name = sqlite_field_name($query, $count); //echo $name; $col_info["alias"] = $name; $col_info["name"] = $name; break; /* Oracle Functionality */ /* Oracle Functionality */ case "oracle": $column_name = oci_field_name($query, $count); $column_type = oci_field_type($query, $count); $column_size = oci_field_size($query, $count); $column_prec = oci_field_precision($query, $count); $column_scale = oci_field_scale($query, $count); $col_info["name"] = $column_name; $col_info["alias"] = $column_name; $col_info["length"] = $column_size; $col_info["prec"] = $column_prec; $col_info["type"] = $column_type; $col_info["scale"] = $column_scale; break; /* PGSQL Functionality */ /* PGSQL Functionality */ case "pgsql": $col_info["name"] = pg_field_name($query, $count); $col_info["alias"] = NULL; // always set to NULL $col_info["relation"] = NULL; // always set to NULL $col_info["length"] = pg_field_size($query, $count); $col_info["type"] = pg_field_type($query, $count); break; } if ($this->debug) { echo "<pre style=\"color : blue\">Column Info fetched for Column {$count} \n </pre>"; } return $col_info; }
/** * Get column meta data * * @param int $colnum column number * * @return mixed column meta data */ public function getColumnMeta($colnum = 0) { if (!$this->_stmt) { return null; } $name = \oci_field_name($this->_stmt, $colnum + 1); $len = \oci_field_size($this->_stmt, $colnum + 1); $prec = \oci_field_scale($this->_stmt, $colnum + 1); $type = \oci_field_type($this->_stmt, $colnum + 1); return array("name" => $name, "len" => $len, "precision" => $prec, "driver:decl_type" => $type); }
/** * Ejecuta la consulta pasada por paranetro sobre la base de datos y retorna los resultados * de la consulta. * * @method ejecutarConsulta() * @author damanzano * @param string $sql Consulta que se desea consultar */ public function ejecutarConsulta($sql) { $statement = oci_parse($this->myconn, $sql); if (!$statement) { $e = oci_error($statement); $this->error = "Error al procesar la consulta<br>" . htmlentities($e['message']); die($this->error); } oci_execute($statement, OCI_DEFAULT); $this->numcols = oci_num_fields($statement); $this->numfilas = oci_num_rows($statement); //Si la consulta fue un select se guarda la información de los nombres y tipos de las //columnas que vienen en el resultado if (oci_statement_type($statement) == 'SELECT') { for ($n = 1; $n <= $this->numcols; $n++) { $this->nomcols[$n] = oci_field_name($statement, $n); $this->tipocols[$n] = oci_field_type($statement, $n); $this->tamcols[$n] = oci_field_size($statement, $n); } } return $statement; }