实例介绍
【实例简介】
【实例截图】
【核心代码】
<?php /** * Created by PhpStorm. * User: Administrator * Date: 14-10-4 * Time: 下午1:08 */ require './db.class.php'; require './command.php'; require './response.php'; class SearthListAction{ /** * @param $array */ public function SearthList($array) { $search = new SearthListAction(); $searchType = lib_replace_end_tag(trim($array['searchType'])); if($searchType!=='' && isset($array['searchType'])){ if (is_int($searchType)||is_numeric($searchType)) { switch ($searchType) { case 1: $search->Searthages($array); break; case 2: $search->Searth($array); break; } } else { // return Response::show(1003, "搜索类型不合法"); $search->SearthIndex($array); } }else{ $search->SearthId($array); } } //第三种查找方法 public function SearthId($array) { $userid = lib_replace_end_tag(trim($array['userId'])); $test = array( userId => '100', userName => 'hello,美女', icon=>'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, ccode => 10106006, monthlyIncome => '5000-8000', age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专' ); if (!empty($userid)) { if (is_numeric($userid)) { //if($userid=='数据库中的值'){ return Response::show(0, "搜索成功", $test); //}else{return Response::show(1007,"账号不存在或错误");} } else { return Response::show(1006, "用户ID不能为空"); } } else { return Response::show(1005, "用户ID不能为空"); } } //第一种查找方法 public function Searthages($array) { $ageScope = lib_replace_end_tag(trim($array['ageScope'])); $pcode = lib_replace_end_tag(trim($array['pcode'])); $ccode = lib_replace_end_tag(trim($array['ccode'])); $pageNo = lib_replace_end_tag(trim($array['pageNo'])); if(empty($ageScope)){ return Response::show(1001, "年龄不能为空"); }else { $age=explode(',',$ageScope); //查找数据库 $arr=array( array(userId => '100', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '101', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '102', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '103', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '104', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '105', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '106', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '107', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '108', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '109', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '110', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '111', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), ); //分页 $count=count($arr); $Page_size=6; $page_count = ceil($count/$Page_size); //判断当前页码 if(empty($pageNo)||$pageNo<0){ $pageNo=1; }else { $pageNo=$pageNo; } $offset=$Page_size*($pageNo-1); for($off=$offset;$off<$offset $Page_size;$off ){ $arr1[]=$arr[$off]; } $test = array( elements => $arr1, pageNo => $pageNo, pageSize => $Page_size, totalCount => $count, totalPages=>$page_count ); return Response::show(0, "搜索成功", $test); } } //第二种查找方法 public function Searth($array) { $sex = lib_replace_end_tag(trim($array['sex'])); $ageScope = lib_replace_end_tag(trim($array['ageScope'])); $pcode = lib_replace_end_tag(trim($array['pcode'])); $ccode = lib_replace_end_tag(trim($array['ccode'])); $maritalStatus = lib_replace_end_tag(trim($array['maritalStatus'])); $education = lib_replace_end_tag(trim($array['education'])); $monthlyIncome = lib_replace_end_tag(trim($array['monthlyIncome'])); $personHeight = lib_replace_end_tag(trim($array['personHeight'])); $nation = lib_replace_end_tag(trim($array['nation'])); $animals = lib_replace_end_tag(trim($array['animals'])); $constllation = lib_replace_end_tag(trim($array['constllation'])); $bloodType = lib_replace_end_tag(trim($array['bloodType'])); $houseStatus = lib_replace_end_tag(trim($array['houseStatus'])); $carStatus = lib_replace_end_tag(trim($array['carStatus'])); $job = lib_replace_end_tag(trim($array['job'])); $broSister = lib_replace_end_tag(trim($array['broSister'])); $photos = lib_replace_end_tag(trim($array['photos'])); $pageNo = lib_replace_end_tag(trim($array['pageNo'])); if (empty($ageScope)) { return Response::show(1001, "年龄不能为空"); } else { //查找数据库 $arr=array( array(userId => '100', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '101', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '102', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '103', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '104', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '105', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '106', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '107', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '108', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '109', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '110', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '111', userName => 'hello,美女', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), ); //分页 $count=count($arr); $Page_size=6; $page_count = ceil($count/$Page_size); //判断当前页码 if(empty($pageNo)||$pageNo<0){ $pageNo=1; }else { $pageNo=$pageNo; } $offset=$Page_size*($pageNo-1); for($off=$offset;$off<$offset $Page_size;$off ){ $arr1[]=$arr[$off]; } $age=explode(',',$ageScope); $test = array( elements => $arr1, pageNo => $pageNo, pageSize => $Page_size, totalCount => $count, totalPages=>$page_count ); return Response::show(0, "搜索成功", $test); } } //默认返回的数据 public function SearthIndex($array){ $pageNo = lib_replace_end_tag(trim($array['pageNo'])); $arr=array( array(userId => '100', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '101', userName => 'hello', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '102', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '103', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '104', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '105', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '106', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '107', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '108', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '109', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '110', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), array(userId => '111', userName => 'hello,', icon => 'http://www.772500.com/app/appp/Action/pic/2.jpg', pcode => 10106000, monthlyIncome => '5000-8000', ccode => 10106006, age => 25, personHeight => '170', maritalStatus => '未婚', education => '大专',monthlyIncome => '5000-8000', ), ); //分页 $count=count($arr); $Page_size=6; $page_count = ceil($count/$Page_size); //判断当前页码 if(empty($pageNo)||$pageNo<0){ $pageNo=1; }else { $pageNo=$pageNo; } $offset=$Page_size*($pageNo-1); for($off=$offset;$off<$offset $Page_size;$off ){ $arr1[]=$arr[$off]; } $test = array( elements => $arr1, pageNo => $pageNo, pageSize => $Page_size, totalCount => $count, totalPages=>$page_count ); return Response::show(0, "搜索成功", $test); } } ?>
好例子网口号:伸出你的我的手 — 分享!
相关软件
网友评论
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
支持(0) 盖楼(回复)