RedBeanPHP
The Power ORM

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:

    require 'rb.php';
    
R::setup();
    
R::freezeTRUE );
    ...
your code...

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

Donate to RedBeanPHP using Monero:
47mmY3AVbRu 7zVVd4bxQnzD
2jR7PQtBJ cF93jWHQ
rP7yRED4qr fqu6G9Q8ZNu7
zqwnB28rz76 w7MaExf
mALVg69yFd 9sUmz
(remove spaces and new lines)

Performance monitor: this page has been generated in 0.031360149383545s. Is the performance lacking? Please drop me an e-mail to notify me!

Partners  
Uurboek.nl PapelDigital

 

RedBeanPHP Easy ORM for PHP © 2024 () and the RedBeanPHP community () - Licensed New BSD/GPLv2 - RedBeanPHP Archives
RedBeanPHP, the power ORM for PHP since 2009.

Privacy Statement