One of the problems of using CakePHP with an Oracle database is that CakePHP does not utilize bind variables. One of the advantages of Oracle is that it can cache query results based on queries, as long as those queries use bind variables and not strings. An example of a query using binds looks like:
SELECT * FROM my_table WHERE id = :myBind;
$bingArray = array( 'myBind' => 12 );
When I first started working with Oracle, I was not aware of the usefulness of bind variables. But after an application I had written that did not use bind variables failed to maintain stability under heavy load, a more experience Oracle developer sat down with me and helped me test the application with bind variables. We saw a great increase in stability under high loads and I was sold. CakePHP had to utilize bind variables.

After a ton of debugging and a lot of live testing on a site that gets 5+ million visitors a month, I am finally ready to release the CakePHP 1.2 Oracle connection class. During development of the class, a lot of the inherited methods from dbo_source.php had to be moved into dbo_oracle.php in order to get things to work correctly. Something that is missing is a way to debug the actual value of the bind variables. I wrote a custom debug level which allowed us to turn on output of just the queries or of the queries and the bind variable values.

This change removes the need for use of the clob and blob behaviors.

Downloads: dbo_source.php | dbo_oracle.php
Views  1085 Comments  1
Filed under: CakePHP, Oracle, Web Development
Add Comment
Francesco Ronchi
hello, we are trying your dbo_oracle on cakephp version 1.2.2.8120 and we experienced some issue. - the name of the class is "DboPostgres" instead of DboOracle - both dbo_oracle and dbo_source are missing the "calculate()" method (we added it from the original dbo_source) - after installing the files, the setConfig() method in datasource.php complained about the 2nd argunent not being an array: we patched it in this quick & dirty way: function setConfig($config = array()) { $this->config = array_merge($this->_baseConfig, (is_array($this->config)?$this->config:array()), $config); } after these changes, the class seems to work ok, but we are still testing it. if you want we can give you feedback. thanks for your nice job. Francesco - http://www.crop.it
View Chris Thompson's profile on LinkedIn
Loading...