/** * @param int $id project_id * @return boolean TRUE if Project exists in Mantis DB */ public static function exists($id) { if (NULL == $id) { self::$logger->warn("exists(): id == NULL."); return FALSE; } if (NULL == self::$existsCache) { self::$existsCache = array(); } if (NULL == self::$existsCache[$id]) { $query = "SELECT COUNT(id) FROM `mantis_project_table` WHERE id=" . $id . ";"; $result = SqlWrapper::getInstance()->sql_query($query); if (!$result) { echo "<span style='color:red'>ERROR: Query FAILED</span>"; exit; } #$found = (0 != SqlWrapper::getInstance()->sql_num_rows($result)) ? true : false; $nbTuples = 0 != SqlWrapper::getInstance()->sql_num_rows($result) ? SqlWrapper::getInstance()->sql_result($result, 0) : 0; if (1 != $nbTuples) { self::$logger->warn("exists({$id}): found {$nbTuples} items."); } self::$existsCache[$id] = 1 == $nbTuples; } return self::$existsCache[$id]; }