function model_list() {
$id = ( int ) $this->_get ( "ws_id" );//获取排期ID
$this->assign ( 'ws_id', $id );//分配ID
$wedding_schedule = $this->wedding_schedule_obj->where ( "id=$id" )->find ();//获取排期信息
$this->assign ( "wedding_schedule", $wedding_schedule );//分配排期信息
$time = $_SERVER ['REQUEST_TIME'];//获取搜寻时间
$this->assign ( 'state_time', $time+1 );//分配请求时间便于前台判断婚期状态是否过期
// 组合查询条件
//global $where;
$where['ws_id']=array('EQ',$id);
foreach ( $_POST as $key => $val ) {
if ($key == 'ti
$where [$key] = array (
'LIKE',
'%' . $val . '%'
);
continue;
}
if ($key == 'state' && $val !== '')//是否显示的STATE字段
$where [$key] = array (
'EQ',
$val
);
if (! empty ( $val ))
$where [$key] = array (
'EQ',
$val
);
if ($key == 'state_time') {//是否生效的提交的查询数据
$state_val=$val;
$this->assign('state_val',$state_val);//给前台分配查询是否过期的属性
if($val==4)continue;
if ($val == 1) {
$where ['end_time'] = array (
'LT',
$time
);
} elseif ($val == 2) {
$where ['start_time'] = array (
'GT',
$time
);
} elseif ($val == 3) {
$where ['start_time'] = array (
'LT',
$time
);
$where ['end_time'] = array (
'GT',
$time
);
}
}
}
import ( 'ORG.Util.Page' ); // 导入分页类
$count = $this->wedding_schedule_model_obj->where ( "ws_id = " . $id )->where ( $where )->count (); // 数据总数
$Page = new Page ( $count, '', "ws_id=$id" ); // 实例化分页类
$show = $Page->show (); // 分页显示输出
$this->assign ( 'page', $show ); // 赋值分页输出
$wedding_schedule_model_fields = $this->wedding_schedule_model_obj->field ( 'model_name' )->where ( "ws_id = " . $id )->order ( 'add_time desc' )->select ();
$wedding_schedule_model = $this->wedding_schedule_model_obj->where ( $where )->order ( 'add_time desc' )->limit ( $Page->firstRow . ',' . $Page->listRows )->select ();
$this->assign ( 'wedding_schedule_model_fields', $wedding_schedule_model_fields );
$this->assign ( "wedding_schedule_model", $wedding_schedule_model );
$this->display ();
}
最佳答案