Fluid and Frozen
RedBeanPHP has two modes, fluid and frozen.
As you have seen in the previous chapters, RedBeanPHP will keep changing the schema to fit your needs, this is what we call 'fluid mode'.
While this is great for development you don't want this to happen on your production server. That's why you need to freeze the schema before you deploy your application. To freeze your app, put R::freeze( TRUE ) at the beginning of your script, like this:
R::freeze( TRUE );
After freezing the schema, open your database client and inspect the schema RedBeanPHP has created for you. You can now refine it where necessary, i.e. add some indexes, change some columns, add or change constraints and more.
Always review the schema generated by RedBeanPHP and allow yourself some
time to refine it.
Do not change the table or column names though, these are part of the RedBeanPHP conventions. Instead I recommend to inspect and refine column types ( maybe a bit too wide ? ), indexes and foreign key constraint settings.
Partial freezing (Chill mode)
It's also possible to only lock the schemas of several types of beans, for instance to lock the schemas of bean types 'book', 'page' and 'book_page' use:
R::freeze( ['book','page','book_page'] );
This makes RedBeanPHP operate in fluid mode, but those tables will not get modified. To reset, pass an empty array.
Learn how to use the debugging tools.
Hybrid Mode (5.4+)
R::store() and R::storeAll() both take a second parameter: $unfreezeIfNeeded. If set to TRUE in frozen mode, RedBeanPHP will automatically temporarily switch to fluid mode to attempt to store the bean in case of an SQLException.
back to main menu
Performance monitor: this page has been generated in 0.026297092437744s. Is the performance lacking? Please drop me an e-mail to notify me!