Membuat Query sederhana


// Create connection to Oracle

$conn = oci_connect(”hr”, “hrpwd”, “//localhost/orcl”);


$query = ’select * from departments’;

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

$r = oci_execute($stid);


// Fetch the results in an associative array

print ‘<table border=”1″>’;

while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC)) {

   print ‘<tr>’;

   foreach ($row as $item) {

      print ‘<td>’.($item?htmlentities($item):’ ’).’</td>’;


   print ‘</tr>’;


print ‘</table>’;


// Close the Oracle connection




The oci_parse() function parses the statement.

The oci_execute() function executes the parsed statement.

The oci_fetch_array() function retrieves the results of the query as an associative array, and includes nulls.


Pada Web browser, ketikkan URL untuk menampilkan output:


Posting kali ini berasal dari,


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )


Connecting to %s