//另一种更安全的方法,且解决了查询,分页的问题,以后都应该用这种方法来做
publicfunction manage($n) {
$tab = M($n);
$Bigtitle = I(‘Bigtitle‘);
$Publishtime = I(‘Publishtime‘);
$page = isset($_POST[‘page‘]) ?intval($_POST[‘page‘]) : 1;
$rows = isset($_POST[‘rows‘]) ?intval($_POST[‘rows‘]) : 10;
$offset = ($page - 1) * $rows;
$sql[‘Lixiao‘] = ‘否‘;
$sql[‘SchoolID‘] ="$_SESSION[SchoolID]";
if ($Bigtitle != ‘‘) {
$sql[‘Bigtitle‘] ="$Bigtitle";
}
if ($Publishtime != ‘‘) {
$sql[‘Publishtime‘] ="$Publishtime";
}
$sql[‘_logic‘] = ‘AND‘;
$total =$tab->where($sql)->count();
$rs =$tab->where($sql)->limit($offset, $rows)->select();
if (!isset($rs)) {
$json->total = 0;
$json->rows = array();
} else {
$json->total = $total;
$json->rows = $rs;
}
$this->ajaxReturn($json);
}
时间: 2024-12-28 01:50:05