I'm new to Yii here. In the documentation, it seems to imply that gii will create the relations for related models. But when using gii to generate models from DB, it doesn't seem to be the case. For example, I have a user table and a profile table with a column "user_id INTEGER DEFAULT 0", but the relations array is empty in the generated model. Did I do something wrong, or gii just doesn't automatically recognize the relations? Thanks,
相关问题
- Yii - Eliminate default controller ID for a module
- how to change csrf field id from YII_CSRF_TOKEN to
- Load balancing with Yii sessions
- Yii uploading pictures
- How to Auto Login and Redirect After Registration
相关文章
- Can you run console jobs from yii2-basic?
- How to do a bulk database insert in Yii2?
- Yii2 - check if the user is logged in view
- Call static method from a string name in PHP
- radioButtonList checked by default
- Postgres error: null value in column “id” - during
- Add column as link in CGridView
- yii : how to ajax update the cgridview
Gii can automatically create relations for generated models if corresponding tables in your DB have foreign keys, but not all storage engines support foreign keys. For example, if you use MyISAM tables in MySQL, you have no way to define it.
Gii will create relations for MyISAM tables if you include a format like the following in the comment of the referenced columns: