If you are connecting to an Oracle database, first ensure that your php_oci8 extension is installed. A simple php page can show you this:
<?php
phpinfo();
?>
View the page and you should see a heading "OCI8" and it should tell you the version and if it is enabled.
Next ensure you can talk to the database. Another simple php file can do this for you. This page will list all tables in the database (code from Oracle's website)
<?php
$conn = oci_connect('username', 'password', 'host/database');
$stid = oci_parse($conn, 'select table_name from user_tables');
oci_execute($stid);
echo "
\n";
while (($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) != false) {
echo "\n";
foreach ($row as $item) {
echo ' '.($item !== null ? htmlentities($item, ENT_QUOTES) : ' ')." | \n";
}
echo "
\n";
}
echo '
';
?>
Now that you know you can access your Oracle database via php, configure your CakePHP connection. Edit
/app/config/database.php
var $default = array(
'driver' => 'oracle',
'connect' => 'oci_connect',
'persistent' => false,
'host' => 'host',
'port' => 1521,
'login' => 'username',
'password' => 'password',
'database' => 'host:1521/database',
'prefix' => '',
);
And that's all there is to it.
No comments:
Post a Comment