if(!function_exists("get_comments")){
function get_comments($type=0,$num)
{
$sql = 'SELECT * FROM ecs_comment '.
' WHERE status = 1 AND parent_id = 0 and comment_type=$type '.
' ORDER BY add_time DESC';
if ($num > 0)
{
$sql .= ' LIMIT ' . $num;
}
//echo $sql;
$res = $GLOBALS['db']->getAll($sql);
$comments = array();
foreach ($res AS $idx => $row)
{
$comments[$idx]['user_name'] = $row['user_name'];
$comments[$idx]['content'] = $row['content'];
$comments[$idx]['id_value'] = $row['id_value'];
if($type==1)
{
$comments[$idx]['url']=build_uri('article',array('aid'=>$comments[$idx]['id_value']));
}
else
{
$comments[$idx]['url']=build_uri('goods',array('gid'=>$comments[$idx]['id_value']));
}
}
return $comments;
}
}
正文完