Recommend this page to a friend! |
Classes of Saro Carvello | PHP Web MVC Framework | wiki/MySQL-ORM.md | Download |
|
![]() IntroductionObject-relational mapping (ORM) is a mechanism that makes it possible to address, access and manipulate objects without having to consider how those objects relate to their database tables. WebMVC provides you with a useful tool for the Object Relation Mapping of MySQL. The tool generates automatically Model classes for any tables of a given database schema. WebMVC Model and ORM - Object Relational MappingTo generate Model classes with the purpose of mapping database tables you need to: 1) Use lowercase with the underscore, which is the widely used MySQL naming notation, on your database tables and fields names. 2) Configure your database schema by modifying 3) Then, launch the tool by typing:
4) Once the utility is started, click "_Generate classes_" button. The following figure shows you the startup screen of the utility: Utility GUIAfter running the generation of classes you can close the utility. You will find all the generated classes
under Notice that:
Each auto-generated Model, widely known as a Database Bean, provides you with the following:
> Notice that ORM doesn't relieve you from a good DB design. This means you must design a good relational database > schema, before using the ORM engine provided by WebMVC. What's nextYou can use autogenerated database bean classes as a Model or in conjunction with it when coding your MVC applications. On the next page, we explain a a fully functioning DB application and consuming, Model, View ad an autogenerate database bean class. |