/** * 设定分页器; * @param DataPager $dataPager 分页器 * @param String $relationEntiyName //指定关联对象名称; */ public function setDataPager($dataPager, $relationEntiyName = null) { if ($relationEntiyName) { $cfg = $this->getConfig(); foreach ($cfg['relations'] as $k => $relation) { if ($relation['name'] == $relationEntiyName) { $crit = null; if (isset($cfg['relations'][$k]['criteria'])) { $crit = $cfg['relations'][$k]['criteria']; } else { if ('my\\bq\\criterion\\MongoCriteriaImpl' == get_class($this->criteria)) { $crit = new MongoCriteriaImpl(new $relation['class']()); } else { $crit = new CriteriaImpl(new $relation['class']()); } } $crit->setDataPager($dataPager); //设定分页器 $crit->addProjection(Projections::rowCount('total')); $cfg['relations'][$k]['criteria'] = $crit; break; } } $this->setConfig($cfg); } else { $this->dataPager = $dataPager; } }