Home
Forums
Members
Search
Help
New topics
Todays topics
Website
Welcome Guest, Not a member yet?
Register
Sign In
Login
Username:
Password:
Remember me
Lost Password?
CodeIgniter Forums
Archived Discussions
Archived Development & Programming
how do i chain multiple OR within a Where() when using active record?
Share on Google
Share on Facebook
Share on Twitter
View a Printable Version
Subscribe to this thread
Add Poll to this thread
Send thread to a friend
Linear Mode
Threaded Mode
how do i chain multiple OR within a Where() when using active record?
El Forum
Guest
#1
02-15-2011, 12:04 PM
[eluser]Bad Penguin[/eluser]
How do i implement "select * from t1 where a=1 and ( b=1 or c=2 or d=3 )" ?
$this->db->select()->from('t1')->where('a',1)
....
how do i open the bracket for chaining ->or_where('b',1) ?
El Forum
Guest
#2
02-15-2011, 12:37 PM
[eluser]danmontgomery[/eluser]
No easy way to do it with AR. You have to specify the entire where statement.
Code:
$this->db->where('a', 1)->where('(b=1 or c=2 or d=3)')->get('t1');
El Forum
Guest
#3
02-15-2011, 04:21 PM
[eluser]Bad Penguin[/eluser]
[quote author="noctrum" date="1297816668"]
Code:
$this->db->where('a', 1)->where('(b=1 or c=2 or d=3)')->get('t1');
[/quote]
i want to avoid exactly this and use or_where
El Forum
Guest
#4
02-15-2011, 11:27 PM
[eluser]Basketcasesoftware[/eluser]
You might try looking at DataMapper. It allows method chaining. And it's an active record system.
--------------------
Private Messages
User Control Panel
Who's Online
Search
Forum Home
General
-- News & Discussion
-- Events
-- Lounge
-- Regional User Groups
Using CodeIgniter
-- Installation & Setup
-- Model-View-Controller
-- Libraries & Helpers
-- Best Practices
-- Choosing CodeIgniter
-- General Help
CodeIgniter 4
-- CodeIgniter 4 Roadmap
-- CodeIgniter 4 Development
-- CodeIgniter 4 Feature Requests
-- CodeIgniter 4 Support
-- CodeIgniter 4 Discussion
-- CodeIgniter 4 Addins
Development
-- CodeIgniter 3.x
-- CodeIgniter 2.x
-- Issues
-- NetBeans Plugin
External Resources
-- Spotlight
-- Learn More
-- Jobs
-- Addins
Archived Discussions
-- Archived Libraries & Helpers
-- Archived Development & Programming
Theme © iAndrew 2016 -
Forum software by © MyBB