Index: modules/openid/openid.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v
retrieving revision 1.42
diff -u -p -r1.42 openid.module
--- modules/openid/openid.module	14 Mar 2009 20:13:27 -0000	1.42
+++ modules/openid/openid.module	16 Mar 2009 03:49:25 -0000
@@ -347,10 +347,12 @@ function openid_association($op_endpoint
   module_load_include('inc', 'openid');
 
   // Remove Old Associations:
-  db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", REQUEST_TIME);
+  db_delete('openid_association')
+    ->condition('created + expires_in', REQUEST_TIME, '<')
+    ->execute();
 
   // Check to see if we have an association for this IdP already
-  $assoc_handle = db_result(db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = '%s'", $op_endpoint));
+  $assoc_handle = db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = :endpoint", array(':endpoint' => $op_endpoint))->fetchField();
   if (empty($assoc_handle)) {
     $mod = OPENID_DH_DEFAULT_MOD;
     $gen = OPENID_DH_DEFAULT_GEN;
@@ -382,12 +384,19 @@ function openid_association($op_endpoint
       $shared = bcpowmod($spub, $private, $mod);
       $assoc_response['mac_key'] = base64_encode(_openid_dh_xorsecret($shared, $enc_mac_key));
     }
-    db_query("INSERT INTO {openid_association} (idp_endpoint_uri, session_type, assoc_handle, assoc_type, expires_in, mac_key, created) VALUES('%s', '%s', '%s', '%s', %d, '%s', %d)",
-             $op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], REQUEST_TIME);
-
+    db_insert('openid_association')
+     ->fields(array(
+       'idp_endpoint_uri' => $op_endpoint,
+       'session_type' => $assoc_response['session_type'],
+       'assoc_handle' => $assoc_response['assoc_handle'],
+       'assoc_type' => $assoc_response['assoc_type'],
+       'expires_in' => $assoc_response['expires_in'],
+       'mac_key' => $assoc_response['mac_key'],
+       'created' => REQUEST_TIME,
+      ))
+      ->execute();
     $assoc_handle = $assoc_response['assoc_handle'];
   }
-
   return $assoc_handle;
 }
 
@@ -513,7 +522,7 @@ function openid_verify_assertion($op_end
 
   $valid = FALSE;
 
-  $association = db_fetch_object(db_query("SELECT * FROM {openid_association} WHERE assoc_handle = '%s'", $response['openid.assoc_handle']));
+  $association = db_query("SELECT * FROM {openid_association} WHERE assoc_handle = :assoc_handle", array(':assoc_handle' => $response['openid.assoc_handle']))->fetchObject();
   if ($association && isset($association->session_type)) {
     $keys_to_sign = explode(',', $response['openid.signed']);
     $self_sig = _openid_signature($association, $response, $keys_to_sign);
Index: modules/openid/openid.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v
retrieving revision 1.13
diff -u -p -r1.13 openid.pages.inc
--- modules/openid/openid.pages.inc	14 Mar 2009 20:13:27 -0000	1.13
+++ modules/openid/openid.pages.inc	16 Mar 2009 03:49:25 -0000
@@ -35,15 +35,21 @@ function openid_user_identities($account
   $result = openid_complete();
   if ($result['status'] == 'success') {
     $identity = $result['openid.claimed_id'];
-    db_query("INSERT INTO {authmap} (uid, authname, module) VALUES (%d, '%s','openid')", $account->uid, $identity);
+    $query = db_insert('authmap')
+      ->fields(array(
+        'uid' => $account->uid,
+        'authname' => $identity,
+        'module' => 'openid',
+      ))
+      ->execute();
     drupal_set_message(t('Successfully added %identity', array('%identity' => $identity)));
   }
 
   $header = array(t('OpenID'), t('Operations'));
   $rows = array();
 
-  $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=%d", $account->uid);
-  while ($identity = db_fetch_object($result)) {
+  $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=:uid", array(':uid' => $account->uid));
+  foreach ($result as $identity) {
     $rows[] = array(check_plain($identity->authname), l(t('Delete'), 'user/' . $account->uid . '/openid/delete/' . $identity->aid));
   }
 
@@ -70,7 +76,7 @@ function openid_user_add() {
 function openid_user_add_validate($form, &$form_state) {
   // Check for existing entries.
   $claimed_id = _openid_normalize($form_state['values']['openid_identifier']);
-  if (db_result(db_query("SELECT authname FROM {authmap} WHERE authname='%s'", $claimed_id))) {
+  if (db_query("SELECT authname FROM {authmap} WHERE authname = :authname", (array(':authname' => $claimed_id)))->fetchField()) {
     form_set_error('openid_identifier', t('That OpenID is already in use on this site.'));
   }
   else {
@@ -83,13 +89,20 @@ function openid_user_add_validate($form,
  * Menu callback; Delete the specified OpenID identity from the system.
  */
 function openid_user_delete_form($form_state, $account, $aid = 0) {
-  $authname = db_result(db_query('SELECT authname FROM {authmap} WHERE uid = %d AND aid = %d', $account->uid, $aid));
+  $authname = db_query('SELECT authname FROM {authmap} WHERE uid = :uid AND aid = :aid', array(
+    ':uid' => $account->uid,
+    ':aid' => $aid,
+  ))
+  ->fetchField();
   return confirm_form(array(), t('Are you sure you want to delete the OpenID %authname for %user?', array('%authname' => $authname, '%user' => $account->name)), 'user/'. $account->uid .'/openid');
 }
 
 function openid_user_delete_form_submit(&$form_state, $form_values) {
-  db_query("DELETE FROM {authmap} WHERE uid = %d AND aid = %d AND module = 'openid'", $form_state['#args'][0]->uid, $form_state['#args'][1]);
-  if (db_affected_rows()) {
+  $query = db_delete('authmap')
+    ->condition('uid', $form_state['#parameters'][2]->uid)
+    ->condition('aid', $form_state['#parameters'][3])
+    ->execute();
+  if ($query) {  
     drupal_set_message(t('OpenID deleted.'));
   }
   $form_state['#redirect'] = 'user/'. $form_state['#args'][0]->uid .'/openid';
