How to Force Code Igniter to NOT to excape queries? |
[eluser]Sheikh Aman Alam[/eluser]
I wish to run this query- Code: SELECT `comment`.`commenttext`, `comment`.`cd`, `user`.`username` the _selectAND() method uses where to run these queries. but this methods gives my following output- Code: SELECT `comment`.`commenttext`, `comment`.`cd`, `user`.`username` MySQL isn't accepting the comment.id in quotes, so i want to stop codeigniter from escaping i with quotes. i know how to do it with set() in INSERT statements, but not in this one. please help. Thanks in advance.
[eluser]Georgi Veznev[/eluser]
Code: $this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.
[eluser]danmontgomery[/eluser]
Do you mean: Code: WHERE `comment`.`videoid` = '2' ? Try: Code: $criteria = array( The above post will prevent CI from escaping fields, but not values if it thinks the value is a string
[eluser]Michael Wales[/eluser]
Wouldn't it be much easier to just select on the comment table and join the user table?
[eluser]Sheikh Aman Alam[/eluser]
@noctrum- i didnt want to this: WHERE `comment`.`videoid` = '2' rather, i want to do this: `user`.`userid` = comment.userid and NOT this one: `user`.`userid` = 'comment.userid' codeigniter is doing the later one. @michael Wales. how to do that in this situation?
[eluser]Sheikh Aman Alam[/eluser]
Got it working. used the join() method and now the code is like- $this->db->select(`comment`.`commenttext`, `comment`.`cd`, `user`.`username`); $this->db->from('comment'); $this->db->join('user','user.userid=comment.userid'); $this->db->where($criterea); $resultSet= $this->db->get() thanks a lot for giving ideas guys.. :-) |
Welcome Guest, Not a member yet? Register Sign In |