Skip to content

Instantly share code, notes, and snippets.

@carlopires
Created February 25, 2013 20:52
Show Gist options
  • Save carlopires/5033177 to your computer and use it in GitHub Desktop.
Save carlopires/5033177 to your computer and use it in GitHub Desktop.
Demo of using PHP OCI in a Oracle server
<?php
$ORACLE_HOST = "127.0.0.1";
$ORACLE_PORT = "1521";
$ORACLE_SID = "mysid";
$ORACLE_USER = "myuser";
$ORACLE_PASSWORD = "mypass";
$ORACLE_DSN = "
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $ORACLE_HOST)(PORT = $ORACLE_PORT))
(CONNECT_DATA = (SID = $ORACLE_SID)) )";
$conn = oci_connect($ORACLE_USER, $ORACLE_PASSWORD, $ORACLE_DSN, 'utf8');
if ($conn) {
$st = oci_parse($conn, "CREATE TABLE TEST(id integer, val integer, primary key (id))");
oci_execute($st);
$st = oci_parse($conn, "INSERT INTO TEST(id, val) VALUES (1,2)");
oci_execute($st);
$st = oci_parse($conn, "UPDATE TEST SET val=3 WHERE id=1");
oci_execute($st);
$st = oci_parse($conn, "DROP TABLE TEST");
oci_execute($st);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment