for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @link https://github.com/chrmorandi/yii2-ldap for the source repository
* @package yii2-ldap
* @author Christopher Mota <[email protected]>
* @license MIT License - view the LICENSE file that was distributed with this source code.
* @since 1.0.0
*/
namespace chrmorandi\ldap;
use yii\base\InvalidConfigException;
use yii\db\QueryInterface;
* ActiveDataProvider implements a data provider based on [[\yii\db\Query]] and [[\yii\db\ActiveQuery]].
*
* ActiveDataProvider provides data by performing DB queries using [[query]].
* The following is an example of using ActiveDataProvider to provide ActiveRecord instances:
* ```php
* $provider = new ActiveDataProvider([
* 'query' => Post::find(),
* 'pagination' => [
* 'pageSize' => 20,
* ],
* ]);
* // get the posts in the current page
* $posts = $provider->getModels();
* ```
* And the following example shows how to use ActiveDataProvider without ActiveRecord:
* $query = new Query();
* 'query' => $query->from('post'),
class ActiveDataProvider extends \yii\data\ActiveDataProvider
{
* @inheritdoc
protected function prepareTotalCount()
if (!$this->query instanceof QueryInterface) {
$this->query
yii\db\QueryInterface
throw new InvalidConfigException('The "query" property must be an instance of a class that implements the QueryInterface e.g. yii\db\Query or its subclasses.');
}
return (int) $this->query->limit($this->getPagination()->getLimit())->offset(-1)->orderBy([])->count('*', $this->db);