How can Oracle functions be integrated into PHP?
To integrate Oracle functions into PHP, you can use the OCI8 extension which provides functions for interacting with Oracle databases. First, ensure that the OCI8 extension is installed and enabled in your PHP environment. Then, you can use functions like oci_connect() to establish a connection to the Oracle database, oci_parse() to prepare and execute SQL statements, and oci_fetch_array() to retrieve results from queries.
// Connect to Oracle database
$conn = oci_connect('username', 'password', 'localhost/orcl');
// Prepare and execute SQL statement
$query = 'SELECT * FROM employees';
$stid = oci_parse($conn, $query);
oci_execute($stid);
// Fetch results
while ($row = oci_fetch_array($stid, OCI_ASSOC)) {
echo $row['EMPLOYEE_ID'] . " - " . $row['FIRST_NAME'] . " " . $row['LAST_NAME'] . "<br>";
}
// Close connection
oci_close($conn);