ecshop get_message_list函数

functionget_message_list(){/*查询条件*/$filter['sort_by']=empty($_REQUEST['sort_by'])?'se... function get_message_list()
{
/* 查询条件 */
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'sent_time' : trim($_REQUEST['sort_by']);
$filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
$filter['msg_type'] = empty($_REQUEST['msg_type']) ? 0 : intval($_REQUEST['msg_type']);

/* 查询条件 */
switch ($filter['msg_type'])
{
case 1:
$where = " a.receiver_id='" .$_SESSION['admin_id']. "'";
break;
case 2:
$where = " a.sender_id='".$_SESSION['admin_id']."' AND a.deleted='0'";
break;
case 3:
$where = " a.readed='0' AND a.receiver_id='".$_SESSION['admin_id']."' AND a.deleted='0'";
break;
case 4:
$where = " a.readed='1' AND a.receiver_id='".$_SESSION['admin_id']."' AND a.deleted='0'";
break;
default:
$where = " (a.receiver_id='".$_SESSION['admin_id']."' OR a.sender_id='" .$_SESSION['admin_id']. "') AND a.deleted='0'";
}

$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('admin_message')." AS a WHERE 1 AND ". $where;
$filter['record_count'] = $GLOBALS['db']->getOne($sql);

/* 分页大小 */
$filter = page_and_size($filter);

$sql = "SELECT a.message_id,a.sender_id,a.receiver_id,a.sent_time,a.read_time,a.deleted,a.title,a.message,b.user_name".
" FROM ".$GLOBALS['ecs']->table('admin_message')." AS a,".$GLOBALS['ecs']->table('admin_user')." AS b ".
" WHERE a.sender_id=b.user_id AND $where ".
" ORDER BY ".$filter['sort_by']." ".$filter['sort_order'].
" LIMIT ". $filter['start'] .", $filter[page_size]";
$row = $GLOBALS['db']->getAll($sql);

foreach ($row AS $key=>$val)
{
$row[$key]['sent_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['sent_time']);
$row[$key]['read_time'] = local_date($GLOBALS['_CFG']['time_format'], $val['read_time']);
}

$arr = array('item' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);

return $arr;
}
简单的说就是用户提问和管理员回答的对话列表,所有对话放在一个表,管理员对话的条有一个parent_id,就是提问条的id,请问呢这个是怎么列出来的呢,看不太懂求助
展开
 我来答
影翼视觉lyl
2014-08-07 · TA获得超过630个赞
知道小有建树答主
回答量:1279
采纳率:50%
帮助的人:680万
展开全部
列出来,那你可以参考这个写法,这边赋值进来就行了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式