MgdSchema metadata object
MgdSchema types in PHP Documentation
Minimum version: Midgard 1.8
midgard_metadata is internal class registered in midgard-core and also registered as internal php class in midgard-php extension. It is registered as member of every class available during runtime and defined in Mgdschema file. MgdSchema object's property which is a pointer to midgard_metadata object is called metadata.
midgard_metadata class members
creator read-only
holds string value with guid of a person who created object.
This property can not be set from application level. It's internally overwritten , even if it is set by user.
created read-only
holds ISO 8601 formatted date string value.
This property value is set only once when object is created, and can not be overwritten by client application.
revisor read-only
holds string value with guid of a person who updated object.
This property can not be set from application level. It's internally overwritten , even if it is set by user. When object's record is created a value of this property is equal to creator property. When update method is invoked then value of property is equal to the guid of person who updates object.
revised read-only
holds ISO 8601 formatted date string value.
This property value is set every time when object is updated.
It's internally overwritten , even if it is set by user. When object's create method is called value of this property is equal to created property value.
revision read-only
holds integer value.
This property value is set and increased every time when object is updated.
It's internally overwritten , even if it is set by user.
Default value of this property is 0 when object is created, and is increased by 1 with every update method call.
locker holds string value with guid of a person who updated object. This property can be set from application level. A caller is responsible to set value with correct guid.
locked holds ISO 8601 formatted date string value. This property can be set from application level. A caller is responsible to set value with correctly formatted date.
approver holds string value with guid of a person who updated object. This property can be set from application level. A caller is responsible to set value with correct guid.
approved holds ISO 8601 formatted date string value. This property can be set from application level. A caller is responsible to set value with correctly formatted date.
authors
holds longtext value.
You should pay special attention while setting this property.
There is no clear convention about how this property should be set.
owner
holds string value with guid of a person who updated object.
This property can be set from application level.
A caller is responsible to set value with correct guid.
schedulestart holds ISO 8601 formatted date string value. This property can be set from application level. A caller is responsible to set value with correctly formatted date.
scheduleend
holds ISO 8601 formatted date string value.
This property can be set from application level.
A caller is responsible to set value with correctly formatted date.
hidden
holds boolean value.
This property can be set from application level.
navnoentry
holds boolean value.
This property can be set from application level.
size read-only
holds integer value.
Value of this property is total storage usage size of an object ( in bytes ).
Additional bytes needed by database server storage are also added to size value. When object is midgard_attachment type , size of file is added to size.
score holds integer value. Score is an editable integer that can be for example used for sorting Query Builder results.
published
holds ISO 8601 formatted date string value.
This property can be set from application level.
When object's create method is called value of this property is by default set to created ones value.
A caller is responsible to set value with correctly formatted date.
deleted read-only
holds boolean value.
This property is set internally by midgard-core.
In every case is set to FALSE, except retrieving deleted objects.
exported read-only
holds ISO 8601 formatted date string value.
This property is set internally by export method. Its value is a datetime value when object has been exported from database.
imported read-only
holds ISO 8601 formatted date string value.
This property is set internally by import method. Its value s a datetime value when object has been imported to database.
Datetimes
Every ISO 8601 formatted date is stored in UTC timezone. Timezone qualifier is defined in datetime string, however it may be ignored by some database engines. (MySQL for example ignores timezone qualifier but stores datetime in UTC).
When object's record is retrieved from database , datetime is not converted to local timezone. And datetime string is retrieved "as is".
Client application is responsible to convert datetime to local timezone. Or to convert datetime to any other format if needed. When property value ( with MGD_TYPE_TMESTAMP type) is incorrectly set or converted to ISO 8601 datetime format, then database storage engine converts such value to default unset datetime: 0000-00-00 00:00.
An empty string is set as property value if datetime is not set for property which holds MGD_TYPE_TIMESTAMP value type. Such value is easy accessible with simple 'if' condition:
<?php
if($object->metadata->schedulestart)
{
echo "Published since $object->metadata->schedulestart";
}
?>
Datetimes in MidCOM
The MidCOM DBA system modifies datetime handling so that all metadata datetime properties can be used as Unix timestamps instead of strings.
<?php
// Set the article's publication time to NOW
$article->metadata->published = time();
$article->update();
// Echo article's approval time
$approval = strftime('%x %X', $article->metadata->approved);
echo "Article was approved on {$approval}.";
?>
Read more in Midgard PHP - how to handle datetimes.
Example
<?php
$guid = "f6b665f1984503790ed91f39b11b5392";
$parameter = new midgard_parameter();
if($parameter->get_by_guid($guid))
{
echo "Parameter with $parameter->guid was
created: $parameter->metadata->created";
}
?>
