// 检索 function search() { // 默认条件 $condition = ' 1=1 and {$search_condition} '; // 动态条件区域 {$search_data} // COUNT $count = 0; if(strcmp($_SESSION['{$ename}_Count'], '')==0 || strcmp(I('changepage'), '1')!=0){ $count = M('{$new_obj_name}')->where($condition){$search_group}->count(); $_SESSION['{$ename}_Count'] = $count; }else{ $count = $_SESSION['{$ename}_Count']; } // COUNT > 0 if (strcmp($count, 0) != 0) { // 默认排序 $order='{$search_order}'; // 排序 if (strcmp(I('sortname'), '')!=0){ $order='`'.I('sortname').'` '.I('sortorder'); } // 分页 $limit = (I('page') - 1) * I('pagesize') . ',' . I('pagesize'); // 检索 $list = M('{$new_obj_name}')->where($condition){$search_group}->order($order)->limit($limit)->select(); } else { $list = array (); } return $data = array ( 'count' => $count, 'data' => $list ); }