Welcome Guest, Not a member yet? Register   Sign In
Suggestion/Discussion for Active Record WHERE-clause grouping feature
#7

[eluser]broofa[/eluser]
I know this thread is a bit aged, but would like to chime in with a couple comments. First, for the record, here's the specific use case I have where I need the proposed feature, and that led me to find this thread:

I'm writing a business directory app (essentially a community-specific yellow pages app) that allows users to search for businesses in the database and view a Google map of the results. When generating the map data, I want to only display the intersection of businesses that match the search criteria and that also have the necessary geocode information used to map their location. Thus, my WHERE clause has to look something like this:

Quote:"WHERE geocode != '' AND (name LIKE '%search_term%' OR description LIKE '%search_term%)'

Obviously w/out the parens I get a different (and incorrect!) set of results than with them. What's important about this is that the where() call is in a different method than the like() and or_like() calls. So juggling the ordering of the these phrases is problematic... and not really the best solution anyway. OverZealous' proposed API is definitely the preferred approach.

Nor do I see this as a particularly unusual case - I think this is a core feature that really needs to be added to the CI ActiveRecord api.

Regarding the naming, I agree that 'group' is a bit overused, especially with the already existant (and unrelated) group_by() method. But the only names I can think of are open_paren()/close_paren(), or paren()/nerap(. And I doubt those are any better.


Messages In This Thread
Suggestion/Discussion for Active Record WHERE-clause grouping feature - by El Forum - 06-24-2010, 09:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB