示例#1
0
 private static function getNext($table)
 {
     $sql = "REPLACE INTO {$table} (stub) VALUES ('a')";
     if (Z_Core::probability(2)) {
         try {
             Zotero_ID_DB_1::query($sql);
             $id = Zotero_ID_DB_1::valueQuery("SELECT LAST_INSERT_ID()");
         } catch (Exception $e) {
             Z_Core::logError("Error accessing ID server 1");
             Zotero_ID_DB_2::query($sql);
             $id = Zotero_ID_DB_2::valueQuery("SELECT LAST_INSERT_ID()");
         }
     } else {
         try {
             Zotero_ID_DB_2::query($sql);
             $id = Zotero_ID_DB_2::valueQuery("SELECT LAST_INSERT_ID()");
         } catch (Exception $e) {
             Z_Core::logError("Error accessing ID server 2");
             Zotero_ID_DB_1::query($sql);
             $id = Zotero_ID_DB_1::valueQuery("SELECT LAST_INSERT_ID()");
         }
     }
     if (!$id || !is_int($id)) {
         throw new Exception("Invalid id {$id}");
     }
     return $id;
 }
示例#2
0
 public function testID()
 {
     $id = Zotero_ID_DB_1::valueQuery("SELECT id FROM items");
     $this->assertNotEquals(false, $id);
     $id = Zotero_ID_DB_2::valueQuery("SELECT id FROM items");
     $this->assertNotEquals(false, $id);
 }