/**
  *查询模块,用于获取数据
  *@param where (必要属性) array 关键字段(eq){key:value}
  *@param field (必要属性如果不提交则认为不查询任何数据) array 需要查询字段,类型为{"0":value,……}
  *@param from (必要属性) string 查询的表(后端检验)
  *@param pagination (必要属性) int 分页
  *@param page int 页码
  *@return list array返回查询列表{"0":{array}……}
  */
 function query()
 {
     $where = I("post.where");
     $field = I("post.field");
     $from = I("post.from");
     $page = I("post.page", 1);
     $pagination = I("post.pagination", 20);
     //设定查询内容
     if (isset($where)) {
         foreach ($where as $i) {
             $map[$i["key"]] = $i["value"];
         }
     } else {
         $map = array();
     }
     //初始化返回
     $returns = array();
     if (in_array($from, array("orders", "positions", "postor", "usr"))) {
         $returns = getDataByKeyWords($type, $map, $from, $pagination, $field, $page);
         if ($returns["list"] != null) {
             $res = array(response => "query", status => "1", "list" => $returns["list"], page => $page, maxPage => $returns["max"]);
         } else {
             $res = array(response => "fail", status => "2");
         }
     } else {
         $res = array(response => "fail", status => "2");
     }
     $this->ajaxReturn(json_encode($res), 'JSON');
 }
 public function test()
 {
     // $this->display(index);
     var_dump(getDataByKeyWords(array('key' => 'usrid', 'word' => '111111', 'type' => 'EQ'), 'orders', 3, array('orderid'), 1));
 }
 public function getAllTables()
 {
     //传入page
     $page = I('post.page');
     //设定分页数目
     $pagination = 6;
     //设定查询内容
     $map['usrId'] = $this->id;
     //设定表
     $table = 'orders';
     //设定返回字段
     $field = array('orderId', 'orderInfo', 'positionId', 'exportTime', 'importTime', 'postorId');
     $type = array();
     $orderlist = getDataByKeyWords($type, $map, $table, $pagination, $field, $page);
     $res = array(response => "用户昵称", status => "1", orders => $orderlist["list"], page => $page, maxPage => $orderlist["max"]);
     $this->ajaxReturn(json_encode($res), 'JSON');
 }