Welcome Guest, Not a member yet? Register   Sign In
Enable true oci_bind_by_name funciton
#1

[eluser]cyu021[/eluser]
Tried to use oci_bind_by_name() for Oracle DB and couldn't get it to work.
Then I find there is some fix need to be done in CI's code.
This is how I apply the fix.

Step 1.
_CI_ROOT_/system/database/DB_driver.php >>>
line 293:
Code:
--
if (FALSE === ($this->result_id = $this->simple_query($sql)))
++
if (FALSE === ($this->result_id = $this->simple_query($sql, $binds)))
line 440:
Code:
--
function simple_query($sql)
++
function simple_query($sql, $binds=FALSE)
line 447:
Code:
--
return $this->_execute($sql);
++
return $this->_execute($sql, $binds);

Step 2.
_CI_ROOT_/system/database/drivers/oci8/oci8_driver.php >>>
line 165:
Code:
--
function _execute($sql)
++
function _execute($sql, $binds=FALSE)
line 172-172:
Code:
--
++
if($binds != FALSE) {
  foreach($binds as $k => $bind) {
    oci_bind_by_name($this->stmt_id, $bind['name'], $bind['value']);
  }
}

How to use it:
Code:
$sql = "insert
into related_firm
(
TYPE,
NAME,
CONTACT_ADDR,
CONTACT_NUMBER,
CONTACT_FAX,
SN
)
values
(
:TYPE,
:NAME,
:CONTACT_ADDR,
:CONTACT_NUMBER,
:CONTACT_FAX,
:SN
)";
$params[] = array('name'=>':TYPE', 'value'=>$this->type);
$params[] = array('name'=>':NAME', 'value'=>$this->name);
$params[] = array('name'=>':CONTACT_ADDR', 'value'=>$this->contactAddress);
$params[] = array('name'=>':CONTACT_NUMBER', 'value'=>$this->contactNumber);
$params[] = array('name'=>':CONTACT_FAX', 'value'=>$this->contactFax);
$params[] = array('name'=>':SN', 'value'=>$this->serialNumber);
$db = $this->load->database('TESTDB', TRUE);
$db->query($sql, $values, TRUE);
#2

[eluser]MVUG[/eluser]
I get the following error:

Fatal error: Only variables can be passed by reference in system/database/drivers/oci8/oci8_driver.php on line 176
#3

[eluser]InsiteFX[/eluser]
You can not extend the database library and you should not
be making changes to it, because when a new version or update
comes out your code will be over written!

InsiteFX
#4

[eluser]cyu021[/eluser]
[quote author="tuurtnt" date="1293816894"]I get the following error:

Fatal error: Only variables can be passed by reference in system/database/drivers/oci8/oci8_driver.php on line 176[/quote]

which version are you running? mine is 1.7
or maybe you can leave your email to my PM so i can send the modified files to you
#5

[eluser]cyu021[/eluser]
[quote author="InsiteFX" date="1293819015"]You can not extend the database library and you should not
be making changes to it, because when a new version or update
comes out your code will be over written!

InsiteFX[/quote]

is it possible to put the proposed changes to trunk?
i think it is a nice feature to have
#6

[eluser]MVUG[/eluser]
[quote author="cyu021" date="1293963902"][quote author="tuurtnt" date="1293816894"]I get the following error:

Fatal error: Only variables can be passed by reference in system/database/drivers/oci8/oci8_driver.php on line 176[/quote]

which version are you running? mine is 1.7
or maybe you can leave your email to my PM so i can send the modified files to you[/quote]


I use 1.7.3. I found that the problem is generated by custom queries I do in my app...
#7

[eluser]Unknown[/eluser]
CodeIgniter's oci8_dirver is not a great implementation for an oracle driver.
I had to make several changes to it in order to get it to do some advanced use of oracle capabilities. On my custom version I included "true" bind variables support while keeping the "escaped" bind variables implemented by CodeIgniter.
Another issue is with function oci_set_prefetch which value is fixed and hardcoded.
There is any way to contribute these changes so the oci8_driver can be improved in future versions?
#8

[eluser]CroNiX[/eluser]
Sure, here: https://github.com/EllisLab/CodeIgniter




Theme © iAndrew 2016 - Forum software by © MyBB