diff --git a/acl.module b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.module
index 5681106..3e00179 100644
--- a/acl.module
+++ b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.module
@@ -29,7 +29,7 @@ function acl_create_acl($module, $name = NULL, $number = NULL) {
   $acl = array(
     'module' => $module,
     'name' => $name,
-    'number' => $number
+    'number_acl' => $number
   );
   drupal_write_record('acl', $acl);
   return $acl['acl_id'];
@@ -63,10 +63,12 @@ function acl_delete_acl($acl_id) {
  * Add the specified UID to an ACL.
  */
 function acl_add_user($acl_id, $uid) {
-  $test_uid = db_query("SELECT uid FROM {acl_user} WHERE acl_id = :acl_id AND uid = :uid", array(
-    'acl_id' => $acl_id,
-    'uid' => $uid,
-  ))->fetchField();
+  $test_uid = db_select('acl_user', 'aclu')
+    ->fields('aclu', array('uid'))
+    ->condition('aclu.acl_id', $acl_id)
+    ->condition('aclu.uid', $uid)
+    ->execute()
+    ->fetchField();
   if (!$test_uid) {
     db_insert('acl_user')
     ->fields(array(
@@ -89,10 +91,8 @@ function acl_remove_user($acl_id, $uid) {
 
 /**
  * Provide a form to edit the ACL that can be embedded in other forms.
- *
  * Pass $new_acl=TRUE if you have no ACL yet, but do supply a string
- * like 'my_module_new_acl' as $acl_id anyway; create the ACL and set
- * $form['acl_id'] before calling acl_save_form().
+ * like 'my_module_new_acl' as $acl_id anyway.
  */
 function acl_edit_form(&$form_state, $acl_id, $label = NULL, $new_acl = FALSE) {
   $form_state['build_info']['files'][] = _acl_module_load_include('admin.inc');
@@ -103,18 +103,21 @@ function acl_edit_form(&$form_state, $acl_id, $label = NULL, $new_acl = FALSE) {
  * Provide access control to all nodes selected by a subquery, based upon an ACL id.
  */
 function acl_add_nodes($subselect, $acl_id, $view, $update, $delete, $priority = 0) {
-  db_delete('acl_node')
-    ->condition('acl_id', $acl_id)
-    ->condition('nid', $subselect, 'IN')
-    ->execute();
-  $subselect->addExpression($acl_id, 'acl_id');
-  $subselect->addExpression((int) $view, 'grant_view');
-  $subselect->addExpression((int) $update, 'grant_update');
-  $subselect->addExpression((int) $delete, 'grant_delete');
-  $subselect->addExpression($priority, 'priority');
-  db_insert('acl_node')
-    ->from($subselect)
-    ->execute();
+  $result = $subselect->execute();
+  if ($result->rowCount() > 0) {
+    db_delete('acl_node')
+      ->condition('acl_id', $acl_id)
+      ->condition('nid', $subselect, 'IN')
+      ->execute();
+    $subselect->addExpression($acl_id, 'acl_id');
+    $subselect->addExpression((int) $view, 'grant_view');
+    $subselect->addExpression((int) $update, 'grant_update');
+    $subselect->addExpression((int) $delete, 'grant_delete');
+    $subselect->addExpression($priority, 'priority');
+    db_insert('acl_node')
+      ->from($subselect)
+      ->execute();
+  }
 }
 
 /**
@@ -176,7 +179,7 @@ function acl_get_id_by_name($module, $name, $number = NULL) {
     ->condition('a.module', $module)
     ->condition('a.name', $name);
   if (isset($number)) {
-    $query->condition('a.number', $number);
+    $query->condition('a.number_acl', $number);
   }
   return $query->execute()->fetchField();
 }
@@ -188,7 +191,7 @@ function acl_get_id_by_number($module, $number) {
   $query = db_select('acl', 'a')
     ->fields('a', array('acl_id'))
     ->condition('a.module', $module)
-    ->condition('a.number', $number);
+    ->condition('a.number_acl', $number);
   return $query->execute()->fetchField();
 }
 
@@ -196,19 +199,25 @@ function acl_get_id_by_number($module, $number) {
  * Determine whether an ACL has some assigned users.
  */
 function acl_has_users($acl_id) {
-  return db_query("SELECT COUNT(uid) FROM {acl_user} WHERE acl_id = :acl_id", array(
-    'acl_id' => $acl_id,
-  ))->fetchField();
+  return db_select('acl_user', 'aclu')
+    ->fields('aclu', array('uid'))
+    ->condition('aclu.acl_id', $acl_id)
+    ->countQuery()
+    ->execute()
+    ->fetchField();
 }
 
 /**
  * Determine whether an ACL has a specific assigned user.
  */
 function acl_has_user($acl_id, $uid) {
-  return db_query("SELECT COUNT(uid) FROM {acl_user} WHERE acl_id = :acl_id AND uid = :uid", array(
-    'acl_id' => $acl_id,
-    'uid' => $uid,
-  ))->fetchField();
+  return db_select('acl_user', 'aclu')
+    ->fields('aclu', array('uid'))
+    ->condition('aclu.acl_id', $acl_id)
+    ->condition('aclu.uid', $uid)
+    ->countQuery()
+    ->execute()
+    ->fetchField();
 }
 
 /**
@@ -225,7 +234,7 @@ function acl_get_ids_by_user($module, $uid, $name = NULL, $number = NULL) {
     $query->condition('a.name', $name);
   }
   if (isset($number)) {
-    $query->condition('a.number', $number);
+    $query->condition('a.number_acl', $number);
   }
   $acl_ids = $query->execute()->fetchCol();
   return $acl_ids;
@@ -235,9 +244,11 @@ function acl_get_ids_by_user($module, $uid, $name = NULL, $number = NULL) {
  * Get the uids of an ACL.
  */
 function acl_get_uids($acl_id) {
-  $uids = db_query("SELECT uid FROM {acl_user} WHERE acl_id = :acl_id", array(
-    'acl_id' => $acl_id,
-  ))->fetchCol();
+  $uids = db_select('acl_user', 'aclu')
+    ->fields('aclu', array('uid'))
+    ->condition('aclu.acl_id', $acl_id)
+    ->execute()
+    ->fetchCol();
   return $uids;
 }
 
@@ -248,9 +259,15 @@ function acl_node_access_records($node) {
   if (!$node->nid) {
     return;
   }
-  $result = db_query("SELECT n.*, 'acl' AS realm, n.acl_id AS gid, a.module FROM {acl_node} n INNER JOIN {acl} a ON n.acl_id = a.acl_id WHERE nid = :nid", array(
-    'nid' => $node->nid,
-  ), array('fetch' => PDO::FETCH_ASSOC));
+  $query = db_select('acl_node', 'n', array('fetch' => PDO::FETCH_ASSOC));
+  $query->join('acl', 'a', 'n.acl_id = a.acl_id');
+  $query->addField('n', 'acl_id', 'gid');
+  $query->addField('a', 'module');
+  $query->addExpression("'acl'", 'realm');
+  $result = $query
+    ->fields('n')
+    ->condition('n.nid', $node->nid)
+    ->execute();
   $grants = array();
   foreach ($result as $grant) {
     if (module_invoke($grant['module'], 'enabled')) {
@@ -277,9 +294,12 @@ function acl_node_access_records($node) {
  * Implements hook_node_grants().
  */
 function acl_node_grants($account, $op) {
-  $acl_ids = db_query("SELECT acl_id FROM {acl_user} WHERE uid = :uid", array(
-    'uid' => $account->uid,
-  ))->fetchCol();
+  $acl_ids = db_select('acl_user', 'u')
+    ->fields('u', array('acl_id'))
+    ->condition('u.uid', $account->uid)
+    ->execute()
+    ->fetchCol();
+
   return (!empty($acl_ids) ? array('acl' => $acl_ids) : NULL);
 }
 
@@ -321,32 +341,49 @@ function acl_node_access_explain($row) {
   static $interpretations = array();
   if ($row->realm == 'acl') {
     if (!isset($interpretations[$row->gid])) {
-      $acl = db_query("SELECT * FROM {acl} WHERE acl_id = :acl_id", array(
-        'acl_id' => $row->gid,
-      ))->fetchObject();
+      $acl = db_select('acl', 'a')
+        ->fields('a')
+        ->condition('a.acl_id', $row->gid)
+        ->execute()
+        ->fetchObject();
       $acl->tag = '?';
       if (!isset($acl->name)) {
-        $acl->tag = $acl->number;
+        $acl->tag = $acl->number_acl;
       }
-      elseif (!isset($acl->number)) {
+      elseif (!isset($acl->number_acl)) {
         $acl->tag = $acl->name;
       }
       else {
-        $acl->tag = $acl->name . '-' . $acl->number;
+        $acl->tag = $acl->name . '-' . $acl->number_acl;
       }
-      foreach (user_load_multiple(acl_get_uids($row->gid)) as $account) {
-        $usernames[] = theme('username', array('account' => $account));
+      $query = db_select('acl_user', 'au');
+      $query->join('users', 'u', 'au.uid = u.uid');
+      $query
+        ->fields('u', array('name'))
+        ->condition('au.acl_id', $row->gid);
+      $result = $query->execute();
+
+      foreach ($result as $user) {
+        $users[] = $user->name;
       }
-      if (isset($usernames)) {
-        $usernames = implode(', ', $usernames);
-        $interpretations[$row->gid] = _acl_get_explanation("$acl->module/$acl->tag: $usernames", $acl->acl_id, $acl->module, $acl->name, $acl->number, $usernames);
+      if (isset($users)) {
+        $users = implode(', ', $users);
+        $interpretations[$row->gid] = _acl_get_explanation("$acl->module/$acl->tag: $users", $acl->acl_id, $acl->module, $acl->name, $acl->number_acl, $users);
       }
       elseif ($row->gid == 0) {
-        $result = db_query("SELECT an.acl_id, a.module, a.name FROM {acl_node} an JOIN {acl} a ON an.acl_id = a.acl_id LEFT JOIN {acl_user} au ON a.acl_id = au.acl_id WHERE an.nid = :nid AND au.uid IS NULL", array(
-          'nid' => $row->nid,
-        ));
+
+        $query = db_select('acl_node', 'an');
+        $query->join('acl', 'a', 'an.acl_id = a.acl_id');
+        $query->leftJoin('acl_user', 'au', 'a.acl_id = au.acl_id');
+        $query
+          ->fields('an', array('acl_id'))
+          ->fields('a', array('module', 'name'))
+          ->condition('an.nid', $row->nid)
+          ->isNull('au.uid');
+        $result = $query->execute();
+
         foreach ($result as $acl) {
-          $rows[] = _acl_get_explanation("$acl->acl_id:&nbsp;$acl->module/$acl->tag", $acl->acl_id, $acl->module, $acl->name, $acl->number);
+          $rows[] = _acl_get_explanation("$acl->acl_id:&nbsp;$acl->module/$acl->tag", $acl->acl_id, $acl->module, $acl->name, $acl->number_acl);
         }
         if (!empty($rows)) {
           return implode('<br />', $rows);
@@ -354,7 +391,7 @@ function acl_node_access_explain($row) {
         return 'No access via ACL.';
       }
       else {
-        $interpretations[$row->gid] = _acl_get_explanation("$acl->module/$acl->tag: no users!", $acl->acl_id, $acl->module, $acl->name, $acl->number);
+        $interpretations[$row->gid] = _acl_get_explanation("$acl->module/$acl->tag: no users!", $acl->acl_id, $acl->module, $acl->name, $acl->number_acl);
       }
     }
     return $interpretations[$row->gid];
@@ -365,11 +402,10 @@ function acl_node_access_explain($row) {
  * Helper function to ask the client for its interpretation of the given
  * grant record.
  */
-function _acl_get_explanation($text, $acl_id, $module, $name, $number, $usernames = NULL) {
-  $hook = $module . '_acl_explain';
+function _acl_get_explanation($text, $acl_id, $module, $name, $number, $users = NULL) {
+  $hook = $module .'_acl_explain';
   if (function_exists($hook)) {
-    return '<span title="' . $hook($acl_id, $name, $number, $usernames) . '">' . $text . '</span>';
+    return '<span title="'. $hook($acl_id, $name, $number, $users) .'">'. $text .'</span>';
   }
   return $text;
 }
-
diff --git a/acl.install b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.install
index 3691656..cb3c346 100644
--- a/acl.install
+++ b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.install
@@ -6,7 +6,7 @@
  */

 /**
- * Implements hook_schema().
+ * Implementation of hook_schema().
  */
 function acl_schema() {
   $schema['acl'] = array(
@@ -28,15 +28,15 @@ function acl_schema() {
         'type'        => 'varchar',
         'length'      => 255,
       ),
-      'number'        => array(
-        'description' => "A number for this ACL entry, given by the module that created it; use either 'name' or 'number'.",
+      'number_acl'        => array(
+        'description' => "A number for this ACL entry, given by the module that created it; use either 'name' or 'number_acl'.",
         'type'        => 'int',
       ),
     ),
     'primary key'     => array('acl_id'),
     'indexes'         => array(
-      'module_name_number' => array(array('module', 64), array('name', 64), 'number'),
-      'module_number' => array(array('module', 64), 'number'),
+      'module_name_number' => array(array('module', 64), array('name', 64), 'number_acl'),
+      'module_number' => array(array('module', 64), 'number_acl'),
     ),
   );
   $schema['acl_user'] = array(
@@ -187,8 +187,8 @@ function acl_update_6001() {
  * Add 'number' column if it's not there yet.
  */
 function acl_update_7000() {
-  if (!db_field_exists('acl', 'number')) {
-    db_add_field('acl', 'number', array('type' => 'int', 'description' => "A number for this ACL entry, given by the module that created it; use either 'name' or 'number'."));
+  if (!db_field_exists('acl', 'number_acl')) {
+    db_add_field('acl', 'number_acl', array('type' => 'int', 'description' => "A number for this ACL entry, given by the module that created it; use either 'name' or 'number_acl'."));
   }
 }

@@ -200,13 +200,13 @@ function acl_update_7001() {
     db_drop_index('acl', 'name');
   }
   if (!db_index_exists('acl', 'module_name_number')) {
-    db_add_index('acl', 'module_name_number', array(array('module', 64), array('name', 64), 'number'));
+    db_add_index('acl', 'module_name_number', array(array('module', 64), array('name', 64), 'number_acl'));
   }
-  if (db_index_exists('acl', 'number')) {
-    db_drop_index('acl', 'number');
+  if (db_index_exists('acl', 'number_acl')) {
+    db_drop_index('acl', 'number_acl');
   }
   if (!db_index_exists('acl', 'module_number')) {
-    db_add_index('acl', 'module_number', array(array('module', 64), 'number'));
+    db_add_index('acl', 'module_number', array(array('module', 64), 'number_acl'));
   }
 }

diff --git a/acl.admin.inc b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.admin.inc
index a21ec37..ca968ca 100644
--- a/acl.admin.inc
+++ b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.admin.inc
@@ -12,25 +12,32 @@ function _acl_edit_form($acl_id, $label = NULL, $new_acl = FALSE) {
   $users = array();
   if (!$new_acl) {
     // Ensure the ACL in question even exists.
-    if (!($record = db_query("SELECT name, number FROM {acl} WHERE acl_id = :acl_id", array(
-      'acl_id' => $acl_id,
-    ))->fetchAssoc())) {
+    $record = db_select('acl', 'a')
+      ->fields('a', array('name', 'number_acl'))
+      ->condition('a.acl_id', $acl_id)
+      ->execute()
+      ->fetchAssoc();
+    if (!$record) {
       return array();
     }
-    $result = db_query("SELECT u.uid, u.name FROM {users} u LEFT JOIN {acl_user} aclu ON aclu.uid = u.uid WHERE acl_id = :acl_id", array(
-      'acl_id' => $acl_id));
+    $query = db_select('users', 'u');
+    $query->leftJoin('acl_user', 'aclu', 'aclu.uid = u.uid');
+    $result = $query
+      ->fields('u', array('uid', 'name'))
+      ->condition('aclu.acl_id', $acl_id)
+      ->execute();
     foreach ($result as $user) {
       $users[$user->uid] = $user->name;
     }
   }
   if (!isset($label)) {
-    $label = (isset($record['name']) ? $record['name'] : (isset($record['number']) ? $record['number'] : $acl_id));
+    $label = (isset($record['name']) ? $record['name'] : (isset($record['number_acl']) ? $record['number_acl'] : $acl_id));
   }

   $form = array(
     '#type' => 'fieldset',
     '#collapsible' => TRUE,
-    '#title' => check_plain($label),
+    '#title' => $label,
     '#tree' => TRUE,
   );

@@ -92,10 +99,12 @@ function _acl_edit_form_after_build($form, &$form_state) {
     }
   }
   elseif (isset($form_state['triggering_element']) && $form_state['triggering_element']['#value'] == $form['add_button']['#value'] && !empty($form['add']['#value'])) {
-    $user = db_query("SELECT uid, name FROM {users} WHERE name = :name", array(
-      'name' => $form['add']['#value'],
-    ))->fetchObject();
-    if (!$user) {
+    $user = db_select('users', 'u')
+      ->fields('u', array('uid', 'name'))
+      ->condition('u.name', $form['add']['#value'])
+      ->execute()
+      ->fetchObject();
+    if (!$user || !$user->uid) {
       form_error($form['add'], t("Invalid user specified."));
     }
     else {
@@ -146,4 +155,3 @@ function acl_save_form($form, $priority = NULL) {
       ->execute();
   }
 }
-
diff --git a/tests/acl.test b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.test
index ca721db..cbd14b5 100644
--- a/tests/acl.test
+++ b/Applications/MAMP/htdocs/ccp/sites/all/modules/contrib/acl/acl.test
@@ -1,20 +1,8 @@
 <?php
+// $Id:

-/**
- * @file
- * Tests for the ACL module.
- */
-
-/**
- * Test case for ACL module.
- */
 class AclWebTestCase extends DrupalWebTestCase {

-  /**
-   * Implements getInfo().
-   *
-   * @return array
-   */
   public static function getInfo() {
     return array(
       'name' => 'ACL access permissions',
@@ -24,7 +12,7 @@ class AclWebTestCase extends DrupalWebTestCase {
   }

   /**
-   * Implements setUp().
+   * Implementation setUp().
    */
   function setUp() {
     parent::setUp('acl', 'acl_node_test');
@@ -43,13 +31,21 @@ class AclWebTestCase extends DrupalWebTestCase {
     acl_create_acl('test1', $node1->title);
     $acl_id = acl_get_id_by_name('test1', $node1->title);
     $this->assertNotNull($acl_id, t('ACL ID was succesfully found.'), $group = 'ACL');
-    $records = db_query('SELECT acl_id, name FROM {acl} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id))->fetchAll();
+    $records = db_select('acl', 'a')
+      ->fields('a', array('acl_id', 'name'))
+      ->condition('a.acl_id', $acl_id)
+      ->execute()
+      ->fetchAll();
     $this->assertEqual(count($records), 1, t('ACL was succesfully created.'), $group = 'ACL');
     acl_delete_acl($records[0]->acl_id);

-    $records = db_query('SELECT acl_id, name FROM {acl} WHERE acl_id = :acl_id', array(':acl_id' => $records[0]->acl_id))->fetchAll();
-    $this->pass(var_export($records, TRUE));
-    $this->assertEqual(count($records), 0, t('ACL was succesfully removed.'), $group = 'ACL');
+    $count = db_select('acl', 'a')
+      ->fields('a', array('acl_id', 'name'))
+      ->condition('a.acl_id', $records[0]->acl_id)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+    $this->assertEqual($count, 0, t('ACL was succesfully removed.'), $group = 'ACL');
   }

   /**
@@ -66,22 +62,37 @@ class AclWebTestCase extends DrupalWebTestCase {
     // made it in.
     $acl_id = acl_get_id_by_name('test2', $node1->title);
     $this->assertNotNull($acl_id, t('ACL ID was succesfully found.'), $group = 'ACL');
-    $records = db_query('SELECT acl_id, name FROM {acl} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id))->fetchAll();
-    $this->assertEqual(count($records), 1, t('ACL was succesfully created.'), $group = 'ACL');
+    $count = db_select('acl', 'a')
+      ->fields('a', array('acl_id', 'name'))
+      ->condition('a.acl_id', $acl_id)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
+    $this->assertEqual($count, 1, t('ACL was succesfully created.'), $group = 'ACL');

     // Add user (can't we use the user created in setup?).
     $web_user_1 = $this->drupalCreateUser();
     //$this->drupalLogin($web_user);
     acl_add_user($acl_id, $web_user_1->uid);
-    $records = db_query('SELECT acl_id, uid FROM {acl_user} WHERE uid = :uid', array(':uid' => $web_user_1->uid))->fetchAll();
+    $count = db_select('acl_user', 'u')
+      ->fields('u', array('acl_id', 'uid'))
+      ->condition('u.uid', $web_user_1->uid)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     // Verify user is added.
-    $this->assertEqual(count($records), 1, t('User was succesfully added.'), $group = 'ACL');
+    $this->assertEqual($count, 1, t('User was succesfully added.'), $group = 'ACL');

     // Remove user.
     acl_remove_user($acl_id, $web_user_1->uid);
-    $records = db_query('SELECT acl_id, uid FROM {acl_user} WHERE uid = :uid', array(':uid' => $web_user_1->uid))->fetchAll();
+    $count = db_select('acl_user', 'u')
+      ->fields('u', array('acl_id', 'uid'))
+      ->condition('u.uid', $web_user_1->uid)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     // Verify user is removed.
-    $this->assertEqual(count($records), 0, t('User was succesfully removed.'), $group = 'ACL');
+    $this->assertEqual($count, 0, t('User was succesfully removed.'), $group = 'ACL');
   }

   /**
@@ -102,26 +113,51 @@ class AclWebTestCase extends DrupalWebTestCase {
     // Add two nodes.
     $query = db_select('node', 'n')
       ->fields('n', array('nid'))
-      ->condition('nid', array($node1->nid, $node2->nid), 'IN');
+      ->condition('n.nid', array($node1->nid, $node2->nid), 'IN');
     acl_add_nodes($query, $acl_id1, 1, 1, 1);
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id1))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id1)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 2, t("2 nodes under control ($count)."), $group = 'ACL');
     // Add a third node.
     acl_node_add_acl($node3->nid, $acl_id1, 1, 1, 1);
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id1))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id1)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 3, t('3 nodes under control.'), $group = 'ACL');
     // Add the second node again.
     acl_node_add_acl($node2->nid, $acl_id1, 1, 1, 1);
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id1))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id1)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 3, t('Still only 3 nodes under control.'), $group = 'ACL');

     // Remove the second node again.
     acl_node_remove_acl($node2->nid, $acl_id1);
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id1))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id1)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 2, t('2 nodes left under control.'), $group = 'ACL');
     // Remove the second node again.
     acl_node_remove_acl($node2->nid, $acl_id1);
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id1))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id1)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 2, t('Still 2 nodes left under control.'), $group = 'ACL');

     // Create another ACL and add nodes.
@@ -129,13 +165,28 @@ class AclWebTestCase extends DrupalWebTestCase {
     $this->assertNotNull($acl_id2, t('ACL ID was created.'), $group = 'ACL');
     acl_node_add_acl($node1->nid, $acl_id2, 1, 1, 1);
     acl_node_add_acl($node2->nid, $acl_id2, 1, 1, 1);
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id2))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id2)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 2, t('2 nodes under control.'), $group = 'ACL');
     // Remove a node (which has two ACLs).
     acl_node_clear_acls($node1->nid, 'test3');
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id1))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id1)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 1, t('1 node left under control.'), $group = 'ACL');
-    $count = db_query('SELECT COUNT(nid) FROM {acl_node} WHERE acl_id = :acl_id', array(':acl_id' => $acl_id2))->fetchField();
+    $count = db_select('acl_node', 'n')
+      ->fields('n', array('nid'))
+      ->condition('n.acl_id', $acl_id2)
+      ->countQuery()
+      ->execute()
+      ->fetchField();
     $this->assertEqual($count, 1, t('1 node left under control.'), $group = 'ACL');
   }

