Beans contain meta information; for instance the type of the bean. This information is hidden in a meta information field. You can use simple accessors to get and modify this meta information.
To get a meta property value:
$value = $bean->getMeta('my.property', $defaultIfNotExists);
The default default value is NULL.
To set a meta property:
The type (in 3.0+ this is always the same as the database table) of the bean is stored in meta property 'type' and can be retrieved as follows:
Since 3.0: Meta data can be used for explicit casts. For instance if you want to store something as a POINT datatype:
Here is an overview of all public meta properties used by the system. These meta properties are safe to read and can be used reliably to extract information about beans. Don't change them though!
|type||(string) Determines the type of the bean, don't change!|
|tainted||(boolean) Whether the bean has been modified.|
|cast.*||Used for explicit casting|
Here is an overview of all system meta properties. These meta properties should not be relied on, they are only for RedBeanPHP internal subsystems.
|buildcommand.indexes||issues extra options for query writer, for internal use only|
|buildreport.flags.*||Information about internal processes|
|sys.*||System information, never touch!|
|idfield||Deprecated. Don't touch!|
|buildcommand.unique||issues an extra option for query writer, use with care|
To see whether a bean has been changed:
Note that certain properties, like lists (see chapter lists) also cause a bean to get marked as tainted. In RedBeanPHP version 3.4 there is a shorthand method: isTainted().
In RedBeanPHP 3.4+ you can check whether a certain property has changed and you can retrieve the previous value.
$post->hasChanged('title'); //has title been changed?
$oldTitle = $post->old('title');
RedBeanPHP Easy ORM for PHP © 2013 Gabor de Mooij and the RedBeanPHP community - Licensed New BSD/GPLv2