Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Entities are specialized objects that represent rows of data stored in OWA's database tables.
Entitiy objects exist to provide developers with an interface to create, retrieve, update, and delete data from the database.
Entity objects aslo play a role in defining , creating and altering the tables that they store data in.
Table of Contents
Entities live under the entities folder within the module that they are a part of.
To work with an entity, use the core API's entityFactory method to create a new entity object of the type you want using the module.name notation..
$entity = owa_core API::entityFactory('module.name');
Once you have created the entity object you can call is various methods to manipulate it.
One of the most frequent entity operations is to retrieve an entities data from the database.
Once you have created the type of entity you want to work with, simply call its load function to populate the entity with data from the database.
The load method assumes that you are passing it the id of the entity to load:
Once you have loaded an entiy you can access its properties by calling the get method.
Entity properties correspond to the name of the columns in the database table that the entity stores its data into. Simply pass the get method the name of the property you want to retrieve:
$value = $entity->get('name');
Alternately you can change an entity's property by setting a new using the set method:
Once an entity's properties are set it can be persisted to the database using eitehr the create or update methods.