- Getting started
- Basics
- Finding
- Relation Mapping
- Models
- Database
- BeanCan
- Advanced
- Architecture
- Other
Meta Data
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:
$bean->setMeta('foo', 'bar');
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:
$bean->getMeta('type');
Since 3.0: Meta data can be used for explicit casts. For instance if you want to store something as a POINT datatype:
$bean->setMeta('cast.myproperty','point');
Unique
Usage of build command unique meta property:
$bean->setMeta("buildcommand.unique" , array(array($property1, $property2)));
Public Meta properties
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!
| Property | Function |
|---|---|
| type | (string) Determines the type of the bean, don't change! |
| tainted | (boolean) Whether the bean has been modified. |
| buildcommand.unique | issues an extra option for query writer, use with care |
| cast.* | Used for explicit casting, for internal use only |
Private Meta properties
Here is an overview of all system meta properties. These meta properties should not be relied on, they are only for RedBeanPHP internal subsystems.
| Property | Function |
|---|---|
| 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! |
Tainted
Sometimes its useful to know whether a bean has been modified or not. The current state of the bean is stored in a Meta property called tainted. To get the state of the bean use:
$bean->getMeta('tainted');
If the bean has been modified this will return boolean TRUE, otherwise it will return FALSE.
Tweet
User contributed notes. Please use the comment section to provide tips, notes and examples. To ask for support or to provide feedback use the forum. For bug reports use Github Issue Tracker.
Site comments powered by Disqus