Example #1
0
function paper_get_top_papers()
{
    global $tablePreStr;
    $t_papers = $tablePreStr . "papers";
    $t_users = $tablePreStr . "users";
    $t_comments = $tablePreStr . "comments";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    /*select isns_papers.*, isns_users.*, count(isns_comments.paper_id) as count 
    from isns_papers 
    left join isns_comments on isns_comments.paper_id = isns_papers.paper_id and isns_comments.comment_type=0
    left join isns_users on isns_users.user_id=isns_papers.user_id group by isns_papers.paper_id order by isns_papers.create_time desc;*/
    $sql = "select \n\t \t{$t_papers}.*, \n\t \t{$t_users}.* \n\t\tfrom {$t_papers} left join {$t_comments} on {$t_comments}.paper_id = {$t_papers}.paper_id and {$t_comments}.comment_type=0\n\t\tleft join {$t_users} on {$t_users}.user_id={$t_papers}.user_id group by {$t_papers}.paper_id order by {$t_papers}.paper_id desc limit 10";
    $result_rs = $dbo->getALL($sql);
    $result_rs = calc_all_distance($result_rs);
    return $result_rs;
}
<?php

require "api/base_support.php";
//引入语言包
$pu_langpackage = new publiclp();
//变量取得
$least_paper_id = get_argg("least_paper_id");
//返回数量
$return_num = 10;
$result = array();
if ($least_paper_id <= 0) {
    echo json_encode($result);
}
//数据表定义区
$t_papers = $tablePreStr . "papers";
$t_users = $tablePreStr . "users";
$dbo = new dbex();
dbplugin('r');
$get_more_papers_sql = "select {$t_papers}.*, {$t_users}.* from {$t_papers}, {$t_users} where {$t_users}.user_id={$t_papers}.user_id and {$t_papers}.paper_id < {$least_paper_id} limit {$return_num}";
//						  select isns_papers.*, isns_users.user_name from isns_papers, isns_users where isns_users.user_id=isns_papers.user_id and isns_papers.paper_id < 222239 limit 2;
//$get_more_papers_sql = "select * from $t_papers where $t_papers.paper_id < $least_paper_id limit $return_num";
$result = $dbo->getALL($get_more_papers_sql);
$result = calc_all_distance($result);
echo json_encode($result);