Example #1
1
 function db_columnType($oStmt, $iPos)
 {
     return oci_field_type($oStmt, $iPos);
 }
Example #2
0
 public function getResultFields()
 {
     if (empty($this->resultFields)) {
         $numFields = oci_num_fields($this->resource);
         for ($i = 0; $i < $numFields; $i++) {
             $this->resultFields[$i] = array("name" => oci_field_name($this->resource, $i + 1), "type" => oci_field_type($this->resource, $i + 1));
         }
     }
     return $this->resultFields;
 }
Example #3
0
 public static function oci_field_type($connection, $statement, $fieldNumber)
 {
     self::checkOCIExtension('oci_field_type');
     $type = @oci_field_type($statement, $fieldNumber);
     if ($type === FALSE) {
         $error = oci_error($connection);
         throw new IllegalStateException(t("Could not retrieve field's (field number: @fieldNumber) data type: @error", array('@fieldNumber' => $fieldNumber, '@error' => t($error['message']))));
     }
     return $type;
 }
 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;
 }
Example #5
0
 /**
  * @param String strSQL
  * @return Array
  */
 public function db_getfieldslist($strSQL)
 {
     $res = array();
     $qResult = $this->connectionObj->query($strSQL);
     $fieldsNumber = $qResult->numFields();
     for ($i = 0; $i < $fieldsNumber; $i++) {
         $stype = oci_field_type($qResult->getQueryHandle(), $i + 1);
         $ntype = $this->getFieldTypeNumber($stype);
         $res[$i] = array("fieldname" => $qResult->fieldName($i), "type" => $ntype, "is_nullable" => 0);
     }
     return $res;
 }
function db_getfieldslist($strSQL)
{
	global $conn;
	$res=array();
	$rs=db_query($strSQL,$conn);
	for($i=0;$i<db_numfields($rs);$i++)
	{
		$stype=oci_field_type($rs,$i+1);
		$ntype=db_fieldtypenum($stype);
		$res[$i]=array("fieldname"=>db_fieldname($rs,$i),"type"=>$ntype,"is_nullable"=>0);
	}
	return $res;
}
 function GetFields()
 {
     $_fields = array();
     $_st_id = oci_parse($this->_Link, $this->SelectCommand);
     if ($_st_id) {
         oci_execute($_st_id);
         //$_result = pg_query($this->_Link,$this->SelectCommand);
         $_num_fields = oci_num_fields($_st_id);
         for ($i = 1; $i <= $_num_fields; $i++) {
             $_field = array("Name" => oci_field_name($_st_id, $i), "Type" => oci_field_type($_st_id, $i), "Not_Null" => 0);
             array_push($_fields, $_field);
         }
     }
     return $_fields;
 }
Example #8
0
 /**
  * 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;
 }
Example #10
0
 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;
 }
Example #11
0
/**
 * Returns the next data set from a DB resource or false if there are no more results.
 *
 * @param resource $cursor
 * @param bool $convertNulls	convert all null values to string zeroes
 *
 * @return array|bool
 */
function DBfetch($cursor, $convertNulls = true)
{
    global $DB;
    $result = false;
    if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) {
        return $result;
    }
    switch ($DB['TYPE']) {
        case ZBX_DB_MYSQL:
            $result = mysqli_fetch_assoc($cursor);
            if (!$result) {
                mysqli_free_result($cursor);
            }
            break;
        case ZBX_DB_POSTGRESQL:
            if (!($result = pg_fetch_assoc($cursor))) {
                pg_free_result($cursor);
            }
            break;
        case ZBX_DB_ORACLE:
            if ($row = oci_fetch_assoc($cursor)) {
                $result = array();
                foreach ($row as $key => $value) {
                    $field_type = strtolower(oci_field_type($cursor, $key));
                    // Oracle does not support NULL values for string fields, so if the string is empty, it will return NULL
                    // convert it to an empty string to be consistent with other databases
                    $value = str_in_array($field_type, array('varchar', 'varchar2', 'blob', 'clob')) && is_null($value) ? '' : $value;
                    if (is_object($value) && strpos($field_type, 'lob') !== false) {
                        $value = $value->load();
                    }
                    $result[strtolower($key)] = $value;
                }
            }
            break;
        case ZBX_DB_DB2:
            if (!($result = db2_fetch_assoc($cursor))) {
                db2_free_result($cursor);
            } else {
                // cast all of the values to string to be consistent with other DB drivers: all of them return
                // only strings.
                foreach ($result as &$value) {
                    if ($value !== null) {
                        $value = (string) $value;
                    }
                }
                unset($value);
            }
            break;
        case ZBX_DB_SQLITE3:
            if ($DB['TRANSACTIONS'] == 0) {
                lock_sqlite3_access();
            }
            if (!($result = $cursor->fetchArray(SQLITE3_ASSOC))) {
                unset($cursor);
            } else {
                // cast all of the values to string to be consistent with other DB drivers: all of them return
                // only strings.
                foreach ($result as &$value) {
                    $value = (string) $value;
                }
                unset($value);
            }
            if ($DB['TRANSACTIONS'] == 0) {
                unlock_sqlite3_access();
            }
            break;
    }
    if ($result) {
        if ($convertNulls) {
            foreach ($result as $key => $val) {
                if (is_null($val)) {
                    $result[$key] = '0';
                }
            }
        }
        return $result;
    }
    return false;
}
Example #12
0
function sti_oracle_get_data($connection_string, $data_source_name, $query)
{
    $info = sti_oracle_parse_connection_string($connection_string);
    if ($info["privilege"] == "") {
        $conn = oci_connect($info["user_id"], $info["password"], $info["database"], $info["charset"]);
    } else {
        $conn = oci_pconnect($info["user_id"], $info["password"], $info["database"], $info["charset"], $info["privilege"]);
    }
    if ($conn === false) {
        $err = ocierror();
        return "ServerError:Could not connect {$err['message']}";
    }
    $query = sti_parse_query_parameters($query);
    $stmt = oci_parse($conn, $query);
    if ($stmt === false) {
        $err = oci_error($conn);
        return "ServerError:Parse Error {$err['message']}";
    } else {
        if (strpos($query, "cursor") !== false) {
            $curs = oci_new_cursor($conn);
            oci_bind_by_name($stmt, "cursor", $curs, -1, OCI_B_CURSOR);
        }
        if (oci_execute($stmt, OCI_COMMIT_ON_SUCCESS) === true) {
            if (isset($curs)) {
                if (oci_execute($curs, OCI_DEFAULT) === false) {
                    $err = oci_error();
                    return "ServerError:Cursor Execute Error {$err['message']}";
                }
                $stmt_curs = $curs;
            } else {
                $stmt_curs = $stmt;
            }
            $ncols = oci_num_fields($stmt_curs);
            $column_names = array();
            $column_types = array();
            for ($i = 1; $i <= $ncols; $i++) {
                $column_names[] = oci_field_name($stmt_curs, $i);
                $column_type = oci_field_type($stmt_curs, $i);
                $column_precision = oci_field_precision($stmt_curs, $i);
                $column_types[] = sti_oracle_get_column_type($column_type, $column_precision);
            }
            $xml_output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Database>";
            oci_fetch_all($stmt_curs, $data);
            for ($i = 0; $i < count($data[$column_names[0]]); $i++) {
                $xml_output .= "<{$data_source_name}>";
                for ($j = 0; $j < count($column_names); $j++) {
                    $value = $data[$column_names[$j]][$i];
                    if ($column_types[$j] == "base64Binary") {
                        $value = base64_encode($value);
                    }
                    if ($column_types[$j] == "dateTime" && strlen($value) > 0 && strpos($value, ".") > 0) {
                        $values = preg_split("/\\./", $value);
                        if (count($values) >= 3) {
                            if (strlen($values[2]) > 2) {
                                $value = $values[2] . '-' . $values[1] . '-' . $values[0];
                            } else {
                                $value = ((int) $values[2] >= 30 ? '19' . $values[2] : '20' . $values[2]) . '-' . $values[1] . '-' . $values[0];
                            }
                        }
                    } else {
                        $value = str_replace("&", "&amp;", $value);
                        $value = str_replace("<", "&lt;", $value);
                        $value = str_replace(">", "&gt;", $value);
                    }
                    $xml_output .= "<{$column_names[$j]}>{$value}</{$column_names[$j]}>";
                }
                $xml_output .= "</{$data_source_name}>";
            }
            $xml_output .= "</Database>";
            if (isset($curs)) {
                oci_free_statement($curs);
            }
            oci_free_statement($stmt);
        } else {
            $err = ocierror($stmt);
            return "ServerError:Execute Error {$err['message']} {$query}";
        }
    }
    return $xml_output;
}
Example #13
0
 /**
  * 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;
 }
Example #14
0
 /**
  * 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;
 }
Example #15
0
 /**
  * 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;
 }
Example #16
0
 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;
 }
 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');
     }
 }
if (!in_array($_SERVER["REMOTE_ADDR"], $cfg["sapos_get_data"]["allowed_ip"])) {
    exit;
}
$oci_db = "(DESCRIPTION =\n                    (ADDRESS = (PROTOCOL = TCP)(HOST = " . $cfg["sapos_get_data"]["oracle"]["host"] . ")(PORT = " . $cfg["sapos_get_data"]["oracle"]["port"] . "))\n                    (CONNECT_DATA = (SERVICE_NAME =" . $cfg["sapos_get_data"]["oracle"]["db"] . "))\n                )";
$oci_conn = oci_connect($cfg["sapos_get_data"]["oracle"]["user"], $cfg["sapos_get_data"]["oracle"]["pass"], $oci_db, 'UTF8');
$sql = "SELECT * FROM " . $cfg["sapos_get_data"]["db"]["stationen"]["entries"];
$statement = oci_parse($oci_conn, $sql);
oci_execute($statement);
$i = 0;
$insert_sql = array();
while ($row = oci_fetch_array($statement, OCI_ASSOC)) {
    //         echo "<pre>".print_r($row,true)."</pre>";
    $insert_a = array();
    $insert_b = array();
    foreach ($row as $key => $value) {
        switch (oci_field_type($statement, $key)) {
            case "VARCHAR2":
                $psql_type = "character varying(200)";
                $psql_value = "'" . addslashes($value) . "'";
                break;
            case "CHAR":
                $psql_type = "text";
                $psql_value = "'" . addslashes($value) . "'";
                break;
            case "NUMBER":
                if (strstr($value, ".")) {
                    $psql_type = "float";
                } else {
                    $psql_type = "integer";
                }
                $psql_value = str_replace(",", ".", $value);
Example #19
0
 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;
 }
Example #20
0
 /**
  * store the column types of the query
  */
 protected function setColumnTypes()
 {
     if (empty($this->columnTypes)) {
         $columns = $this->getColumnNames();
         foreach ($columns as $column) {
             $this->columnTypes[$column] = oci_field_type($this->statement->getResource(), $column);
         }
     }
 }
function DBfetch(&$cursor, $convertNulls = true)
{
    global $DB;
    $result = false;
    if (!isset($DB['DB']) || empty($DB['DB']) || is_bool($cursor)) {
        return $result;
    }
    switch ($DB['TYPE']) {
        case ZBX_DB_MYSQL:
            if (!($result = mysql_fetch_assoc($cursor))) {
                mysql_free_result($cursor);
            }
            break;
        case ZBX_DB_POSTGRESQL:
            if (!($result = pg_fetch_assoc($cursor))) {
                pg_free_result($cursor);
            }
            break;
        case ZBX_DB_ORACLE:
            if (ocifetchinto($cursor, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
                $result = array();
                foreach ($row as $key => $value) {
                    $field_type = zbx_strtolower(oci_field_type($cursor, $key));
                    $value = str_in_array($field_type, array('varchar', 'varchar2', 'blob', 'clob')) && is_null($value) ? '' : $value;
                    if (is_object($value) && zbx_stristr($field_type, 'lob') !== false) {
                        $value = $value->load();
                    }
                    $result[zbx_strtolower($key)] = $value;
                }
            }
            break;
        case ZBX_DB_DB2:
            if (!($result = db2_fetch_assoc($cursor))) {
                db2_free_result($cursor);
            } else {
                // cast all of the values to string to be consistent with other DB drivers: all of them return
                // only strings.
                foreach ($result as &$value) {
                    if ($value !== null) {
                        $value = (string) $value;
                    }
                }
                unset($value);
            }
            break;
        case ZBX_DB_SQLITE3:
            if ($DB['TRANSACTIONS'] == 0) {
                lock_sqlite3_access();
            }
            if (!($result = $cursor->fetchArray(SQLITE3_ASSOC))) {
                unset($cursor);
            } else {
                // cast all of the values to string to be consistent with other DB drivers: all of them return
                // only strings.
                foreach ($result as &$value) {
                    $value = (string) $value;
                }
                unset($value);
            }
            if ($DB['TRANSACTIONS'] == 0) {
                unlock_sqlite3_access();
            }
            break;
    }
    if ($convertNulls && $result) {
        foreach ($result as $key => $val) {
            if (is_null($val)) {
                $result[$key] = '0';
            }
        }
    }
    return $result;
}
Example #22
0
 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;
 }
Example #23
0
 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;
 }
 function executeStatement($stmt)
 {
     if (!oci_execute($stmt, OCI_DEFAULT)) {
         $this->lastError();
         oci_free_statement($stmt);
         return false;
     }
     $this->mAffectedRows[$stmt] = oci_num_rows($stmt);
     $this->mFetchCache[$stmt] = array();
     $this->mFetchID[$stmt] = 0;
     $this->mNcols[$stmt] = oci_num_fields($stmt);
     if ($this->mNcols[$stmt] == 0) {
         return $this->mLastResult;
     }
     for ($i = 1; $i <= $this->mNcols[$stmt]; $i++) {
         $this->mFieldNames[$stmt][$i] = oci_field_name($stmt, $i);
         $this->mFieldTypes[$stmt][$i] = oci_field_type($stmt, $i);
     }
     while (($o = oci_fetch_array($stmt)) !== false) {
         foreach ($o as $key => $value) {
             if (is_object($value)) {
                 $o[$key] = $value->load();
             }
         }
         $this->mFetchCache[$stmt][] = $o;
     }
     return $this->mLastResult;
 }
Example #25
0
 /**
  * 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);
 }
Example #26
0
/**
 * @todo add missing keys like in from mysqli_query (orgname, orgtable, flags, decimals)
 */
function PMA_DBI_get_fields_meta($result, $table = null)
{
    $fields = array();
    $num_fields = oci_num_fields($result);
    for ($i = 1; $i <= $num_fields; $i++) {
        $field = array();
        $field['name'] = oci_field_name($result, $i);
        $field['type'] = oci_field_type($result, $i);
        $field['max_length'] = oci_field_size($result, $i);
        $field['not_null'] = oci_field_is_null($result, $i);
        $field['table'] = $table;
        $fields[] = (object) $field;
        //$fields[] = oci_fetch_field($result, $i);
    }
    return $fields;
}
Example #27
0
 /**
  * Returns metadata for all columns in a result set.
  * @return array
  */
 public function getResultColumns()
 {
     $count = oci_num_fields($this->resultSet);
     $columns = [];
     for ($i = 1; $i <= $count; $i++) {
         $type = oci_field_type($this->resultSet, $i);
         $columns[] = ['name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'fullname' => oci_field_name($this->resultSet, $i), 'nativetype' => $type === 'NUMBER' && oci_field_scale($this->resultSet, $i) === 0 ? 'INTEGER' : $type];
     }
     return $columns;
 }
 public function FieldType($statement, int $field)
 {
     return oci_field_type($statement, $field);
 }
Example #29
0
 /**
  * Returns metadata for all columns in a result set.
  * @return array
  */
 public function getResultColumns()
 {
     $count = oci_num_fields($this->resultSet);
     $columns = array();
     for ($i = 1; $i <= $count; $i++) {
         $columns[] = array('name' => oci_field_name($this->resultSet, $i), 'table' => NULL, 'fullname' => oci_field_name($this->resultSet, $i), 'nativetype' => oci_field_type($this->resultSet, $i));
     }
     return $columns;
 }
Example #30
0
 /**
  * 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;
 }