i want to convert this sql query to codeigniter query |
[eluser]minhbu[/eluser]
select * from class where id=3 and (name like "%a" or name like "a%" or name like "%a%" ) help me !
[eluser]umefarooq[/eluser]
try this Code: $this->db->get('class') before will put % before a, after will put % after a , default is on both side. check the link will help you more http://ellislab.com/codeigniter/user-gui...ecord.html
[eluser]minhbu[/eluser]
[quote author="Milos Dakic" date="1235738733"]@umefarooq; I think you forgot quotes around the name field Code: $this->db->get('class') but when i query this code is select * from class where id=3 and name like "%a" or name like "%a%" or name like "a%" i want select * from class where id=3 and (name like "%a" or name like "%a%" or name like "a%")
[eluser]pehaw[/eluser]
I would have said that “%a” and “a%” are subsets of “%a%” , so you don't need all of those ORs anyway. |
Welcome Guest, Not a member yet? Register Sign In |