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

Schema

RedBeanPHP generates a sane and readable database schema for you. Here are the schema conventions used by RedBeanPHP:

Field names:Lowercase a-z, 0-9 and underscore (_)
Table name:Should match bean type, a-z, 0-9
Primary key:Each table should have a primary key named 'id' (int, auto-incr)
Foreign key:Format: <TYPE>_id
Link table:Format: <TYPE1>_<TYPE2> sorted alphabetically

Be careful with underscores; they are used for linking tables and foreign keys. It's safe to use underscores in property names, but try not to use them in type names/tables.

Schema functions (3.5+)

To obtain the name of the table of a bean:


    $bean 
R::dispense('book');
    
$beanTable $bean->getMeta('type');

To get all the columns in this table:


    $fields 
R::inspect('book');

To get all tables:


    $listOfTables 
R::inspect();

In RedBeanPHP 3.4 and earlier use R::$writer->getTables() and R::writer->getColumns($type).



 
 

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