crudcontroller Create-read-update-delete operations on every tables in DB by a single controller

  1. Documentation
  2. Change Log

This extension implements CRUD operations on the DB tables using a single controller.

Resources

Documentation

Requirements
  • Yii 1.0.2 or above - tested only at this version
Warning!!!

Be careful with access control! You should set restricted access to this controller, or list allowed models in filters, or organize access control to tables at the database level (if possible). Otherwise one can manipulate with your forbidden datatables over it!

Installation
  • Extract the release catalogue 'crud' under protected/extensions

  • Add to your 'config/main':

[php]

 'controllerMap'=>array(
    'crud'=>array(
       'class'=>'application.extensions.crud.CrudController',
    )
),

 'components'=>array(
     ..............
    'crudMessages'=>array(
        'class'=>'CPhpMessageSource',
        'basePath'=>'protected/extensions/crud/messages',
    ),     
     ..............

[php]

The last ('crudMessages') is needed if you have created corresponding message file 'yii.php' and dispose it in the corresponding language directory. At present only Russian translation is available.

  • Define 'pluralName' property to all of your models you want to manipulate over this controller - if wanna get nice titles!

  • Define all needed relaitons in your models via Model::relations. Notice! Only 'BELONGS_TO' type taken into account in this version.

  • View files 'list.php', 'createUpdate.php' use CSS classes defined in 'main.css', registered in layout. You may redefine them in your own css-file and register this one (after publishing).

Usage

call by the adddress:

{baseUrl}/crud/{action}/model/{modelName}[/id/{recordId}],

where {action} = create|list|update|delete|

{modelName} - your model's name in lowercase

if needed (for update&delete), set the value of record id you want to update or delete:

{recordId} - record id (if needed)

Restrictions

At present can work with models having:

  • ONLY 'BELONGS_TO' relations;

  • ONE primary key named 'id';

  • refered table MUST have a field named 'name' - that is the field which is displayed in the relation

I learnt from someone that references can be emulated even on MyISAM tables using 'COMMENT' SQL declaration, but I didn't check.

It works definitely on InnoDB with real references - this is a fact, and it's enough for me...

Change Log

April 11, 2009
  • Initial release.
1 0
2 followers
985 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Tags:
Developed by: kvl
Created on: Apr 11, 2009
Last updated: 8 years ago

Downloads

show all