This video describes how Oracle 12c database can be connected with PHP using XAMPP.
Pre-requisite:
1) XAMPP installation completed
https://www.apachefriends.org/download.html
2) Instant Client Package Download Link :
https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html
3) C:\instantclient_12_1 Add Path in Environment Variable
4) XAMPP Apache -- Config -- PHP.ini
extension=oci8_12c ; Use with Oracle Database 12c Instant Client
;extension=oci8_19 ; Use with Oracle Database 19 Instant Client
4) C:\xampp\htdocs\test.php
<?php
$conn = oci_connect('test', 'test', 'orcl1', 'AL32UTF8');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
Else echo "connection successful";
?>
---------------------------------------------------------------------------------------------------------------------
<?php
$conn = oci_connect('system', 'oracle', 'localhost/orcl', 'AL32UTF8');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
Else echo "connection successful";
?>
-----------------------------------------------------------------------------------------------------------------------
Example. oracle.php
<?php
$conn = oci_connect('hr', 'hr', 'orcl1', 'AL32UTF8');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
Else echo "connection successful";
?>
<html>
<head>
</head>
<body>
<h2>Test Results</h2>
<?php
$result =oci_parse($conn, "select department_name from departments");
oci_execute($result);
?>
<ul>
<?php
while ($row =oci_fetch_array($result))
{
?>
<li> <?php echo $row['DEPARTMENT_NAME']; ?> </li>
<?php
}
?>
</ul>
</body>
</head>
</html>
No comments:
Post a Comment