Dynamicly (Re)Generate Models

Hi,

first of all must say I use Yii for year now. I’ve finished a few projects in that time and I’m very happy for using it.

Now I’m trying to build something bigger. I’m trying to crate application that makes dynamic models in DB and application with possibility to add and remove individual fields in that models and all that from application.

For this I need to dynamicly call gii generator for generate me model (maybe I can also use it for creating views, but there will be one more problem, adding my on personal template)? Is there any chance to call gii module from controller? I found:

example for this, but getModule(‘ssgii’) returns null all times.

Tnx for your time.

Shouldn’t you use some kind of document database, instead of a typical RDMBs?

And you don’t need to regenerate models when you add/remove/alter columns, as long as they are not FKs. You just need a dynamic way to fetch attribute labels (see attributeLabels() method). Just remember to clear the cache.

Still I need that generating command for first time. Tnx for answer @nineinchnich.I were looking for document databases, and I think that is not for me. I need implementation of this in PHP and standard MySQL (store procedures maybe). Is there any other framework to can do this from gui:

  • dynamically add entities

  • dynamically edit entities

  • dynamically add fields

  • dynamically edit fields

  • fields can be of types(decimal, string, text, lookup, option sets…)

This is maybe nice think that can be added to yii 2.0 like optional type of start making app. Specified entities and fields, and yii will create them for you i DB. You just got models, and use them in your code.