IdField

Class. It extends Field.

use Saij\WpAppFramework\Query\Field\IdField;

An ID field of a meta class: an image (#[Image]) or a reference to a post, term or user by ID (?int). No object is stored as 0 or not at all.

Constructor

new IdField(string $class, string $field)
ParameterTypeDefaultDescription
classclass-stringrequiredThe class the field belongs to: a meta class (#[PostMeta]) or row class (#[Table]).
fieldstringrequiredThe name of the constructor parameter.

Methods

equals()

equals(int $id): Condition

Matches posts whose field holds the object with ID $id.

ParameterTypeDefaultDescription
idintrequiredThe ID of the object.

Returns Condition

getClass()

getClass(): string

The class the field belongs to.

Returns class-string

getField()

getField(): string

The name of the field: the name of the constructor parameter.

Returns string

in()

in(int ...$ids): Condition

Matches posts whose field holds one of the objects. Throws an InvalidArgumentException if no value is given.

ParameterTypeDefaultDescription
...idsintThe IDs of the objects.

Returns Condition

isNotNull()

isNotNull(): Condition

Posts with an object in the field.

Returns Condition

isNull()

isNull(): Condition

Posts without an object in the field.

Returns Condition

notIn()

notIn(int ...$ids): Condition

Matches posts whose field holds none of the objects, including posts without an object. Throws an InvalidArgumentException if no value is given.

ParameterTypeDefaultDescription
...idsintThe IDs of the objects.

Returns Condition