Another Does Yii Allow To Create (Mysql) Database And Tables Dynamically ?


I’m just learning about Yii. I was wondering whether Yii allows to create (mysql) database and tables dynamically (for example based on a submitted webform by means of a controller)?

Appreciate your feedback



Yii is just a convenient way to organize your project with common functionalities and libraries provided out of the box. So it allows you to do anything you may do with plain php, js and db of your choice.

Have you read description how to work with database yet? You’re highly encouraged to read whole yii guide as it describes all the basic framework approaches and functionalities.

As a matter of fact, it does. However, you shouldn’t do this unless you are building a database administration tool like phpMyAdmin or chive, you really shouldn’t.

Hi Yugene ,

Thanks for your reply. I have not read the entire manual yet (this is my 3rd day of reading about Yii), but I did read some of the tutorials, some of manual and searched for related topics on the forum.

If I understand correctly - for one creating dynamic databases one -e.g. some controller code- has to :

  1. create the database and table (using plain php pdo code; that’s easy)

  2. edit the application configuration file in the protected directory the Gii tool to create the models for the table

The tutorials show how to edit the app config file and use the Gii tool manually, but I struggle to understand (/have not seen any example ) how controller code could perform these steps (2,3) automatically? Or do I miss something and do I take the wrong approach? (ps: the databases I need to create have all the same kind of tables but with different content )



thnx Da:Sourcerer for your advice. my conclusion, what i already suspected is that in that case Yii is not suitable with respect to my system requirements. Nevertheless I 'm very impressed by Yii and hope to experiment with it for another design in the future.