padams edited this page Jan 28, 2015 · 1 revision

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

Working with Entities

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.

Loading Data

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:


Accessing Entity Properties

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:

$entity->set('name', 'value');

Saving Entity to the Databse

Once an entity's properties are set it can be persisted to the database using eitehr the create or update methods.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.