Avolutions\Orm\Entity
An entity represents a clearly identified object from an entity collection. It provides the methods for manipulating the Entity with CRUD operations.
Properties
Property | Visibility | Type | Description |
---|---|---|---|
$id | public | ?int | The unique identifier of the entity. |
Methods
Method | Visibility | Description |
---|---|---|
__construct() | public | Creates a new Entity object and loads the corresponding EntityConfiguration and EntityMapping. |
delete() | public | Deletes the Entity object from the database. |
exists() | public | Checks if the Entity already exists in the database. |
getEntityName() | public | Returns the shortname of the reflected class. |
getErrors() | public | Returns all validation error messages. |
isValid() | public | Checks if entity was validated successfully last time by checking if errors are set or not. |
save() | public | Saves the Entity object to the database. It will be either updated or inserted, depending on whether the Entity already exists or not. |
validate() | public | Validates the Entity by using the Validators specified in mapping file. If a property is not valid the error message of the Validator will be added to the error array. |
Property Details
Method Details
__construct()
Creates a new Entity object and loads the corresponding EntityConfiguration and EntityMapping.
public
__construct([array<string|int, mixed> $values = [] ]) : mixed
Parameters
array<string|int, mixed>
$values
(optional)
The Entity attributes as an array
delete()
Deletes the Entity object from the database.
public
delete() : mixed
Return values
mixed Deletes the Entity object from the database.exists()
Checks if the Entity already exists in the database.
public
exists() : bool
Return values
bool Checks if the Entity already exists in the database.getEntityName()
Returns the shortname of the reflected class.
public
getEntityName() : string
Return values
string Returns the shortname of the reflected class.getErrors()
Returns all validation error messages.
public
getErrors() : array<string|int, mixed>
Return values
array<string|int, mixed> Returns all validation error messages.isValid()
Checks if entity was validated successfully last time by checking if errors are set or not.
public
isValid() : bool
Return values
bool Checks if entity was validated successfully last time by checking if errors are set or not.save()
Saves the Entity object to the database. It will be either updated or inserted, depending on whether the Entity already exists or not.
public
save() : mixed
Return values
mixed Saves the Entity object to the database. It will be either updated or inserted, depending on whether the Entity already exists or not.validate()
Validates the Entity by using the Validators specified in mapping file. If a property is not valid the error message of the Validator will be added to the error array.
public
validate() : bool