Loading data with KenedoModel::getRecord

You have seen how to make a model using KenedoModel and making a set of MVC files to manage data. So far so good, time to start using that data.

KenedoModel has a method called getRecord that gives you an object with the data you defined in your model.

$model = KenedoModel::getModel('ConfigboxModelAcmeExamples'); $record = $model->getRecord($id, $languageTag);


getRecord gives you a record by it's ID and in the language you specify. The method looks into the defined properties and loads the data in a standardised form.

Parameters

  • $id - The record ID, the property of type 'id' in your model is what you refer to

  • $languageTag (optional) the language you want the record in. Form is 'en-GB', leave empty to get the record in the current user's language.

Return value

You get a stdClass object. Each property in your model adds data to your record, what each adds is up to the property's type. Generally properties add a object var named after the name of the property. Translatables do too (using the right language) and add the various translations as well (language tag as suffix). Image properties add full file path and full URL as additional vars. Multiselects add an array of IDs of what they reference to. You can configure Join properties to add record data from joined models (documentation to follow).

About KenedoModel::getModel($modelClassName)

This static method gives you a singleton object of your model. Feel free to get your model object multiple times in the runtime, no performance hit.