请高手提供php+MongoDB数据库分页函数,或者类使用,等候中! 为了数据的访问速度我,最近研究一下这个php+MongoDB,但是网上找不到分页的集成好的函数或者类,请高手提供,感谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /** * 得到指定区间的n条信息 * * 默认以时间升序排序 * */ function page( $page = 1 , $page_size = 2 , $sort = array( 'time' => -1 )){ 查询条件 $where = array( 'email' => $this->email ); $cursor = $this->db_obj_user_complaint->collection->find( $where ); //需要跳过的记录数 $skip = ($page-1) * $page_size; $skip = $skip<0 ? 0 : $skip ; //每页显示page_size条记录 return $cursor->sort( $sort )->skip( $skip )->limit( $page_size ); } 这个是mongodb+php分页的,做到一半,但是分页效果没有出来,请教各位一下,怎么弄?<style type="text/css">.tb1{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid; background:#FFCC00;}.tb2{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid;}.tb3{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid; color:#FF0000;}.tb4{border-bottom:#CCCCCC 1px solid; color:#FF0000;}.tb5{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid; }.tb6{border-bottom:#CCCCCC 1px solid;}</style><?php$this->pageTitle=Yii::app()->name . ' - index';$this->breadcrumbs=array( 'index',);?><body><div style=" background-color:#FFFFFF; padding:10px 10px;"><table><tr> <td><select name="color" onchange = "showandhide(this.value)"> <option value="3">Please select categories</option> <option value="1" >publisher</option> <option value="2">network</option> </select></td> <td>date: <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( 'name'=>'publishDate', // additional javascript options for the date picker plugin 'options'=>array( 'showAnim'=>'fold', ), 'htmlOptions'=>array( 'style'=>'height:20px;' ),)); ?></td> <td> <input name="soso" type="text" size="20" maxlength="20" id="soso" /> search </td></tr></table><div class="main" style="margin-top:0px; border-left:#CCCCCC 1px solid; border-top:#CCCCCC 1px solid;"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <th class="tb1">Network</th> <th class="tb1">Date</th> <th class="tb1">Pub_id</th> <th class="tb1">Info</th> </tr> <?php$conn = new Mongo("mongodb://localhost:27017");//blog$db = $conn->report;//users)$collection = $db->pub_report; //$where = array( '_id' => $this->_id);$pageSize = 2;$page = isset($_GET['page'])?intval($_GET['page']):1;$skip = ($page-1)*$pageSize;$skip = $skip<0?0:$skip;//$obj = $collection->find()->sort(array('vote'=>-1))->skip($skip)->limit($pageSize);$networkList = $collection->find()->sort(array('weight'=>-1))->skip($skip)->limit($pageSize);foreach ($networkList as $key) { ?> <tr> <td class="tb2"><?php echo $key["network_id"]; ?></td> <td class="tb2"><?php echo $key["date"]; ?></td> <td class="tb2"><?php echo $key["pub_id"]; ?></td> <td class="tb2"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr > <th class="tb3">Short Url</th> <th class="tb3">Long Url</th> <th class="tb3">Visit</th> <th class="tb4">Earn</th> </tr> <?php foreach ($key['info'] as $value['msb']) { ?> <?php foreach ($value as $val) { ?> <tr> <td class="tb5"><?php echo $val["short_url"]; ?></td> <td class="tb5"><?php echo $val["longurl"]; ?></td> <td class="tb5"><?php echo number_format($val["visit"],0,'. ',', '); ?></td> <td class="tb6">$<?php echo number_format($val["earn"],3,'. ',', '); ?></td> </tr><?php }} ?> </table> </td> </tr><?php } ?></table></div><p><?php echo $page; ?></p></div></body> ppframe问题 php版本越新越好吗? 何如调用文件夹内图片 【求一套VPN 用户管理系统】 关于分页刷新后返回首页的问题~ 请问有没有免费开源的类似香港雅虎拍卖(台湾雅虎奇摩拍卖)的程序? dedecms做的网站,现在被恶意刷流量,不知道有没有程序能够实现阻止恶意刷流量呢 请问在ecshop中,后台控制前台首页模块自由布局的原理是什么? 求ECSHOP仿京东源码,有装机大师无错版100分 IIS7.5无后缀URL 如何实现伪静态没.html也可以访问 dedecms 自定义搜索 不能使用autoindex 关于CORESEEK增量索引的问题!
* 得到指定区间的n条信息
*
* 默认以时间升序排序
*
*/
function page( $page = 1 , $page_size = 2 , $sort = array( 'time' => -1 )){
查询条件
$where = array( 'email' => $this->email );
$cursor = $this->db_obj_user_complaint->collection->find( $where );
//需要跳过的记录数
$skip = ($page-1) * $page_size;
$skip = $skip<0 ? 0 : $skip ; //每页显示page_size条记录
return $cursor->sort( $sort )->skip( $skip )->limit( $page_size );
}
<style type="text/css">
.tb1{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid; background:#FFCC00;}
.tb2{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid;}
.tb3{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid; color:#FF0000;}
.tb4{border-bottom:#CCCCCC 1px solid; color:#FF0000;}
.tb5{border-bottom:#CCCCCC 1px solid; border-right:#CCCCCC 1px solid; }
.tb6{border-bottom:#CCCCCC 1px solid;}
</style><?php
$this->pageTitle=Yii::app()->name . ' - index';
$this->breadcrumbs=array(
'index',
);
?>
<body>
<div style=" background-color:#FFFFFF; padding:10px 10px;">
<table>
<tr>
<td>
<select name="color" onchange = "showandhide(this.value)">
<option value="3">Please select categories</option>
<option value="1" >publisher</option>
<option value="2">network</option>
</select>
</td>
<td>date:
<?php
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>'publishDate',
// additional javascript options for the date picker plugin
'options'=>array(
'showAnim'=>'fold',
),
'htmlOptions'=>array(
'style'=>'height:20px;'
),
));
?></td>
<td>
<input name="soso" type="text" size="20" maxlength="20" id="soso" /> search
</td>
</tr>
</table>
<div class="main" style="margin-top:0px; border-left:#CCCCCC 1px solid; border-top:#CCCCCC 1px solid;">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th class="tb1">Network</th>
<th class="tb1">Date</th>
<th class="tb1">Pub_id</th>
<th class="tb1">Info</th>
</tr>
<?php
$conn = new Mongo("mongodb://localhost:27017");
//blog
$db = $conn->report;
//users)
$collection = $db->pub_report;
//$where = array( '_id' => $this->_id);
$pageSize = 2;
$page = isset($_GET['page'])?intval($_GET['page']):1;$skip = ($page-1)*$pageSize;
$skip = $skip<0?0:$skip;
//$obj = $collection->find()->sort(array('vote'=>-1))->skip($skip)->limit($pageSize);
$networkList = $collection->find()->sort(array('weight'=>-1))->skip($skip)->limit($pageSize);
foreach ($networkList as $key) {
?>
<tr>
<td class="tb2"><?php echo $key["network_id"]; ?></td>
<td class="tb2"><?php echo $key["date"]; ?></td>
<td class="tb2"><?php echo $key["pub_id"]; ?></td>
<td class="tb2">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr >
<th class="tb3">Short Url</th>
<th class="tb3">Long Url</th>
<th class="tb3">Visit</th>
<th class="tb4">Earn</th>
</tr>
<?php foreach ($key['info'] as $value['msb']) { ?>
<?php foreach ($value as $val) { ?>
<tr>
<td class="tb5"><?php echo $val["short_url"]; ?></td>
<td class="tb5"><?php echo $val["longurl"]; ?></td>
<td class="tb5"><?php echo number_format($val["visit"],0,'. ',', '); ?></td>
<td class="tb6">$<?php echo number_format($val["earn"],3,'. ',', '); ?></td>
</tr><?php
}
}
?>
</table>
</td>
</tr>
<?php
}
?>
</table>
</div>
<p><?php echo $page; ?></p>
</div>
</body>