Example #1
0
function comment_list()
{
    $gender_value_arr = array(1, 2, 3, 4);
    //1:男对女,2:女对男,3:男对男,4:女对女
    $type_arr = array(1, 2);
    //1:视频介绍,2:人生经历
    foreach ($type_arr as $type_value) {
        foreach ($gender_value_arr as $gender_value) {
            $cache_file = getCacheFile($gender_value . $type_value);
            $sql = "SELECT id,comment FROM {$GLOBALS['dbTablePre']}manage_comment where type=1 and comment_type='{$type_value}' and (comment_sort='{$gender_value}' or comment_sort='0') ORDER BY id DESC";
            $comment_list = $GLOBALS['_MooClass']['MooMySQL']->getAll($sql);
            foreach ($comment_list as $key => $value) {
                $comment_list_tmp[$value['id']] = $value['comment'];
            }
            setArrayCache($gender_value . $type_value, $comment_list_tmp);
            $comment_list_tmp = array();
            $comment_list = array();
        }
        //echo "正在生成缓存文件,请稍等....";
    }
    return 'ok';
}
Example #2
0
function comment_list($gender_value, $type = 1)
{
    global $_MooClass, $dbTablePre;
    $cache_file = getCacheFile($gender_value . $type);
    if (file_exists($cache_file) && filemtime($cache_file) + 3600 > time()) {
        include $cache_file;
        return $data;
    } else {
        $sql = "SELECT id,comment FROM {$dbTablePre}manage_comment where type=1 and comment_type='{$type}' and (comment_sort='{$gender_value}' or comment_sort='0') ORDER BY id DESC";
        $comment_list = $_MooClass['MooMySQL']->getAll($sql);
        foreach ($comment_list as $key => $value) {
            $comment_list_tmp[$value['id']] = $value['comment'];
        }
        setArrayCache($gender_value . $type, $comment_list_tmp);
        return $comment_list_tmp;
    }
}