Ask Your Question

Revision history [back]

The method for retrieving information from an Oracle database using PHP involves the following steps:

  1. Install the required Oracle database extension for PHP.

  2. Establish a connection to the Oracle database using the oci_connect() function.

  3. Prepare a SQL statement using the oci_parse() function.

  4. Execute the SQL statement using the oci_execute() function.

  5. Fetch the result set using the ocifetcharray(), ocifetchassoc(), or ocifetchobject() functions.

  6. Process the result set as required.

  7. Close the connection to the Oracle database using the oci_close() function.

Example code:

// prepare and execute SQL statement $sql = 'SELECT firstname, lastname FROM employees'; $statement = ociparse($conn, $sql); ociexecute($statement);

// fetch and process result set while ($row = ocifetcharray($statement, OCIASSOC)) { echo $row['FIRSTNAME'] . ' ' . $row['LAST_NAME'] . '
'; }

// close connection to Oracle database oci_close($conn); ?>