I'm currently working in a project that use Oracle with Yii. I tried the OCI support on Active Record with Oracle and get some problem to make it working.
1.In CDbCommandBuilder there is a function called createInCondition($table,$columnName,$values,$prefix=null) where in this function there is a looping like this
The '&' character before $value variable make the value of $value changed. I have the primary key on Oracle table with NUMBER(16) data type and this make ActiveRecord can't find the record on database by it's Pk. After I remove the '&' character the Active Record can find the record on database by it's pk.
We can not use the '_' character in createUpdateCommand function as a variable. The current function generate update query that have some variable like _p0,_p1,_p2, The code was like this
… In Oracle the '' character has identified as invalid character every time I try to update my record. So I extend createUpdateCommand function in COciCommandBuilder and remove the '' character and it's work. The code will become like this
Please verify that this is a bug on Yii Oracle Active Record.
1.In CDbCommandBuilder there is a function called createInCondition($table,$columnName,$values,$prefix=null) where in this function there is a looping like this
The '&' character before $value variable make the value of $value changed. I have the primary key on Oracle table with NUMBER(16) data type and this make ActiveRecord can't find the record on database by it's Pk. After I remove the '&' character the Active Record can find the record on database by it's pk.
I had the same problem once, but now it works. Not sure, but seems a PHP version problem.
Reading PHP manuals, it says that if you use a foreach like foreach($values as &$value) and you alter the $value variable, you'll set the internal pointer of $values. So, $values[0] will not work.
However, remove the & is not a good idea, since the foreach objective is to alter the array. Instead this, copy the array to another array, as below:
This will not affect the original array.
Quote
2. We can not use the '_' character in createUpdateCommand function as a variable. The current function generate update query that have some variable like _p0,_p1,_p2, The code was like this
… In Oracle the '' character has identified as invalid character every time I try to update my record. So I extend createUpdateCommand function in COciCommandBuilder and remove the '' character and it's work. The code will become like this
I haven't understand very well: this happens in any kind of update? I have fields with '_' character and it works fine. Could you give more details?
I guess this is not related with the & usage. It is probably about identifying the PHP type of "NUMBER(16)" column type. Most likely, the typecast() call changes the value to a string while Oracle expects an integer.
I'm not sure about this. Why would underscore in parameter placeholders affect SQL execution?
For the first case I will follow the Qiang solution. I change the typecast function so if it's a integer it will return the value without changed.
For the second case. I'm using Oracle Express that I think was a 10g version on Windows and Zend Community Server for web server. Using the code from CRUD console command, if I have underscore character before the variables in createUpdateCommand function my application will throw error from Oracle like invalid character. But if I remove the underscore my update function will save the record without error. So I think it will be because underscore character.