Beans contain meta data. For instance, the type of the bean is stored in the meta data. To obtain the type of a bean:
You can also store your own meta data in a bean:
$bean->setMeta( 'my.secret.property', 'secret' );
this data will not get stored in the database.
Some meta data is accessible using convenience method. For instance if you would like to know whether a bean has been changed since it got retrieved from the database use the tainted() method.
Note that a bean is marked as tainted if a list gets accessed.
To determine if a certain property has changed:
$book = R::load( 'book', $id );
$book->hasChanged( 'title' ); //returns FALSE
$book->title = 'New title';
$book->hasChanged( 'title' ); //returns TRUE
To get the old value of the property:
$book->old( 'title' );
To test whether two beans have the same type and primary key ID:
$bean->equals( $otherBean );
To determine if a bean is empty, or only contains empty values (everything that qualifies as empty() in PHP) use: