Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

oci fetch array function syntax tag tutorial 2013





Alert! Connect with 10,000 Chating Online. Join Now

Php oci fetch array () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 5)

oci_fetch_array -- Returns the next row from the result data as an associative or numeric array, or both

Syntax

array oci_fetch_array ( resource statement [, int mode] )

Returns an array, which corresponds to the next result row or FALSE in case of error or there is no more rows in the result.

oci_fetch_array() returns an array with both associative and numeric indices.

Note: This function sets NULL fields to PHP NULL value.

Optional second parameter can be any combination of the following constants:

OCI_BOTH - return an array with both associative and numeric indices (the same as OCI_ASSOC + OCI_NUM). This is the default behavior.
OCI_ASSOC - return an associative array (as oci_fetch_assoc() works).
OCI_NUM - return a numeric array, (as oci_fetch_row() works).
OCI_RETURN_NULLS - create empty elements for the NULL fields.
OCI_RETURN_LOBS - return the value of a LOB of the descriptor.

Default mode is OCI_BOTH.

It should be mentioned here, that oci_fetch_array() is insignificantly slower, than oci_fetch_row(), but much more handy.

Note: Don't forget, that Oracle returns all field names in uppercase and associative indices in the result array will be uppercased too.

Example 1. oci_fetch_array() with OCI_BOTH example

<?php
$connection
= oci_connect("apelsin", "kanistra");

$query = "SELECT id, name FROM fruits";

$statement = oci_parse ($connection, $query);
oci_execute ($statement);

while (
$row = oci_fetch_array ($statement, OCI_BOTH)) {
    echo
$row[0]." and ".$row['ID']." is the same<br>";
    echo
$row[1]." and ".$row['NAME']." is the same<br>";
}
?>

Example 2. oci_fetch_array() with OCI_NUM example

<?php
$connection
= oci_connect("user", "password");

$query = "SELECT id, name, lob_field FROM fruits";

$statement = oci_parse ($connection, $query);
oci_execute ($statement);

while (
$row = oci_fetch_array ($statement, OCI_NUM)) {
    echo
$row[0]."<br>";
    echo
$row[1]."<br>";
    echo
$row[2]->read(100)."<br>";  //this will output first 100 bytes from LOB
}
?>

Example 3. oci_fetch_array() with OCI_ASSOC example

<?php
$connection
= oci_connect("user", "password");

$query = "SELECT id, name, lob_field FROM fruits";

$statement = oci_parse ($connection, $query);
oci_execute ($statement);

while (
$row = oci_fetch_array ($statement, OCI_NUM)) {
    echo
$row['ID']."<br>";
    echo
$row['NAME']."<br>";
    echo
$row['LOB_FIELD']."<br>";  //this will output "Object id #1"
}
?>

Example 4. oci_fetch_array() with OCI_RETURN_LOBS example

<?php
$connection
= oci_connect("user", "password");

$query = "SELECT id, name, lob_field FROM fruits";

$statement = oci_parse ($connection, $query);
oci_execute ($statement);

while (
$row = oci_fetch_array ($statement, OCI_NUM)) {
    echo
$row[0]."<br>";
    echo
$row[1]."<br>";
    echo
$row['LOB_FIELD']."<br>";  //this will output LOB's content
}
?>

See also oci_fetch_assoc(), oci_fetch_object(), oci_fetch_row() and oci_fetch_all().

Php oci fetch array Function syntax tag

oci fetch array php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php oci fetch array syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online