Common Single Controller / Model for all tables in current database

I hope I am not crazy , as I am new to this framework and really need expert opinion in this regard .

My client requested me to expose all database tables for basic CRUD operations and with the passage of time we might add/delete tables . I know how to use gii to generate MVC stuff for a table , but that seems to be extra/repeating code/view for nothing . What I want is to use single controller and model to expose basic CRUD + search operation on any table in database ,which we pass it as parameter.

for example : I have a link index?r=backend/list/users

where backend points to common controller BackendController

list is entry method in that controller

users is parameter we want to pass .

When accesses this controller should read the schema for the parameter tables ‘users’

– list all the records (paginate)

– provide add/edit/search/delete(multiple) record links

a delete link might look


a edit link might look


Same for all the tables in current application database (will be accessible for admin users only)

I tried to use Gii to generate the CRUD form of the table but its seems that it requires model.

Please guide me with your expert opinion

thanks in advance

CRUD generated actions are working only on Active Record.

It doesn’t have sense to have all Model’s to be listed on one page, what if you have 50 tables. It will also be slow, to gather all models on same page.

However it is possible. You can use gii to generate CRUD actions for all your models, and then in your main(dashboard) view include views from every controller(partial). This will work, but if possible, please try to avoid it.

Hi @Ivica thanks for the reply, I am working on a solution and not finished yet . I don’t want all models on page ,actually don’t want models at all . I have some success lets see how it comes along .