error = $query . "
" . $error; } else { $this->error = ''; } $total = DB::counter($table, $conds, '*'); //获取总数量,计算总页数 } else { //用来解决sql语句复杂的情况下 无法正确计算总条数的BUG $query = $sql . " LIMIT {$start},{$length}"; $array = DB::get_all($query); $error = DB::error(); $this->error = $error?$query . "
" . $error:0; //总数 $where = trim($where); if (strtolower(substr($where, 0, 5)) != 'where' && $where) $where = "WHERE " . $where; $countsql = " SELECT COUNT(*) FROM {$table} {$where} "; if($multi_table) $countsql = " SELECT count(*) FROM ($sql) num "; $result = DB::query($countsql); $fetch_row = DB::fetch_row($result); $total = $fetch_row[0]; } /* 回传数组处理 */ $this->rarray = array(); $this->rarray['draw'] = $draw; //回传执行次数 $this->rarray['recordsTotal'] = $total; //回传总数量 $this->rarray['recordsFiltered'] = $total; //回传筛选过的总数量,暂无作用,但必须回传 // if(class_exists('admin') || class_exists('app')){ $this->rarray['sql'] = $query; //返回sql语句 $this->rarray['array'] = $array; //返回sql语句 $this->rarray['form'] = $_M['form']; //返回sql语句 $this->rarray['sqlse'] = $sql; //返回sql语句 $this->rarray['sqltotal'] = $countsql; //返回sql语句 // } return $array; } /** * 把处理后的数组已json方式输出到页面上,供AJAX读取。 * @param array $rdata 需要转成json的数组 */ public function rdata($rdata) { if ($rdata) { $this->rarray['data'] = $rdata; } else { $this->rarray['data'][''] = ''; } jsoncallback($this->rarray); //回传json格式 } } # This program is an open source system, commercial use, please consciously to purchase commercial license. # Copyright (C) MetInfo Co., Ltd. (http://www.metinfo.cn). All rights reserved. ?>