Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Creating ORM from existing database
  • Can someone tell any ways to create ORM from existing database??
  • I am a FuelPHP newbie, so others may be able to give you a more enlightened answer. Many frameworks allow you to automatically generate the database structure from your models. But trying to do the opposite - that is, automatically generate model code simply by looking at the structure of the database - is very risky. The more tables you have in your database, and the more complex your data relationships are, the more likely that the code generator will not be able to guess it right: it will overlook important links, establish links that don't exist, and forget data validation which might be vital for your application. Right now you may have a system setup with a different framework, and the data management is being handled in a certain way by that framework, with the tools that framework provide. It is likely that the tools in FuelPHP are different, and you will have to use a different strategy - that is, you will have to retool your data management. You can certainly keep your existing database structure. But I would recommend you manually create Model classes - extending the ORM class - then implement data validation, and re-establish data relationships (one-to-many, many-to-many, etc.) as needed for each model. Use the Active Record methods to implement data searches, and make use of the built-in CRUD methods for data storage. FuelPHP is extremely flexible, and you will certainly be able to re-model your data *quickly* and efficiently, no matter how complex. Of course, it is highly advisable that you make a full copy of your database, and try all of this out on a 'development' copy of your data, before trying it out on a live server - and using your live data! I hope this helps.
  • Actually using Fuel its pretty easy to make a database use the ORM, as long as it has a proper primary key any database can be converted without much effort. Just set the properties right and relate the tables with the proper FK and relationship method. Read the Docs on the ORM you'll understand soon =]

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion