Home > drupal-qb

drupal-qb

Drupal-qb is a project mainly written in PHP, it's free.

Drupal Query Builder

This is a simple query builder that can be used to generate sql query compatible with Drupal 6 db_query() function.

Example usage:-

$query = qb_select()
    ->fields("u", array("name", "mail", "status"))
    ->from("users", "u")
    ->where("u.name = '%s'", array('root'))
    ->where("u.status = 1");
$result = db_query($query->sql(), $query->getArguments());

Please take a look in tests/qb.test for more usage example.

Reason

Drupal 7 database API already included query builder and it's been backported to Drupal 6 as dbtng module. The problem with the module is it created a new database connection instead of using existing one. This query builder try to follow the dbtng API as close as possible.

Previous:script.cdart