- Getting started
- Basics
- Create a Bean
- Loading a Bean
- Deleting a Bean
- Freeze
- Finding
- Relation Mapping
- Models
- Database
- BeanCan
- Advanced
- Architecture
- Other
Loading a Bean
To load a bean from the database use the load() function and pass both the type of the bean and the id:
$book = R::load('book', $id);
If the bean cannot be loaded a new empty bean will be dispensed with id 0. To check whether a bean has been loaded correctly you can verify the id using:
if (!$bean->id) { ...help bean not found!!.. }
You can access bean properties like this:
echo $book->title;
To load a batch of beans at once:
$books = R::batch('book',array($id1,$id2));
To count beans:
R::count('page'); //counts all pages
If the bean cannot be loaded a new empty bean will be dispensed.
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 Disquspage generated in 0.011666059494019 sec.