Feature Request #1999
Change order of operator in where() ... on()... etc
| Status: | Closed | Start date: | 08/25/2009 | |
|---|---|---|---|---|
| Priority: | Low | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | Modules:Database | |||
| Target version: | v3.1.0 | |||
| Resolution: | wontfix | Points: |
Description
In most cases when I build a query that has an operator it is an = comparison.
It would be nice to have the operator moved to the end of the argument list and defaulted to '=' so we can do something like the following...
DB::select('*')->from('Users')->where('UserID', 10);
instead of having to remember the stick the equal sign in every statement
DB::select('*')->from->('Users')->where('UserID', '=', 10);
--
If you needed to use a different operator then you could stick it at the end.
DB::select('*')->from('News')->where('ExpireDate', date('Y-m-d'), '>');
This would apply to any function you can add the operator to, where and on to name a few. (I'm sure there are some I am missing)
History
Updated by Isaiah DeRose-Wilson over 2 years ago
I thought the same thing at first when I saw the new Database api, however after using it for a while I would say the readability of where('col', '=', 'value') (the logical order) far outweighs having to type '=' all the time.
Updated by Woody Gilk over 2 years ago
- Status changed from New to Feedback
- Target version set to v3.1.0
Updated by Cédric Cazette over 2 years ago
I thought about it too... It's about readability vs typing laziness. I think I agree with Isaiah on this one. That's also a significant change in the API (that would be quite a lot of replacements in application models and modules such as ORM), that could lead to some confusion in the documentation (loads of code samples for the coming 3.0 documentation would require an update as soon as 3.1).
Not sure it's worth it... Still open to discussions though.
Updated by John Heathco over 2 years ago
I agree with Cedric and Isaiah on this one as well - most operations are equals, and I don't think putting the operator at the end makes readability that much more difficult.
Updated by Miodrag Tokić over 2 years ago
When reading code I have to know instantly what is purpose of that particular line, so I would go with readability over typing lazinest.
Updated by Woody Gilk over 2 years ago
Miodrag Tokić wrote:
When reading code I have to know instantly what is purpose of that particular line, so I would go with readability over typing lazinest.
I agree 100%. Typing a couple extra characters makes the code more obvious and readable.
Updated by Dave Widmer over 2 years ago
No worries, just a thought as a nice to have. I'll probably just end up extending the DB class and setting that up functionality. I can post it when I'm done if anyone is interested.
Updated by Dave Widmer over 2 years ago
After getting used to the where parameters, I like it the way it is for readability sake. This can be closed out...
Updated by Woody Gilk over 2 years ago
- Category set to Modules:Database
- Assignee set to Woody Gilk
- Resolution set to wontfix
Updated by Anonymous about 2 years ago
Shouldn't the status of this be set to Closed?
Updated by Woody Gilk about 2 years ago
- Status changed from Feedback to Closed