class Builder extends Builder (View source)

Query builder for ODM.

Properties

protected string $currentField The current field we are operating on.

Methods

__construct(DocumentManager $dm, string[]|string|null $documentName = null)

Construct a Builder

requireIndexes(bool $requireIndexes = true)

Set whether or not to require indexes.

field(string $field)

Set the current field to operate on.

prime(boolean|callable $primer = true)

Use a primer to eagerly load all references in the current field.

eagerCursor($bool = true)

{@inheritdoc}

hydrate(bool $bool = true)

No description

refresh(bool $bool = true)

No description

find(string $documentName = null)

Change the query type to find and optionally set and change the class being queried.

findAndUpdate(string $documentName = null)

No description

returnNew(bool $bool = true)

No description

findAndRemove(string $documentName = null)

No description

update(string $documentName = null)

No description

insert(string $documentName = null)

No description

remove(string $documentName = null)

No description

references(object $document)

No description

includesReferenceTo(object $document)

No description

getQuery(array $options = array())

Gets the Query executable.

expr()

Create a new Expr instance that can be used as an expression with the Builder

Details

__construct(DocumentManager $dm, string[]|string|null $documentName = null)

Construct a Builder

Parameters

DocumentManager $dm
string[]|string|null $documentName (optional) an array of document names, the document name, or none

Builder requireIndexes(bool $requireIndexes = true)

Set whether or not to require indexes.

Parameters

bool $requireIndexes

Return Value

Builder

Builder field(string $field)

Set the current field to operate on.

Parameters

string $field

Return Value

Builder

Builder prime(boolean|callable $primer = true)

Use a primer to eagerly load all references in the current field.

If $primer is true or a callable is provided, referenced documents for this field will loaded into UnitOfWork immediately after the query is executed. This will avoid multiple queries due to lazy initialization of Proxy objects.

If $primer is false, no priming will take place. That is also the default behavior.

If a custom callable is used, its signature should conform to the default Closure defined in {@link ReferencePrimer::__construct()}.

Parameters

boolean|callable $primer

Return Value

Builder

Exceptions

InvalidArgumentException If $primer is not boolean or callable

eagerCursor($bool = true)

{@inheritdoc}

Parameters

$bool

Builder hydrate(bool $bool = true)

Parameters

bool $bool

Return Value

Builder

Builder refresh(bool $bool = true)

Parameters

bool $bool

Return Value

Builder

Builder find(string $documentName = null)

Change the query type to find and optionally set and change the class being queried.

Parameters

string $documentName

Return Value

Builder

Builder findAndUpdate(string $documentName = null)

Parameters

string $documentName

Return Value

Builder

Builder returnNew(bool $bool = true)

Parameters

bool $bool

Return Value

Builder

Builder findAndRemove(string $documentName = null)

Parameters

string $documentName

Return Value

Builder

Builder update(string $documentName = null)

Parameters

string $documentName

Return Value

Builder

Builder insert(string $documentName = null)

Parameters

string $documentName

Return Value

Builder

Builder remove(string $documentName = null)

Parameters

string $documentName

Return Value

Builder

Builder references(object $document)

Parameters

object $document

Return Value

Builder

Builder includesReferenceTo(object $document)

Parameters

object $document

Return Value

Builder

Query getQuery(array $options = array())

Gets the Query executable.

Parameters

array $options

Return Value

Query $query

Expr expr()

Create a new Expr instance that can be used as an expression with the Builder

Return Value

Expr $expr