How would you write given query using active record |
[eluser]Unknown[/eluser]
query Code: SELECT * FROM `users` Im not shure how to "combine" (`role` = 0 OR `role` = $role) im stuck
[eluser]Dennis Rasmussen[/eluser]
I wouldn't. AR is just for easy and quick queries (to my understanding).
[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-gui...tml#select (and then a bit bellow on that page). So, it should be doable Cheers, Smilie
[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
[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.
[eluser]Unknown[/eluser]
thanks for helping.. I went with using "ordinary" queries with binding variables. |
Welcome Guest, Not a member yet? Register Sign In |