escape not working with active record and Oracle |
[eluser]Unknown[/eluser]
This is my first CI project. one reason I choose CI what for the cross DB library and the active records. I started out the project with MySql and then had t switch to Oracle. The active record is not escaping an apostrophe. like in the string "you can't do that." The code looks simple: Code: $comment = $this->input->post('CommentsDenial'); I get the error: A PHP Error was encountered Severity: Warning Message: ociparse() [function.ociparse]: ORA-01756: quoted string not properly terminated Filename: oci8/oci8_driver.php Line Number: 186 I even tried to call escape first. Code: $this->db->set('REQ_DENY_COMMENT_DESC', $this->db->escape($comment) ); With a few debug statements I got this: Code: echo $comment . "<BR>"; All escape did was place single quotes around the whole string. the Apostrophe was not escaped! So am I missing some settings or is this a bug (maybe with the oci8 driver)?
[eluser]Brad K Morse[/eluser]
change Code: $comment = $this->input->post('CommentsDenial'); to Code: $comment = str_replace("'", "''", $this->input->post('CommentsDenial'));
[eluser]MVUG[/eluser]
Maybe this can solve your problem: http://ellislab.com/forums/viewthread/179202/
[eluser]Unknown[/eluser]
I found another way of handeling the escaped problem in oracle. Within the system -> database -> drivers -> oci8 -> oci8_driver.php have added this line: Code: $str = str_replace("'", "''", $str); Code: function escape_str($str, $like = FALSE) |
Welcome Guest, Not a member yet? Register Sign In |