Membuat Query sederhana

<?php

// 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

oci_close($conn); 

 

?>

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:

http://localhost/~phplab/query.php

Posting kali ini berasal dari http://www.oracle.com/technology/obe/11gr1_db/appdev/php/php.htm,

Tinggalkan Balasan

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

Logo WordPress.com

You are commenting using your WordPress.com 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 )

Foto Google+

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

Connecting to %s