How would you write given query using active record - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: How would you write given query using active record (/showthread.php?tid=37303) |
How would you write given query using active record - El Forum - 01-05-2011 [eluser]Unknown[/eluser] query Code: SELECT * FROM `users` Im not shure how to "combine" (`role` = 0 OR `role` = $role) im stuck How would you write given query using active record - El Forum - 01-05-2011 [eluser]Dennis Rasmussen[/eluser] I wouldn't. AR is just for easy and quick queries (to my understanding). How would you write given query using active record - El Forum - 01-05-2011 [eluser]smilie[/eluser] Although I do agree with Dennis (using AR for 'simple' queries), I think AR could do this as well with: or_where: Quote:$this->db->or_where(); See: http://ellislab.com/codeigniter/user-guide/database/active_record.html#select (and then a bit bellow on that page). So, it should be doable Cheers, Smilie How would you write given query using active record - El Forum - 01-05-2011 [eluser]Cristian Gilè[/eluser] Dennis, you are right. AR is for quick and easy queries. In the CI reactor forum (http://bit.ly/fABQQk) there are some votes to add the parentheses in the AR. In the meantime, take a look at this post: http://bit.ly/e66mbQ How would you write given query using active record - El Forum - 01-05-2011 [eluser]Dennis Rasmussen[/eluser] Sure it's doable with AR, but there's really no need to. I wouldn't recommend it (considering all the "hard" work you'll have to do compared to already having the solution as a standard query) and that's why I didn't give an example or reference to a solution. Sometimes simple is best. How would you write given query using active record - El Forum - 01-05-2011 [eluser]Unknown[/eluser] thanks for helping.. I went with using "ordinary" queries with binding variables. |