This is an outdated version of the Manual. Visit the NEW Manual

Upgrade

RedBeanPHP is a very dynamic project, however we try to keep upgrading as easy as possible without hampering innovation. Here you find upgrade guides for various versions of RedBeanPHP.

Upgrade 3.4 to 3.5

Welcome to the RedBeanPHP ORM upgrade guide for upgrading from version 3.4 to version 3.5. RedBeanPHP 3.5 is a minor release, this means that it's almost backward compatible with previous releases in the 3-series. However even in a minor release there might be minor incompatibilities because the product has to move forward. This chapter describes the minor backward compatibilities and how to deal with them.

Unrelated method removed

The R::unrelated() method has been removed. This method had become quite problematic because the architecture could not be cleanup up because of this method. Also, this method has nothing to do with object relational mapping anyway - it was a feature request during a period in which I was less critical. Well, it's gone now. If you have some code depending on this method you'll have to write a query.

Internal select method removed

The internal select() method in writers has been removed. Nobody should have used this internal method anyway.

Plugin Sync removed

This plugin is still available in other branches and work as expected however I do not consider this core functionality.

Upgrade 3.3 to 3.4

Welcome to the RedBeanPHP ORM upgrade guide for upgrading from version 3.3 to version 3.4. RedBeanPHP 3.4 is a minor release, this means that it's almost backward compatible with previous releases in the 3-series. However even in a minor release there might be minor incompatibilities because the product has to move forward. This chapter describes the minor backward compatibilities and how to deal with them.

No more escaping

RedBeanPHP 3.4 no longer has an $adapter->escape() / $database->Escape() method. RedBeanPHP has always offered parameter binding and parameter binding has always been the preferred way to write queries. The escape methods therefore have been confusing and might lead to SQL injection because people don't know how to use them. Parameter binding is much more safe and this is why I have decided to remove the escape() methods completely. If you have code that relies on the escape() methods please rewrite this code to use parameter binding, it makes your code safer and more consistent. If you insist on using escaping instead of parameter binding you can still use the underlying PDO instance for this: R::$adapter->getDatabase->getPDO()->quote();.

TimeLine and Sync

RedBeanPHP has grown a little fat. Therefore I removed two plugins from the main distribution; namely TimeLine and Sync. Since they are only useful to some people I figured they can just as well remain on github. You can compile them into rb.php yourself using Replica the RedBeanPHP build tool.

Extra Cooker flag

The Cooker (R::graph()) - a tool in RedBeanPHP to quickly turn entire array hierarchies in bean hierarchies and store them in the database will now throw an exception if you want to load a bean (by providing an id). You can turn this off using: RedBean_Plugin_Cooker::enableBeanLoading(true);

Uppercase characters

Formally RedBeanPHP never allowed the use of uppercase chars in properties. However this was always easy to circumvent if you knew how. In RedBeanPHP 3.4 uppercase characters will be used to generate 'beautiful' column names. For instance, a property called 'singleMalt' will result in a column single_malt. The reason why RedBeanPHP never allowed uppercase chars (and still does not allow) is because this tends to cause inter-operating system issues as well as fundamental cross database issues (some OSes and database engines are case sensitive while others are not). However like I said the restriction was easy to circumvent if you studied the API carefully. In RedBeanPHP 3.4 You'll have to turn off the beautifier to use circumvent the restriction using: RedBean_OODBBean::setFlagBeautifulColumnNames(false); Of course, I still recommend not to do this. Instead I hope you enjoy the beautiful underscore-columns, generated by the 'beautifier'.

No more SET(1) in MySQL

From now on RedBeanPHP will use BOOLEAN (TINYINT 1) as the default column for boolean values instead of SET(1). This has been done to make the behaviour across database platforms more consistent. Also SET(1) columns have some issues regarding NULL because they either represent 1 or NULL (or empty) while TINYINT(1) can respresent NULL, TRUE (1) and FALSE (0). Unfortunately none of the database platforms has a good boolean column type (actually Postgres has a real boolean value but it's too strict and required a cast for every comparison). Therefore I feel TINYINT or INTEGERS are the best way to represent booleans given the current state of database platforms.

Upgrade 3.2 to 3.3

Welcome to the RedBeanPHP ORM upgrade guide for upgrading from version 3.2 to version 3.3. This guide describes possible issues when upgrading from release 3.2 to version 3.3. RedBeanPHP 3.3 is a minor release and offers new functionality. For the most part this release is backward compatible. You should be able to migrate your projects with ease. However there are some minor incompatible changes. These are discussed on this page.

Strict Bean Types

From 3.3 on bean types may only contain alphanumeric characters. The underscore is no longer allowed. The reason for this is that in RedBeanPHP the underscores signifies a relationship between two types; for instance 'product_shop' is recognized as a relational bean or link table representing the relation between a product and a shop. The strict typing feature can be overridden easily by issueing:


    R
::setStrictTyping(false);

Keyless export

From 3.3 on, the bean export behaviour has become more consistent. Prior to 3.3 when you performed an export on a bean the lists would be returned as arrays indexed by the IDs. This is very problematic for Javascript to work with because it creates NULL entries for intermediate entries which is bad for performance and just ugly. On the other hand exportAll() never did this. In RedBeanPHP 3.3 this has changed. All exports now return keyless lists. If you need to old bahviour use:


    RedBean_OODBBean
::setFlagKeyedExport(true);

With the new keyless exports I hope to increase the consistency throughout the library and improve support for more Javascript oriented development strategies.

Plugins

In RedBeanPHP 3.3 plugin functions no longer have hard coded facade methods. For instance the Cooker plugin provides a method R::graph(). This method still exists, but only in R. Not in the facade RedBean_Facade. These plugin extensions of R are now compiled into the R-class by the Replica Build Script. If you use these methods on the facade class itself you should replace this code using a find replace action on your project.


 
 

RedBeanPHP Easy ORM for PHP © 2024 Gabor de Mooij and the RedBeanPHP community - Licensed New BSD/GPLv2