Ok, I considered db_select because I needed to be able to add an extend() method and db_query() doesn't allow for it. However, my query is adjustable by the user with a filter selection that allows the user to add OR and/or AND filters on the fly. The db_or() and db_and() methods requires I know the condition()s all at once which I don't so now I'm back to use db_query to build the query string as I was doing in D6. However, I need to be able to page the list of items such as extend('PagerDefault')->extend('TableSort')->orderByHeader->($header) but this doesn't exist in the db_query object. Is there some means by which I can create a SelectQueryExtender object with the db_query object as a parameter? Or does anyone have a different solution?
On Mon, Jun 11, 2012 at 4:04 PM, Earnie Boyd earnie@users.sourceforge.net wrote:
Ok, I considered db_select because I needed to be able to add an extend() method and db_query() doesn't allow for it. However, my query is adjustable by the user with a filter selection that allows the user to add OR and/or AND filters on the fly. The db_or() and db_and() methods requires I know the condition()s all at once which I don't so now I'm back to use db_query to build the query string as I was doing in D6. However, I need to be able to page the list of items such as extend('PagerDefault')->extend('TableSort')->orderByHeader->($header) but this doesn't exist in the db_query object. Is there some means by which I can create a SelectQueryExtender object with the db_query object as a parameter? Or does anyone have a different solution?
For others who may need a solution, I decided to use the SelectQuery::where() API[1] reverting back to db_select(). This allows me to build the complex where clauses I need and giving the final string to the object like so, $query->where($where, $args). This way the extensions are usable.
[1] http://api.drupal.org/api/drupal/includes%21database%21select.inc/function/S...