Index: mysql_auth.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mysql_auth/mysql_auth.module,v
retrieving revision 1.13
diff -u -r1.13 mysql_auth.module
--- mysql_auth.module	23 Feb 2006 19:34:19 -0000	1.13
+++ mysql_auth.module	23 Feb 2006 19:43:35 -0000
@@ -121,6 +121,24 @@
  * Helper for mysql_auth_auth
  */
 function mysql_auth_query($username, $password) {
+  $salt = '';
+  if (variable_get('mysql_auth_pass_salt', 0)) {
+    $salt = ', '. variable_get('mysql_auth_pass_col', 'pass');
+  }
+  $res = db_fetch_array(_mysql_auth_query("SELECT %s AS name FROM %s WHERE %s = '%s' AND %s = %s('%s'%s)", array(variable_get('mysql_auth_user_col', 'name'), variable_get('mysql_auth_table', 'users'), variable_get('mysql_auth_user_col', 'name'), $username, variable_get('mysql_auth_pass_col', 'pass'), _mysql_auth_current_scheme(), $password, $salt)));
+  if (!empty($res['name'])) { //we have a winner!
+    return $res['name'];
+  }
+
+  return FALSE;
+}
+
+/**
+ * do a query to the database using credentials defined in this module's configuration
+ *
+ * helper for mysql_auth_query()
+ */
+function _mysql_auth_query($query, $args = null) {
   global $db_url, $active_db;
 
   $behold_db_url = $db_url;
@@ -140,30 +158,14 @@
     db_set_active(variable_get('mysql_auth_string', 'mysql://username:password@localhost/database'));
   }
 
-  if (variable_get('mysql_auth_pass_salt', 0)) {
-    $salt = ', '. variable_get('mysql_auth_pass_col', 'pass');
-  }
-  $res = db_fetch_array(db_query("SELECT %s AS name FROM %s WHERE %s = '%s' AND %s = %s('%s'%s)",
-    variable_get('mysql_auth_user_col', 'name'),
-    variable_get('mysql_auth_table', 'users'),
-    variable_get('mysql_auth_user_col', 'name'),
-    $username,
-    variable_get('mysql_auth_pass_col', 'pass'),
-    _mysql_auth_current_scheme(),
-    $password,
-    $salt
-    ));
+  $query = db_queryd($query, $args);
 
   db_set_active(); //set the connection back
 
   unset($db_url);
   $db_url = $behold_db_url;
 
-  if (!empty($res['name'])) { //we have a winner!
-    return $res['name'];
-  }
-
-  return FALSE;
+  return $query;
 }
 
 /**
