Get paginator

@param   mixed|null  $where
@param   mixed|null  $order
@param   mixed|null  $columns
@param   mixed|null  $joins
@param   mixed|null  $quantifier
@return  \Zend\Paginator\Paginator
550836
public function getPaginator( $where        = null,
                                  $order        = null,
                                  $columns      = null,
                                  $joins        = null,
                                  $quantifier   = null )
    {
        $joins = array_merge( (array) $joins, array(
            'subdomain' => array(
                'where'     => static::$tableName . '.subdomainId = subdomain.id',
                'columns'   => array( 'subdomain' ),
                'type'      => Select::JOIN_LEFT,
            ),
            'paragraph_content' => array(
                'table'     => array( 'paragraph_content' => 'paragraph' ),
                'where'     => static::$tableName . '.contentId = paragraph_content.id',
                'columns'   => array( 'contentName' => 'name' ),
                'type'      => Select::JOIN_LEFT,
            ),
        ) );

        return parent::getPaginator( $where, $order, $columns, $joins, $quantifier );
    }
202930
public function paginate($perPage = null, $columns = array('*'))
	{
		$perPage = $perPage ?: $this->model->getPerPage();

		$paginator = $this->query->getConnection()->getPaginator();

		if (isset($this->query->groups))
		{
			return $this->groupedPaginate($paginator, $perPage, $columns);
		}
		else
		{
			return $this->ungroupedPaginate($paginator, $perPage, $columns);
		}
	}
729452
public function findWhere($where, $columns = ['*'], $with = [])
    {
        $where    = $this->castRequest($where);
        $cacheKey = $this->generateKey([$where, $columns, $with]);

        return $this->cacheResults(get_called_class(), __FUNCTION__, $cacheKey, function () use ($where, $columns, $with) {
            $model = $this->model instanceof Model ? $this->model->query() : $this->model;

            foreach ($where as $attribute => $value) {
                if (is_array($value)) {
                    list($attribute, $condition, $value) = $value;

                    $model->where($attribute, $condition, $value);
                } else {
                    $model->where($attribute, '=', $value);
                }
            }

            return $model->with($with)
                ->get($columns);
        });
    }
1307992
public function getByPage(
        int $page = 1,
        int $limit = 10,
        array $where = [],
        array $with = [],
        string $orderBy = null,
        string $order = 'desc'
    ) {
        $query = $this->make($with);

        $query = $this->applyWhere($query, $where);

        if ($orderBy) {
            $query = $query->orderBy($orderBy, $order);
        }

        return $query->skip($limit * ($page - 1))
            ->take($limit)
            ->get();
    }
930221
public function fetchCount($where = null)
    {
        $select = $this->sql->select();

        if ($where instanceof \Closure) {
            $where($select);
        } elseif ($where !== null) {
            $select->where($where);
        }

        $select->columns(array('Gzfextra_Db_Count' => new Expression('count(1)')));
        $result = $this->sql->prepareStatementForSqlObject($select)->execute()->current();
        return $result['Gzfextra_Db_Count'];
    }
551352
public function getAllSortByQuery($sort, $order = 'DESC')
    {
        $qb = $this->createQueryBuilder('p');
        $qb2 = $this->getEntityManager()->getRepository(PageSnapshot::class)->createQueryBuilder('pp');
        $qb->select('p', 'ps')
            ->leftJoin('p.snapshots', 'ps')
            ->where($qb->expr()->eq(
                'ps.id',
                '('.$qb2->select('MAX(pp.id)')
                    ->where('p.id = pp.page')
                    ->getDQL().')'
            ))
            ->orWhere('ps.id IS NULL')
            ->orderBy('p.'.$sort,  $order);

        return $qb->getQuery();
    }
1310037
static function doSelectIterator(Query $q = null) {
		$q = $q ? clone $q : static::getQuery();

		if (!$q->getTable()) {
			$q->setTable(static::getTableName());
		}

		return new QueryModelIterator($q, get_called_class());
	}
1331291
public function find($where = null, $orderby = null, $onpage = null, $page = null)
  {
    $this->items = null;

    $q = $this->getManager()
      ->getQueryBuilder()
      ->select($this->getTable())
      ->where($where)
      ->orderby($orderby)
      ->page($page, $onpage);

    return $this->fetch($q);
  }
537354
public function get(array $where) {
        $options = [
            Db::OPTION_FETCH_MODE => $this->getFetchArgs(),
            'rowCallback' => [$this, 'unserialize']
        ];

        $qry = new TableQuery($this->name, $where, $this->db, $options);
        $qry->setLimit($this->getDefaultLimit())
            ->setOrder(...$this->getDefaultOrder());

        return $qry;
    }
1073352
public function findByCategory(Category $category, $order, $orderBy, $page, $limit): Paginator
    {
        $qb = $this->createQueryBuilder('page')
            ->where('page.category = :category')
            ->andWhere('page.enabled = :enabled')
            ->orderBy('page.'.$orderBy, $order)
            ->setMaxResults($limit)
            ->setFirstResult($limit * ($page-1))
            ->setParameter('category', $category)
            ->setParameter('enabled', true)
        ;

        return new Paginator($qb->getQuery()->useResultCache($this->cacheEnabled, $this->cacheTtl));
    }
615495
public function findWhere(array $wheres, array $columns = ['*'])
    {
        return $this->mediator->transform($this->mediator(func_get_args()))->first();
    }
150539
public function row($fields = null, $where = null, $orderBy = null)
    {
        // 按整个SELECT进行查询
        $table = self::selectArray($fields, $where, $orderBy, "1");

        // 如果有,返回第一行
        if ($table) {
            return $table[0];
        }

        return null;
    }
1032260
public function count($where = null)
  {
    $m = $this->getManager();

    $q = $m->getQueryBuilder()
      ->select($this->getTable())
      ->columns('COUNT(*) as total')
      ->where($where);

    return $m->query($q)->fetchColumn();
  }
898737
public function whereStruct(IBaseWhere $where, string $logicalOperator = LogicalOperator::AND)
    {
        $this->option->where[] = $where;
        return $this;
    }
886198
public function pagination($page, $limit, $query = null, $orderBy = null, $sort = 'ASC', $filter = null)
    {
        $entityClassAlias = $this->getEntityClassAlias();

        // Create a Doctrine Collection
        $queryBuilder = $this->getObjectManager()->createQueryBuilder();
        $queryBuilder->select($entityClassAlias)
                     ->from($this->getEntityClass(), $entityClassAlias);

        $paramCounter = 0;

        if (is_array($filter)) {
            $paramCounter = $this->addFilterToQueryBuilder($filter, $queryBuilder);
        }

        //Add joins to query builder
        $this->addJoinTablesToQueryBuilder($queryBuilder);

        if (null !== $query) {
            $properties    = $this->getQueryableProperties();
            $orExpressions = array();
            $paramCounter++;

            foreach ($properties as $property) {
                $orExpressions[] = $queryBuilder->expr()->like($property, '?' . $paramCounter);
            }

            $queryBuilder->andWhere(
                call_user_func_array(array($queryBuilder->expr(), "orX"), $orExpressions)
            );

            $queryBuilder->setParameter($paramCounter, $query);
        }

        if ($orderBy) {
            $orderByIdentifier = $this->getOrderByIdentifier($orderBy);

            if (!$sort) {
                $sort = 'ASC';
            }
            $queryBuilder->orderBy($orderByIdentifier, $sort);
        }

        // Create the paginator itself
        $paginator = new Paginator(
            new DoctrinePaginator(new ORMPaginator($queryBuilder))
        );

        $paginator->setCurrentPageNumber($page)
                  ->setItemCountPerPage($limit)
                  ->setPageRange(5);

        return $paginator;
    }
1361486
public function getPaginated($paged = 15, $orderBy = 'created_at', $sort = 'desc')
    {
        $query = function () use ($paged, $orderBy, $sort) {

            return $this->model
                ->with($this->requiredRelationships)
                ->orderBy($orderBy, $sort)
                ->paginate($paged);
        };

        return $this->doQuery($query);
    }
1200209
public function getIn(
        $whereInKey,
        array $whereIn = [],
        array $with = [],
        string $orderBy = null,
        string $order = 'desc',
        int $limit = 0
    ) {
        $query = $this->make($with);

        $query = $query->whereIn($whereInKey, $whereIn);

        if ($orderBy) {
            $query = $query->orderBy($orderBy, $order);
        }

        if ($limit) {
            $query = $query->take($limit);
        }

        return $query->get();
    }