--- backup/parser.inc	2007-11-16 14:56:52.000000000 -0500
+++ parser.inc	2007-12-16 01:53:13.515625000 -0500
@@ -418,13 +418,12 @@ function api_parse_php_file($file_path, 
  *   The documentation ID of the inserted/updated construct.
  */
 function api_save_documentation(&$docblock) {
-  $result = db_query("SELECT did FROM {api_documentation} WHERE object_name = '%s' AND branch_name = '%s' AND object_type = '%s'", $docblock['object_name'], $docblock['branch_name'], $docblock['object_type']);
-  if (db_num_rows($result) > 0) {
-    $did = db_result($result);
+  $did = db_result(db_query("SELECT did FROM {api_documentation} WHERE object_name = '%s' AND branch_name = '%s' AND object_type = '%s' AND file_name = '%s'", $docblock['object_name'], $docblock['branch_name'], $docblock['object_type'], $docblock['file_name']));
+  if ($did > 0) {
     db_query("UPDATE {api_documentation} SET title = '%s', file_name = '%s', summary = '%s', documentation = '%s', code = '%s' WHERE did = %d", $docblock['title'], $docblock['file_name'], $docblock['summary'], $docblock['documentation'], $docblock['code'], $did);
   }
   else {
-    $did = db_next_id('{api_documentation}_did');
+    $did = db_last_insert_id('api_documentation', 'did');
     db_query("INSERT INTO {api_documentation} (did, object_name, branch_name, object_type, title, file_name, summary, documentation, code) VALUES (%d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $did, $docblock['object_name'], $docblock['branch_name'], $docblock['object_type'], $docblock['title'], $docblock['file_name'], $docblock['summary'], $docblock['documentation'], $docblock['code']);
   }
 
@@ -681,7 +680,7 @@ function api_reference($branch_name, $to
   static $is_php_function = array();
 
   if ($to_type == 'function' && !isset($is_php_function[$to_name])) {
-    $is_php_function[$to_name] = (db_num_rows(db_query("SELECT object_name FROM {api_documentation} WHERE object_name = '%s' AND branch_name = 'php'", $to_name)) == 1);
+    $is_php_function[$to_name] = (db_result(db_query("SELECT COUNT(*) FROM {api_documentation} WHERE object_name = '%s' AND branch_name = 'php'", $to_name)) == 1);
   }
 
   if ($to_type != 'function' || !$is_php_function[$to_name]) {
@@ -696,3 +695,4 @@ function api_update_references() {
   // First, figure out all the dids of the object/branch/types.
   db_query('UPDATE {api_reference_storage} r, {api_documentation} d SET r.to_did = d.did WHERE r.object_name = d.object_name AND r.branch_name = d.branch_name AND r.object_type = d.object_type');
 }
+
