Connecting to Oracle via php
Settings
Below is an article based on an example of connection to an Oracle database through a php script. However it is not designed to configure your oracle server and oracle client. It ensure that you can access your oracle server from the web server using the SQLPlus.
We can normally connect to a server based on Oracle 8i.
You can find example of codes with other Oracle version on below link:
www.php.net
Requirements
It is essential to assemble PHP with Oracle8i module. Under windows, it is crucial to the php.ini to include the line
extension=php_oci8.dll
Example of code
$c1 = ocilogon("scott", "tiger", $db);
$c2 = ocilogon("scott", "tiger", $db);
function create_table($conn)
$stmt = ociparse($conn, "create table scott.hallo (test varchar2(64))");
ociexecute($stmt);
echo $conn . " created table\n\n";
function drop_table($conn)
$stmt = ociparse($conn, "drop table scott.hallo");
ociexecute($stmt);
echo $conn . " dropped table\n\n";
function insert_data($conn)
$stmt = ociparse($conn, "insert into scott.hallo
values('$conn' || ' ' || to_char(sysdate,'DD-MON-YY HH24:MI:SS'))");
ociexecute($stmt, OCI_DEFAULT);
echo $conn . " inserted hallo\n\n";
This is one of the easiest way to access Oracle amongst others.