Gii: generate CRUD application from existing database tables? - yii

I have a mysql database with tables that have one to many relationships with foreign keys linking them.
How can I use gii to create CRUD form pages which will reflect the table relationships?

I suggest you to take a look at the following article which includes using yii's gii
Creating Your First Yii Application

Related

It's possible to detect a many-to-many relationship on a rlinq file?

I am working on a project manually mapping entities from a SQL db. My primary source of information about columns, keys, relationships, and others is the rlinq generate by Telerik from the db.
I wonder if it's possible to detect a many-to-many relationship based on only in this file.

How to generate automatically relationships with JPA with IntelliJ?

I found this solution for a problem I have: how to generate entities with JPA annotations from a given database.
IntelliJ IDEA 10 generate entity (POJO) from DB model
Now with IntelliJ I'm given the possibility to create relationships between entities manually. Is there a way to generate them automatically as it did with entities?
I used the REFERENCES keyword when needed while creating the database. I suppose there should be an automatic mapping of relationships as well!
When Generating entities from DB Schema in dialog there is an option to 'Show default relationships' which when selected will display FK relationships when selecting tables to generate entities from:

How to generate relations between tables

How can I use Gii to create relations between the tables? Should I create them first in my database or they will be generated automatically?
Gii doesn't create a schema for you (like EclipseLink or Hibernate would in Java), it just helps you to create ActiveRecord classes based on the definition of your schema in database and the relationships that it can find between your tables and with the help of some conventions that the framework have. If you want to manage your database changes programmatically you should try Yii migrations.
Short answer, you must first create the schema and then use gii to generate active record classes.
Hope this helps.

Piranha CMS Custom Entities

I am new the Piranha. I want to make a new table in database like as site messages or newsletter form.
Can I make extension or what is the right way for Piranha?
Additional info: I am not using source code. I add piranha to my project from Nu-get.
just add entities/tables to your database using entity framework or whatever technology you like.
Remember that if you use an ORM you will can't have foreign key to tables in other contexts (Piranha) so you'll have to handle relationships with software triggers.
Regards
HÃ¥kan

About CRUD generator in Yii

i am starting to use Yii framework and the gii tool to create the crud functionality for several tables.
The issue is that i need normally to modify the generated code. For example, i have noticed that all the forms use only text inputs. For example, in the case of foreign keys i need to show a select where the user can select a register of the other table without having to insert the primary key.
I achive this modifying the involved views (_view.php, _form.php, ...). My problem starts when it's necessary to modify the database and regenerate the code again. For that case i would have to go table by table, updating the involved files one by one keeping my old changes.
Does it exist a way to deal better with this situation?
The GiiX extension generates dropdowns for relationships.
In case you use the Gii Model generation, GiiX generates better models, too.
You don't have to do that. You can generate a select with the foreign keys, for example.
<?php echo CHtml::dropDownList('ModelName[language_id]',$model->language_id,CHtml::listData(Language::model()->findAll(), 'id', 'name'), array('prompt'=>'Select Language')); ?>
The first parameter is the name of the select, second is the value (if you're updating, the value will be selected), third is the data, and the fourth is an array with html options. More info about CHtml::dropDownList and CHtml::listData.
In this, the language_id is the foreign key, and in the Language table you have an id and a name field. This will generate a select with all the available languages, like this : 1=> English, 2=> German etc.
If you're going to need the functionality of crud form generation a couple of times, with the option of show foreign keys as dropdowns, you can create your own gii template to do it for you. Take a look at the guide to know how to do it.
For this functionality you need to develop you gii tool which will inherit functionality of existing gii tool, means some modification in existing classes while creating CRUD. This is your specific requirement, gii tool provides only general functionality which suits to all users.