#1 homexigua
$this->menuname = '教室使用情况查询';以上代码中只要涉及数字的文本框使用escape就会什么也检索不出来,也无法翻页。escape是否只对字符串有效?可否弄个我们菜鸟通用的过滤,省的还得每次鉴别需要不需要使用escape
$db = spClass('lib_course');
$sql = "select * from c_course where 1=1";
$course_flag=(int)$this->spArgs('course_flag',1); //默认有课
$this->course_flag = $course_flag;
//检索
//日期检索
$course_date = $this->spArgs('course_date',false);
$this->course_date = $course_date;
$week = date('w',strtotime($course_date));//通过日期获得星期
$weekly = (int)(((strtotime($course_date)-strtotime('2010-8-23'))/86400 +1)/7+1); //获取周数
if($course_date!=false){
$condition = " and course_week=$week and substr(course_weekly,$weekly,1)=$course_flag";
$sql.=$condition;
}
//星期
$course_week = (int)$this->spArgs('course_week',0);
$this->course_week=$course_week;
if($course_week!=0 and $course_date==false){
$condition = " and course_week=$course_week";
$sql .= $condition;
}
//课程名
$course_name = $db->escape($this->spArgs('course_name',false));
$course_name = trim($course_name,"'");
$this->course_name=$course_name;
if($course_name!=false){
$condition = " and course_name like '%$course_name%'";
$sql .= $condition;
}
//教师
$course_teacher = $db->escape($this->spArgs('course_teacher',false));
$course_teacher = trim($course_teacher,"'");
$this->course_teacher=$course_teacher;
if($course_teacher!=false){
$condition = " and course_teacher like '%$course_teacher%'";
$sql .= $condition;
}
//教室
$course_room = $db->escape($this->spArgs('course_room',false));
$course_room = trim($course_room,"'");
$this->course_room=$course_room;
if($course_room!=false){
$condition = " and course_room like '%$course_room%'";
$sql .= $condition;
}
//节次为数字
$course_jieci = (int)$this->spArgs('course_jieci',0);
$this->course_jieci=$course_jieci;
if($course_jieci!=0 and $course_time==0){
$condition = " and course_jieci=$course_jieci";
$sql .= $condition;
}
//周次
$course_weekly = (int)$this->spArgs('course_weekly',0);
$this->course_weekly=$course_weekly;
if($course_weekly!=0 and $course_date==false){
$condition = " and substr(course_weekly,$course_weekly,1)=$course_flag";
$sql .= $condition;
}
//班级
$course_class = $db->escape($this->spArgs('course_class',false));
$course_class = trim($course_class,"'");
$this->course_class=$course_class;
if($course_class!=false){
$condition = " and course_class like '%$course_class%'";
$sql .= $condition;
}
$sql.=" order by course_room,course_jieci";
$this->list = $db->spPager($this->spArgs('p',1),14)->findSql($sql);
$this->pager = $db->spPager()->getPager();
echo $db->dumpSql();
2010-09-20 09:08:25