|
|
@@ -263,6 +263,30 @@ class Mooses_AbstractMongo extends Mooses_Mongodb_Mongo_Document {
|
|
|
return new Mooses_Mongodb_Mongo_Iterator_Cursor($cursor, $config);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @param $_pageLimit
|
|
|
+ * @param $_pageSize
|
|
|
+ * @return int
|
|
|
+ * @throws Mooses_Mongodb_Mongo_Exception
|
|
|
+ */
|
|
|
+ protected static function countResults($query){
|
|
|
+ $inheritance = static::getCollectionInheritance();
|
|
|
+ if (count($inheritance) > 1) {
|
|
|
+ $query['_type'] = $inheritance[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ // If we are selecting specific fields make sure _type is always there
|
|
|
+ if (!empty($fields) && !isset($fields['_type'])) {
|
|
|
+ $fields['_type'] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ return static::getMongoCollection(false)->count($query);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function ___countCollection(){
|
|
|
+ return self::countResults($this->_queryConditions);
|
|
|
+ }
|
|
|
+
|
|
|
protected function ___getCollectionData($_forceArray = true){
|
|
|
if($this->_pageLimit !== false && $this->_page !== false) {
|
|
|
$_result = self::fetchAllWithLimits($this->_queryConditions, $this->_fields, $this->_pageLimit, $this->_page);
|