Meta
From RedBean
Contents |
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.
Fetching Meta Data
To get a meta property value:
$value = $bean->getMeta("my.property", $defaultIfNotExists);
The default default value is NULL.
Changing or Adding Meta Data
To set a meta property simply use a dot separated notation; preceding nodes do not have to exist; the system will create them automatically.
$bean->setMeta("type", "newtable"); //changes the table
To make Redbean add a unique index for several columns:
$bean->setMeta("buildcommand.unique.0",
array( "column1", "column2", "column3") );
Explicit casting
Example:
$page->setMeta("cast.numasstring","string");
$page->numasstring = $numAsString;

