Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal Query builder

I quite often use Drupal's Views Module to build SQL that I paste into my code. It understands the Drupal database schema quite well.

Is there a module that would give me this functionality or can I factor this out of Views?

like image 264
Rimian Avatar asked Mar 21 '10 07:03

Rimian


1 Answers

Would be cool of the Views module was extended to better support programmatic usage, but until then you might perhaps want to take a look at one of my colleagues attempt at creating something similar to such a thing: http://github.com/hugowetterberg/query_builder

Related to this might be the Services project attempt at providing Views data as a service, an effort that we right now are separating out into it's own module: http://drupal.org/node/709100 Might be worth follow since it's going to need some level of programmatic access to Views.

Another example of a module that's accessing Views programmatically is Development Seeds Litenode: http://developmentseed.org/blog/2009/feb/4/litenode

Update 15/12-2010: The EntityFieldQuery in Drupal 7 is almost like using Views programmatically to build queries - the difference being that EntityQueryBuilder works on only entities and fields and by that also with the bonus that it actually can build queries against any type of field storage in use - eg. a NoSQL database like MongoDB. Example can be found here: http://drupal4hu.com/node/267

like image 168
VoxPelli Avatar answered Sep 22 '22 01:09

VoxPelli