MongoDB限制(1)它返回结果数组为空

时间:2015-03-09 03:23:35

标签: php mongodb codeigniter limit

我使用带有codeigniter的库php mongodb当我使用limit(1)它返回结果数组为空时但是当我使用limit(2)limit(n)时返回结果对我来说是正确的我不知道为什么?

以下是我要使用的代码:

> $resutl = $this->mongo_db->limit(1)->get('UserProfile');

信息库:

/**  
* CodeIgniter MongoDB Active Record Library  
*  
* A library to interface with the NoSQL database MongoDB. For more information see mongodb.org  
*  
* @package      CodeIgniter  
* @author       Alex Bilbie   
* @copyright    Copyright (c) 2010, Alex Bilbie.  
* @license      http://www.opensource.org/licenses/mit-license.php  
* @link         http://alexbilbie.com  
* @version      Version 0.5.2  
*  
* Thanks to Kyle Dye (kyledye.com), Nick Jackson (nickjackson.me), Mikhail Kozlov (mikhailkozlov.com) and Phil Sturgeon (philsturgeon.co.uk) for additional help  
*/

1 个答案:

答案 0 :(得分:0)

我不知道它是否适合你,你会对它有所了解。

$links = $this->mongo_db
        ->where(array(
            'status' => 1,
            'siteid' => 1
        ))->where_lt('publishedtime', $start)->order_by(array('publishedtime'=>'desc'))
        ->limit(10)->get('links');

OR

$query = $this->CI->cimongo->limit(1)->get_where($table, array($field => $str));