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,请问呢这个是怎么列出来的呢,看不太懂求助 展开
{
/* 查询条件 */
$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,请问呢这个是怎么列出来的呢,看不太懂求助 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询