Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to set OR condition for query. #216

Open
tejashsoni111 opened this issue Jan 6, 2016 · 7 comments
Open

not able to set OR condition for query. #216

tejashsoni111 opened this issue Jan 6, 2016 · 7 comments

Comments

@tejashsoni111
Copy link

Is it possible to set OR condition for any query?

I need to set condition for following query :
select * from users where username='abc' or email='[email protected]';

@dadenewyyt
Copy link

you could use active record or_where();
On Jan 6, 2016 5:02 PM, "tejashsoni111" [email protected] wrote:

Is it possible to set OR condition for any query?

I need to set condition for following query :
select * from users where username='abc' or email='abc@defcom';


Reply to this email directly or view it on GitHub
#216.

@tejashsoni111
Copy link
Author

@dadenewyyt , how to use or_where(); with get_by() or get_many() methods? Do I need to add new method for it?

@dadenewyyt
Copy link

I guess u need to።modify the actual code።base on. MYmodel.php other wise ur
have the option to define a method inside ur model like student_model.php a
function።purly apply codei።tired active record the or_where query please
sear h on that.
On Jan 7, 2016 8:06 AM, "tejashsoni111" [email protected] wrote:

@dadenewyyt https://github.com/dadenewyyt , how to use or_where(); with
get_by() or get_many() methods? Do I need to add new method for it?


Reply to this email directly or view it on GitHub
#216 (comment)
.

@gautamsawala
Copy link

Can we use get_by() on email and if the returns null again make a get_by() on username?

Is this technique costly and inefficient considering the database has huge number of rows?

@vsogrimen
Copy link

@gautamsawala, I think you can do that by executing two different QUERIES or by using or_where().

@gautamsawala
Copy link

@vsogrimen do we have 'or_where()' as in built function in MY_Model? I cannot find it!

@davidvrsantos
Copy link

davidvrsantos commented Jul 26, 2016

You can use this form:

$this->users->get_many_by("collumn1 = 1 OR collumn1 = 2 OR collumn1 = 3");

this works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants