Пример #1
0
function dbUtil()
{
    reset_db_result();
    $args_arr = func_get_args();
    $type = $args_arr[0];
    try {
        $mongo = new MongoClient('mongodb://nb403:27127/admin:admin');
        $db = $mongo->svnCodeComment;
        if ($type == GetProductList) {
            return getProductList($db);
        } elseif ($type == GetVersionList) {
            $prodName = $args_arr[1];
            return getVersionList($db, $prodName);
        } elseif ($type == CodeSearch) {
            list($prodName, $version, $keyword) = array_slice($args_arr, 1);
            return codeSearch($db, $prodName, $version, $keyword);
        } elseif ($type == CodeSearchDetail) {
            list($prodName, $id) = array_slice($args_arr, 1);
            return codeSearchDetail($db, $prodName, $id);
        } elseif ($type == AddCodeInfo) {
            list($codeSvnPathWithVersion, $version, $prodName, $creator, $diskPath) = array_slice($args_arr, 1);
            return addCodeInfo($db, $codeSvnPathWithVersion, $version, $prodName, $creator, $diskPath);
        } elseif ($type == GetCommentorList) {
            $prodName = $args_arr[1];
            return getCommentorList($db, $prodName);
        } elseif ($type == GetCreator) {
            list($prodName, $version) = array_slice($args_arr, 1);
            return getCreator($db, $prodName, $version);
        } elseif ($type == GetCodeDiskPath) {
            list($prodName, $version) = array_slice($args_arr, 1);
            return getCodeDiskPath($db, $prodName, $version);
        } elseif ($type == GetCodeInfo) {
            list($prodName, $version) = array_slice($args_arr, 1);
            return getCodeInfo($db, $prodName, $version);
        } elseif ($type == GetProdNameMap) {
            return getProdNameMap($db);
        } elseif ($type == SetProdNameMap) {
            list($prodName, $tableName) = array_slice($args_arr, 1);
            return setProdNameMap($db, $prodName, $tableName);
        }
    } catch (MongoConnectionException $e) {
        set_db_result("1", $e->getMessage());
    }
}
Пример #2
0
function dbUtil()
{
    $args_arr = func_get_args();
    $type = $args_arr[0];
    if ($type != GetStatus && $type != SetStatus) {
        reset_db_result();
    }
    try {
        $mongo = new MongoClient('mongodb://nb403:27127/admin:admin');
        $db = $mongo->svnCodeComment;
        if ($type == LoadCodePathInfoTable) {
            return load_codePathInfoTable($db);
        } elseif ($type == LoadProdTableNameMapInfoTable) {
            return load_prodTableNameMapInfoTable($db);
        } elseif ($type == LoadCodeCommentInfoTable) {
            $prodName = $args_arr[1];
            return load_codeCommentInfoTable($db, $prodName);
        } elseif ($type == SaveCodePathInfo) {
            list($svnAddr, $version, $prodName, $creator) = array_slice($args_arr, 1);
            return save_codePathInfo($db, $svnAddr, $version, $prodName, $creator);
        } elseif ($type == SaveProdTableNameMapInfo) {
            list($prodName, $tableName) = array_slice($args_arr, 1);
            return save_prodTableNameMapInfo($db, $prodName, $tableName);
        } elseif ($type == SaveCodeCommentInfo) {
            list($prodName, $version, $status, $filePath, $commentor, $type, $content, $detail_type, $selected_id) = array_slice($args_arr, 1);
            return save_codeCommentInfo($db, $prodName, $version, $status, $filePath, $commentor, $type, $content, $detail_type, $selected_id);
        } elseif ($type == SetStatus) {
            list($status, $msg) = array_slice($args_arr, 1);
            return set_db_result($status, $msg);
        } elseif ($type == GetStatus) {
            return get_db_result();
        } elseif ($type == CreateCollection) {
            $tableName = $args_arr[1];
            return create_table($db, $tableName);
        }
    } catch (MongoConnectionException $e) {
        set_db_result(1, $e->getMessage());
        return false;
    }
}