CodeIgniter Forums
'~' char converted to '-' char in active record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: '~' char converted to '-' char in active record (/showthread.php?tid=30486)



'~' char converted to '-' char in active record - El Forum - 05-16-2010

[eluser]paris[/eluser]
hi all,

I have problem using '~' char with active record. I need to use '~' char in where clause for pattern matching. But in the sql string produced by active record, '~' char converted to '-' char.

here my sample model:

Code:
$this->db->select('*');
    $this->db->where('term ~*', 'regex');
    $query = $this->db->get('search');

    $result = $query->result_array();
    return $result;

the sql string should be like this:
Code:
SELECT * FROM 'search' WHERE 'term' ~* 'regex';

the sql string produced by active record :
Code:
SELECT * FROM 'search' WHERE 'term' -* 'regex';

anyone could help me?, what did I wrong?

thanks, paris.


'~' char converted to '-' char in active record - El Forum - 05-17-2010

[eluser]Mat-Moo[/eluser]
have you tried "FALSE" as the 3rd parameter? $this->db->where('term ~*', 'regex', FALSE);


'~' char converted to '-' char in active record - El Forum - 05-17-2010

[eluser]paris[/eluser]
thanks, mat for your reply...

using 3rd parameter solve the '~' char issue, but using FALSE option also eliminate the quotation marks char... when using FALSE option my SQL would be like :

Code:
SELECT * FROM search WHERE term ~* regex


witch the correct sql should be :

Code:
SELECT * FROM search WHERE term ~* 'regex'

any other ideas ?


'~' char converted to '-' char in active record - El Forum - 05-18-2010

[eluser]Mat-Moo[/eluser]
Code:
$this->db->where('term ~* "regex"',NULL,FALSE);
Any good?


'~' char converted to '-' char in active record - El Forum - 05-19-2010

[eluser]paris[/eluser]
hei Mat, i got following error from your suggestion :
Code:
A Database Error Occurred

Error Number:

ERROR: column "regex" does not exist LINE 3: WHERE term ~* "regex" ^

SELECT * FROM "search" WHERE term ~* "regex"

anyway... I have solve this issue using common string query instead of active record.
Thanks for your help Mat...


'~' char converted to '-' char in active record - El Forum - 05-23-2010

[eluser]Unknown[/eluser]
Thanks a lot!
Had the issue using common string query =(


'~' char converted to '-' char in active record - El Forum - 08-03-2010

[eluser]Unknown[/eluser]
$this->db->where('field RLIKE', "'^[0-9].*'", FALSE);