Check out ARel. (it's in ActiveRecord 3, part of Rails) It uses relational algebra and is pretty good about letting you mix and match:
enabled = User.where(:disabled => false)
enabled.group("date(created_at)").having("created_at > ?", 1.month.ago).order(weird_order_clause).limit(5)Right, yeah that's pretty nice!
The CodeIgniter ActiveRecord library follows the same pattern. Unfortunately, it's pretty kludgey and requires you to use CodeIgniter.
Do you have an example that shows how to use ARel to do relational algebra?
I believe it just uses it under the hood, but I'm not familiar enough with relational algebra (or ARel) to know for sure. Here's a blog post from the author:
http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-...
django Q and F functions? they let you build funky where clauses.
see: https://docs.djangoproject.com/en/1.3/topics/db/queries/#com... https://docs.djangoproject.com/en/dev/topics/db/queries/#fil...
I think activerecord in rails 3 comestibles Odette close - except the modification of from.
That sounds like something I wrote.
https://github.com/mikecao/sparrow
It's a simple class that builds and executes SQL, but you can customize query at any time.
There's php-activerecord[1] or if you want something a bit different, do take a look at notorm[2]. I'd also take this opportunity to mention my own creation, pdoext[3].
[1] https://github.com/kla/php-activerecord
Re:Why I Hate Frameworks
by jcromartie on Wednesday July 20, 2011 @10:45PM
(#2788333)
ClojureQL (also based on relational algebra like the other comment) lets you compose bits and pieces of queries a lot like that.
Now I want to add some weirdo custom stuff in but I can't - I have to go back to the part of the application that produced db_obj in the first place and refactor that to use custom SQL.
It's one or the other.