Un exemple simple de l'utilisation de la database API de Drupal 7

Voici un exemple simple de l'utilisation de la database API :

$results = db_select('authmap', 'am') // 'authmap' is the table name, 'am' the alias
->fields('am', array('uid')) // The alias and the field we want to fetch
->distinct() // Add distinct
->condition('module', 'MYMODULE') // A condition on the 'module' field, 'MYMODULE' value
->condition('authname', $ids, 'IN') // A condition on the 'authname' field, value is in $ids array
->execute() // Execute the query
->fetchCol(); // Fetch column