RedBeanPHP

easy ORM for PHP

Formatting ID Fields

In RedBeanPHP 3.0 this feature is no longer supported. To format an ID field, you implement a method called formatBeanID(). The type of the current bean will be passed to the method and RedBeanPHP expects a field name string for the ID field. In our example, we prefix the ID field with the table name. For instance, a bean of type 'page' will now have a primary key ID in field 'page_id'. While you can change the name of the field, an auto-incrementing primary key ID itself is mandatory. RedBeanPHP will not allow any other kind of field to function as a primary key.

Also see: Default Schema Conventions (for use with legacy databases)

For an example, see: custom mapping.



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