RedBeanPHP

easy ORM for PHP

Cooker 1.3

The Cooker 1.3 is a Cooker version from RedBeanPHP 1.3. While this cooker originally belonged to 1.3 it can still be used for compatibility reasons with that version. For new projects I recommend to use the graph() function because it is way easier.


<input type="hidden" name="mybean[type]" value="user" />

This will dispense a new bean of type user.

To get the beans from the POST request, do:


$beans 
R::cooker$_POST );

This will return an array:


array( "can"=> array( "mybean"=>$userBean ), "pairs"=>array() )

Since 2.0 the Cooker will also return an array with all the beans sorted by type:


 $array
['sorted'][ beantype ];

The 'can' contains the beans distilled from the form, the pairs array is used for associations in forms.


<input type="hidden" name="mybean[type]" value="user" />
<
input type="text" name="mybean[name]" value="" />

Now if someone fills in this form and submits the data, you will get a bean of type user with a property 'name' set with the data filled in by the client.

As you see, this system can be used to turn forms directly into beans.

To make the client modify existing beans:


<input type="hidden" name="mybean[id]" value="2" />
<
input type="hidden" name="mybean[type]" value="user" />
<
input type="text" name="mybean[name]" value="" />

To form an association


<select name="associations[mybean][]">
   <
option value="usergroup-mybean" option 1 </option>
</
select>

If one selects 'option 1' and submits, the bean usergroup will be associated with mybean, note that you need to define usergroup like you did with mybean. If you dont want that (just load another bean on the fly):


<select name="associations[mybean][]">
   <
option value="usergroup:2-mybean" option 1 </option>
</
select>

Associates usergroup bean with ID 2 with mybean.



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

page generated in 0.0059099197387695 sec.