生成delete BulkWrite对象
@access public
@param Query     $query 查询对象
@return BulkWrite
181544
public function delete(Query $query)
    {
        $options = $query->getOptions();
        $where   = $this->parseWhere($query, $options['where']);

        $bulk = new BulkWrite;

        if (1 == $options['limit']) {
            $deleteOptions = ['limit' => 1];
        } else {
            $deleteOptions = ['limit' => 0];
        }

        $bulk->delete($where, $deleteOptions);

        $this->log('remove', $where, $deleteOptions);

        return $bulk;
    }
538607
public function prepareExecuteAndFetchAll(Query $query)
    {
        $prepare = $this->prepareQuery($query);
        $execute = $this->executePrepared($prepare);

        return $this->fetchAllPrepared($prepare);
    }
219691
public function batchActionDelete(ProxyQueryInterface $query)
    {
        if (false === $this->admin->checkAccess('batchDelete')) {
            throw new AccessDeniedException();
        }

        try {
            $this->doBatchDelete($query);

            $this->addFlash('sonata_flash_success', 'flash_batch_delete_success');
        } catch (ModelManagerException $e) {
            $this->addFlash('sonata_flash_error', 'flash_batch_delete_error');
        }

        return new RedirectResponse($this->admin->generateUrl(
            'list',
            ['filter' => $this->admin->getFilterParameters()]
        ));
    }
67671
public function value(Query $query, $field, $default = null)
    {
        $options = $query->getOptions();
        $result  = null;
        if ($this->cache && !empty($options['cache'])) {
            // 判断查询缓存
            $cache  = $options['cache'];
            $key    = is_string($cache['key']) ? $cache['key'] : md5($field . serialize($options));
            $result = $this->cache->get($key);
        }

        if (!$result) {
            if (isset($options['field'])) {
                $query->removeOption('field');
            }

            $query->setOption('field', $field);
            $query->setOption('limit', 1);

            $mongoQuery = $this->builder->select($query);

            // 执行查询操作
            $readPreference = isset($options['readPreference']) ? $options['readPreference'] : null;
            $cursor         = $this->query($options['table'], $mongoQuery, $readPreference, true, ['root' => 'array']);
            $resultSet      = $cursor->toArray();
            if (!empty($resultSet)) {
                $data = (array) array_shift($resultSet);
                if ($this->getConfig('pk_convert_id')) {
                    // 转换ObjectID 字段
                    $data['id'] = $data['_id']->__toString();
                }
                $result = $data[$field];
            } else {
                $result = null;
            }

            if (isset($cache)) {
                // 缓存数据
                $this->cacheData($key, $result, $cache);
            }
        }

        return !is_null($result) ? $result : $default;
    }
1338232
public function count(Query $query)
    {
        $options = $query->getOptions();

        $cmd['count'] = $options['table'];
        $cmd['query'] = $this->parseWhere($query, $options['where']);

        foreach (['hint', 'limit', 'maxTimeMS', 'skip'] as $option) {
            if (isset($options[$option])) {
                $cmd[$option] = $options[$option];
            }
        }

        $command = new Command($cmd);
        $this->log('cmd', 'count', $cmd);

        return $command;
    }
1340642
protected function addOnlyTrashed(Query $query)
    {
        $query->macro('onlyTrashed', function (Query $query) {
            $this->remove($query);

            $query->getQuery()->whereNotNull($query->getMapper()->getEntityMap()->getQualifiedDeletedAtColumn());

            return $query;
        });
    }
600481
private function _doExecute(Query $query)
    {
        $collection = $this->documentManager->getCollection($this->documentClass);

        if ($this->isScroll()) {
            $scroll = $collection->scroll($query);

            foreach ($scroll as $resultSet) {
                yield $resultSet;
            }
        } else {
            yield $collection->search($query);
        }
    }
514426
public function buildDropTable(Query $query) {
        return $this->renderStatement(Query::DROP_TABLE, [
            'table' => $this->formatTable($query->getTable())
        ] + $this->formatAttributes($query->getAttributes()));
    }
724631
public function compile_delete( &$query )
	{
		$build = 'delete from '.$this->escape_table( $query );

		$build .= $this->compile_where( $query );
		$build .= $this->compile_limit( $query );

		// cut the last comma away
		return $build;
	}
737314
protected function cloneQuery(Query $query)
    {
        $aclAppliedQuery = clone $query;
        $params = $query->getParameters();
        /* @var $param Parameter */
        foreach ($params as $param) {
            $aclAppliedQuery->setParameter($param->getName(), $param->getValue(), $param->getType());
        }

        return $aclAppliedQuery;
    }
460876
public function filter(Query $query)
    {
        if (!empty($this->filterOptions['conditions'])) {
            $query->where($this->filterOptions['conditions']);
        }
        if (!empty($this->filterOptions['order'])) {
            $query->order($this->filterOptions['order']);
        }

        return $query;
    }
464693
private function _doExecuteCached(Query $query)
    {
        if (null !== $resultCache = $this->documentManager->getResultCache()) {
            $item = $resultCache->getItem($this->cacheProfile->getCacheKey());

            if ($item->isHit()) {
                yield from $item->get();

                return;
            }
        }

        $resultSets = iterator_to_array($this->_doExecute($query));

        if (isset($item)) {
            $item->set($resultSets);
            $item->expiresAfter($this->cacheProfile->getTtl());
            $resultCache->save($item);
        }

        yield from $resultSets;
    }
112314
public function buildTruncate(Query $query) {
        return $this->renderStatement(Query::TRUNCATE, [
            'table' => $this->formatTable($query->getTable())
        ] + $this->formatAttributes($query->getAttributes()));
    }
148481
public function modifyQuery(Query $query)
    {
        return $this->queryBuilder->startFrom($query)->useDebug(true)->getQuery();
    }
658346
function queryChunkedData($query, $limit = 1000, $resultType = MYSQLI_ASSOC)
  {
    return new MySQLiChunkedResult($this, $query, $limit, $resultType);
  }
23785
public function apply(Query $query) : Query
    {
        return $query->where(
            (new QueryExpression())->gt(
                $this->field,
                $this->value,
                $query->getTypeMap()->type($this->field)
            )
        );
    }
245306
public function delete($query)
	{
		$deleteQuery = $this->parseQuery($query);

		if (!empty($deleteQuery))
		{
			try
			{
				$update = $this->connection->createUpdate();
				$update->addDeleteQuery($deleteQuery);
				$update->addCommit();
				$response = $this->connection->update($update);
				return null;
			}
			catch (\Solarium\Exception\HttpException $e)
			{
				$body = json_decode($e->getBody());
				$message = isset($body->error->msg) ? $body->error->msg : $e->getStatusMessage();
				return $message;
			}
		}
		else
		{
			return false;
		}
	}