搜索
系统检测到您的用户名不符合规范:

THINKPHP 分页上一页下一页 分页查询问题

浏览:5844 发布日期:2014年03月26日 分类:求助交流
代码如下 分页上一页 下一页的时候失去查询参数 尝试 把$WHERER 传给分页类但是没有效果 因为 到这个方法之后where 被覆盖了 请大家给点主意



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 == 'title' && (! empty ( $val ))) {//title字段
$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 ();
}
最佳答案
评论() 相关
后面还有条评论,
评论支持使用[code][/code]标签添加代码
您需要登录后才可以评论 登录 | 立即注册
收藏
sddsjik
积分:439 等级:LV2
热点推荐
(追記) (追記ここまで)
最新更新

我们

合作

网站

信息

ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。

AltStyle によって変換されたページ (->オリジナル) /