Drupal Retrieving Query Results

Posted under » Drupal on 18 November 2009

This "tutorial" is regarding modules in Drupal.

Drupal automatically establishes a connection to the database as part of its normal bootstrap process, so you do not need to worry about this. Anyway, trying to connect manually is problematic. Another thing to note is the use of db_rewrite_sql. You write your SQL like so.

function showy()
{
$sql = "SELECT * FROM {table}";
$result = db_query(db_rewrite_sql($sql));
while ($data = db_fetch_object($result)) 
   { echo $data->field1; }
}

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css