Showing posts with label oci8. Show all posts
Showing posts with label oci8. Show all posts

Thursday, October 22, 2009

OCI8

You need the following (once logged in) from Oracle Instant Client:

  • oracle-instantclient-basic
  • oracle-instantclient-devel

You also need to install two PHP related packages, namely:

  • php-pear
  • php-devel

You might need to update the channel data of pear and pecl by:

  • pear channel-update pear.php.net
  • pecl channel-update pecl.php.net

Now you should be able to install oci8 with the following command:

  • sudo pecl install oci8

Finally edit /etc/php.ini and add the line bellow in the extensions section:

  • extension=oci8.so

See also the php-oracle manual

Example

       # Here's how we connect:
$dbh = oci_connect ('USERNAME', 'PASSWD', '//172.31.5.337:1521/ORACL');
# Here's how we pass an sql statement:
$stmt = oci_parse ($dbh, 'SELECT USERNAME, PASSWORD FROM TABLE');
# Here we execute the statement:
oci_execute ($stmt);
$cnt = 1;
# Then we fetch rows in a loop until we're done
while ($result = oci_fetch_array($stmt)) {
echo "user: " . $cnt . " " . $result['USERNAME'] .
" " . $result['PASSWORD'] . "
";
$cnt = $cnt +1;
}
# last we close the database handle
oci_close($dbh);
# and note to the parser that this is the end of the php code section