コード例 #1
0
/** To get the Currency of the specified user
 * @param $id -- The user Id:: Type integer
 * @returns  vtiger_currencyid :: Type integer
 */
function fetchCurrency($id)
{
    global $log;
    $log->debug("Entering fetchCurrency(" . $id . ") method ...");
    // Lookup the information in cache
    $currencyinfo = VTCacheUtils::lookupUserCurrenyId($id);
    if ($currencyinfo === false) {
        global $adb;
        $sql = "select currency_id from vtiger_users where id=?";
        $result = $adb->pquery($sql, array($id));
        $currencyid = $adb->query_result($result, 0, "currency_id");
        VTCacheUtils::updateUserCurrencyId($id, $currencyid);
        // Re-look at the cache for consistency
        $currencyinfo = VTCacheUtils::lookupUserCurrenyId($id);
    }
    $currencyid = $currencyinfo['currencyid'];
    $log->debug("Exiting fetchCurrency method ...");
    return $currencyid;
}