Wednesday, August 26, 2009

Connecting to Oracle via php

 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";

No comments:

Post a Comment