本文整理汇总了PHP中yii\data\ActiveDataProvider::getCount方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider::getCount方法的具体用法?PHP ActiveDataProvider::getCount怎么用?PHP ActiveDataProvider::getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\data\ActiveDataProvider
的用法示例。
在下文中一共展示了ActiveDataProvider::getCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: existUser
public function existUser($post)
{
$model = new $this->modelClass();
$query = $model::find()->orFilterWhere(['login' => $post['login']])->orFilterWhere(['email' => $post['email']]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
return $dataProvider->getCount() === 0 ? false : true;
}
示例2: actionList
public function actionList($event_id)
{
\Yii::$app->response->format = Response::FORMAT_JSON;
$dp = new ActiveDataProvider();
$dp->query = Comment::find()->with('user')->where(['event_id' => $event_id])->orderBy(['id' => SORT_DESC]);
$dp->pagination->pageSize = 6;
return ['items' => $dp->getModels(), 'pageCount' => $dp->getPagination()->getPageCount(), 'totalCount' => $dp->getTotalCount(), 'page' => $dp->pagination->page, 'count' => $dp->getCount()];
}
示例3: getUserReferrer
public function getUserReferrer($code)
{
$query = commonUser::find();
$query->where('status != ' . commonUser::STATUS_DELETED);
$query->andwhere('id != ' . Yii::$app->user->id);
$query->andwhere(['referrer' => $code]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false]);
if ($dataProvider->getCount() > 0) {
return ['dataProvider' => $dataProvider, 'code' => $code, 'parent_checked' => 0];
}
return "NULL";
}
示例4: actionSearch
public function actionSearch()
{
if (!empty($_GET)) {
$model = new $this->modelClass();
foreach ($_GET as $key => $value) {
if (!$model->hasAttribute($key)) {
throw new \yii\web\HttpException(404, 'Invalid attribute:' . $key);
}
}
try {
$provider = new ActiveDataProvider(['query' => $model->find()->where($_GET), 'pagination' => false]);
} catch (Exception $ex) {
throw new \yii\web\HttpException(500, 'Internal server error');
}
if ($provider->getCount() <= 0) {
throw new \yii\web\HttpException(404, 'No entries found with this query string');
} else {
return $provider;
}
} else {
throw new \yii\web\HttpException(400, 'There are no query string');
}
}
示例5: actionEventSubscribers
/**
* @param $event_id
* @return array Вывод подписчиков на страницу события
* Вывод подписчиков на страницу события
* @throws \yii\web\NotFoundHttpException
*/
public function actionEventSubscribers($event_id)
{
if (!\Yii::$app->request->isAjax) {
throw new NotFoundHttpException();
}
\Yii::$app->response->format = Response::FORMAT_JSON;
$dp = new ActiveDataProvider();
$dp->query = EventSubscriber::find()->with('user')->where(['event_id' => $event_id])->orderBy(['id' => SORT_DESC]);
$dp->pagination->pageSize = 12;
return ['items' => $dp->getModels(), 'pageCount' => $dp->getPagination()->getPageCount(), 'totalCount' => $dp->getTotalCount(), 'page' => $dp->pagination->page, 'count' => $dp->getCount()];
}
示例6: actionGetUsers
public function actionGetUsers()
{
if (!Yii::$app->user->can("admin")) {
throw new NotFoundHttpException('The requested page does not exist.');
}
$this->layout = "admin";
if (Yii::$app->request->isAjax) {
$code = Yii::$app->request->post('code');
$parent_checked = Yii::$app->request->post('parent_checked');
$query = User::find();
$query->where('status != ' . User::STATUS_DELETED);
$query->andwhere('id != ' . Yii::$app->user->id);
$query->andwhere(['referrer' => $code]);
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => false]);
if ($dataProvider->getCount() > 0) {
return $this->renderAjax("children-user-1", ['dataProvider' => $dataProvider, 'code' => $code, 'parent_checked' => $parent_checked]);
}
}
return "NULL";
}