黑松山资源网 Design By www.paidiu.com
本文实例讲述了Yii框架引入coreseek分页功能。分享给大家供大家参考,具体如下:
把sphinxapi.php改为SphinxClient.php 类文件随便放,你能找到就行,我放在advanced/frontend/web/SphinxClient.php,打开common/config/bootstrap.php
在里面添加
Yii::$classMap['SphinxClient']='@frontend/web/SphinxClient.php';
地址写正确
在需要用得控制其中 use SphinxClient
controller控制器
/** * 话题搜索 * * @author YING * @param void * @return void */ public function actionTopic() { //模拟数据 $studId=2; //用户id $classId=2; //班级id $title=""; //为空 //实例化模型 $studTopic=new StudTopic(); //查询 $data=$studTopic->find()->select('*')->innerJoin('stud_user','stud_topic.stud_id=stud_user.stud_id')->where(['class_id'=>$classId]); //实例化分页类 $pagination=new Pagination(['totalCount' => $data->count()]); //每页条数 $pagination->setPageSize(3); //执行分页 $topicInfo= $data->offset($pagination->offset)->limit($pagination->limit)->asArray()->all(); //返回值 return $this->render('topicList',['topicInfo'=>$topicInfo,'pages'=>$pagination,'studId'=>$studId,'classId'=>$classId,'title'=>$title]); } /** * coreseek搜索 * * @author YING * @param void * @return void */ public function actionSearchTitle() { //接值 $title=Yii::$app->request->get('t_title'); $classId=Yii::$app->request->get('class_id'); //模拟数据 $studId=2; //用户id //coreseek 搜索 $cl = new SphinxClient (); $cl->SetServer ( '127.0.0.1', 9312); $cl->SetConnectTimeout ( 3 ); $cl->SetArrayResult ( true ); $cl->SetMatchMode ( SPH_MATCH_ANY); $res = $cl->Query ( $title, "*" ); //如果存在值 if($res['total']){ $matches=$res['matches']; foreach($matches as $key => $val){ $tidArray[]=$val['id']; } } //转化为字符串 $tidStr=isset($tidArray) "t_id in ($tidStr)"); //实例化分页类 $pagination=new Pagination(['totalCount' => $data->count()]); //每页条数 $pagination->setPageSize(3); //执行分页 $topicInfo= $data->offset($pagination->offset)->limit($pagination->limit)->asArray()->all(); //加载模板 return $this->render('topicList',['topicInfo'=>$topicInfo,'pages'=>$pagination,'studId'=>$studId,'classId'=>$classId,'title'=>$title]); }
view视图
<"table"> <tr> <td>标题</td> <td>作者</td> <td>发布时间</td> <td>操作</td> </tr> <"tr_<"> <td><input type="checkbox" tid="<"/> <"index.php" rel="external nofollow" >编辑</a>||<a href="">删除</a></td> <"">删除</a></td> <"button" value="全选/全不选" id="all"/></td> <td><input type="button" value="反选" id="fan"/></td> <td><input type="button" value="批删" id="del"/></td> </tr> </table> <"./css/js/jquery.1.12.min.js"></script> <script> //全选/全不选 var temp=true; //临时变量 $('#all').click(function(){ $('input[type="checkbox"]').prop('checked',temp); //取反 temp=!temp; }) //批删 $('#del').click(function(){ var checkAll=$('input[type="checkbox"]'); //获取全部的复选框 var length=checkAll.length; //计算长度 var arr=new Array(); //定义数组 var str=""; //定义字符串 //循环 $.each(checkAll,function(k,v){ //判断是否选中 if(checkAll[k].checked){ arr.push(checkAll.eq(k).attr('tid')); } }) //转化为字符串 str=arr.join(','); //ajax var url="index.php"; //地址 $.get(url,{str:str},function(msg){ if(msg){ //window.location.reload(); //刷新页面 //节点删除 $.each(arr,function(k,v){ $('#tr_'+v).remove(); }); } },'json'); }); //反选 $("#fan").click(function(){ var checkAll=$('input[type="checkbox"]'); //获取复选 $.each(checkAll,function(k,v){ this.checked=!this.checked; }) }); </script>
搞定 收工 ok!
更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。
更新日志
2025年03月06日
2025年03月06日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]