表结构:
代码:
查询包今$mid和$department_id的记录
$mid = cookie('mid');
$department_id = M('user')->where('id = ' . $mid)->getField('department_id');
if(!$type) {
//首次加载首页
$where = 'is_send = 1 and to_type = 1 or find_in_set(' . $mid . ',to_mid) or find_in_set(' . $department_id . ',to_department)';
} elseif ($type == 1) {
$new_id = I('post.new_li','','intval');
$where = 'id > ' . $new_id;
$where .= ' and (is_send = 1 and to_type = 1 or find_in_set(' . $mid . ',to_mid) or find_in_set(' . $department_id . ',to_department))';
} elseif($type == 2) {
$page = I('post.page',2,'intval');
$where = 'is_send = 1 and to_type = 1 or find_in_set(' . $mid . ',to_mid) or find_in_set(' . $department_id . ',to_department)';
}
$order = 'add_time desc';//is_top desc,
$list = M('notice')->where($where)->order($order)->page($page, $limit)->select();