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

$this
requireIndexes(bool $requireIndexes = true)

Set whether or not to require indexes.

$this
field(string $field)

Set the current field to operate on.

$this
prime(boolean|callable $primer = true)

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

eagerCursor($bool = true)

{@inheritdoc}

$this
hydrate(bool $bool = true)

No description

$this
readOnly(bool $bool = true)

No description

$this
refresh(bool $bool = true)

No description

$this
find(string $documentName = null)

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

$this
findAndUpdate(string $documentName = null)

No description

$this
returnNew(bool $bool = true)

No description

$this
findAndRemove(string $documentName = null)

No description

$this
update(string $documentName = null)

No description

$this
insert(string $documentName = null)

No description

$this
remove(string $documentName = null)

No description

$this
references(object $document)

No description

$this
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

$this requireIndexes(bool $requireIndexes = true)

Set whether or not to require indexes.

Parameters

bool $requireIndexes

Return Value

$this

$this field(string $field)

Set the current field to operate on.

Parameters

string $field

Return Value

$this

$this 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

$this

Exceptions

InvalidArgumentException If $primer is not boolean or callable

eagerCursor($bool = true)

{@inheritdoc}

Parameters

$bool

$this hydrate(bool $bool = true)

Parameters

bool $bool

Return Value

$this

$this readOnly(bool $bool = true)

Parameters

bool $bool

Return Value

$this

$this refresh(bool $bool = true)

Parameters

bool $bool

Return Value

$this

$this find(string $documentName = null)

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

Parameters

string $documentName

Return Value

$this

$this findAndUpdate(string $documentName = null)

Parameters

string $documentName

Return Value

$this

$this returnNew(bool $bool = true)

Parameters

bool $bool

Return Value

$this

$this findAndRemove(string $documentName = null)

Parameters

string $documentName

Return Value

$this

$this update(string $documentName = null)

Parameters

string $documentName

Return Value

$this

$this insert(string $documentName = null)

Parameters

string $documentName

Return Value

$this

$this remove(string $documentName = null)

Parameters

string $documentName

Return Value

$this

$this references(object $document)

Parameters

object $document

Return Value

$this

$this includesReferenceTo(object $document)

Parameters

object $document

Return Value

$this

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