PHP Oracle oci8 example

<?php
$conn = oci_connect('username', 'usernames_password', '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = mydatabase.example.com)(PORT = 1521))) (CONNECT_DATA = (SID = enter_your_database_sid))) ');

$query = "SELECT * FROM IU_FP_CUSTOMER where USERNAME='wsams'";

$stid = oci_parse($conn, $query);

$r = oci_execute($stid, OCI_DEFAULT);

while($row = oci_fetch_assoc($stid))
{
        print_r($row);
}

oci_close($conn);
?>
 

If you use oci_fetch_array(), you can use it as follows,

<?php
$an_array = oci_fetch_array($stid_query, (OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS));
?>

Some fields are returned as objects. The OCI_RETURN_LOBS returns the values of the objects in the array so you don't have to parse them out.

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.