RedBeanPHP

easy ORM for PHP

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

To obtain the name of the table of a bean:


    $beanTable 
$bean->getMeta('type');

To get all tables:


    $listOfTables 
R::$writer->getTables();


TimeLine

To monitor the changes made by RedBeanPHP you can turn on logging with R::log($fileToWriteTo). This can be used to ease schema migrations.



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.010496854782104 sec.