midgard_reflection_property method get_midgard_type
get_midgard_type is a method for getting property's midgard type using Midgard Reflection Property class.
int $mrp->get_midgard_type(string 'property')
Minimum version: 1.8
The method takes one parameter:
- 'property' is the name of property which is registered as 'classname' member
Usage example
<?php
$mrp = new midgard_reflection_property("midgard_article");
$type = $mrp->get_midgard_type("created");
if($type == MGD_TYPE_TIMESTAMP)
print "Property 'created' is a date \n";
?>
Available midgard types registered as PHP constants
MGD_TYPE_NONE Returned when property is not registered as class member, or derived class' name was passed as reflection's constructor and property name is member of derived class.
MGD_TYPE_STRING String type. Returned when property's type is set as "string" and (or) when no type was specified for peroperty.
MGD_TYPE_INT Integer type. Value range from -2,147,483,648 to 2,147,483,647
MGD_TYPE_UINT Unsigned integer type. Value range from 0 to 4,294,967,295
MGD_TYPE_FLOAT Float ( double ) type.
MGD_TYPE_BOOLEAN Bool type.
MGD_TYPE_TIMESTAMP Datetime type. Returned when property's type is set as 'datetime'.
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:
<?
if($object->metadata->schedulestart)
echo "Published since $object->metadata->schedulestart";
?>
MGD_TYPE_LONGTEXT String type. Returned when property's type is set as 'text' or 'longtext' ( for example $article->content ).
MGD_TYPE_GUID String type. Returned if property's type is set as 'guid'. Value set for property with such type should be >21 and <80 characters long. Reference: GUID and UUID mRFC.
