Update 22 May 2012 –
I just check with CakePHP 2.1.2 and it works fine. I also update some of the library and hopefully you guys can also contribute . https://bitbucket.org/odin88/cakephp-2.0-oracle
One of the clients where I work at is using Oracle 9i. We are still using CakePHP 1.3 for that project.The reason we still using the 1.x version because there is no support for Oracle database.
So i took some initiative to make it work. Mind you this is not using Oracle PDO because as you can see in this website they stated that it is still experimental.
I grab CakePHP 2.0.5 and add this database config
public $default = array(
'datasource' => 'Database/Oracle',
'driver' => 'oracle',
'connect' => 'oci_pconnect',
'persistent' => false,
'host' => 'ip_address',
'login' => 'username',
'password' => 'password',
'database' => 'ip_address:1521/test',
'prefix' => '',
'schema' => 'schema_name'
);
Create Oracle.php and put inside /lib/Cake/Model/Datasource/Database
U can copy the contents from oracle datasource from CakePHP 1.3 or just download from here.
in line 20 i put App:uses
App::uses('DboSource', 'Model/Datasource');
Rename the class name from
class DboOracle extends DboSource {
to
class Oracle extends DboSource {
And now we need to hack the core by just commenting line 650 and 661 DboSource.php located in /lib/Cake/Model/Datasource.
//if ($this->hasResult()) {
$first = $this->fetchRow();
if ($first != null) {
$out[] = $first;
}
while ($item = $this->fetchResult()) {
if (isset($item[0])) {
$this->fetchVirtualField($item);
}
$out[] = $item;
}
//}
The reason we comment $this->hasResult() is because the method is checking whether we are using PDOStatement or not .
public function hasResult() {
return is_a($this->_result, 'PDOStatement');
}
// It is better to just override the function hasResult() in Oracle.php and return true;
function hasResult()
{
return true;
}
So far I have tested functions like find(‘first’) and find(‘all’) and so far so good .. I will post any updates whether the Stored Procedure is working or not.
Enjoy ..
Update on 22 May 2012 – The stored procedure works fine 🙂
p/s : This tutorial is requested by @jose_zap so I try my best to explain. ^_^