Ejemplo n.º 1
0
 public static function setBuildPrimaryScreenshot($sid, $bid)
 {
     //we don't care if this returns true or false, this is to ensure the mapping exists
     ScreenshotManager::addScreenshotToBuild($sid, $bid);
     $database = new DatabaseManager();
     ScreenshotManager::verifyTable($database);
     if (!$database->query("UPDATE `build_screenshotmap` SET `primary` = '0' WHERE\n\t\t\t`bid` = '" . $database->sanitize($bid) . "'")) {
         throw new Exception("Database error: " . $database->error());
     }
     //$oldPrimaryID = getBuildPrimaryScreenshot($bid);
     //
     //if($oldPrimaryID !== false) {
     //	if(!$database->query("UPDATE `build_screenshotmap` SET `primary` = '0' WHERE
     //		`sid` = '" . $database->sanitize($oldPrimaryID) . "'")) {
     //		throw new Exception("Database error: " . $database->error());
     //	}
     //	apc_delete('ScreenshotObject_' . $oldPrimaryID);
     //}
     if (!$database->query("UPDATE `build_screenshotmap` SET `primary` = '1' WHERE\n\t\t\t`bid` = '" . $database->sanitize($bid) . "' AND\n\t\t\t`sid` = '" . $database->sanitize($sid) . "'")) {
         throw new Exception("Database error: " . $database->error());
     }
     apc_delete('buildPrimaryScreenshot_' . $bid);
     return true;
 }