This script have an interesting function that not have present on YIIC:
limit the number of table columns that you want display at the admin page of CRUD, imagine, you have 30 colummns in your table;
YIIC CRUD generate 30 large columns in the horizontal way of course out of lay-out
typing crudm mymod 5 {table_name}
this generate only 5 columns at the admin site and at the list action; (see the documentation)
This tool can help you to generate full working app module based from an existing mysql table (CRUD) and usefulls class under a module dir sctructure like default yiic generator for models controllers and cruds.
this code is a modified version of main shell files
ControllerCommand.php
CrudCommand.php
ModelCommand.php
modified files:
ControllermCommand.php
CrudmCommand.php
ModelmCommand.php
commands: crudm modelm controllerm
See the following code example:
first crate a module using the module command: module nodulename; after this you can start using the following commands: commands are: modelm,controllerm,crudm ex for module called mymod and table called mytable: module mymod modelm mymod mytable crudm mymod (number_cols) mytable (crudm mymod 5 mytable ) controllerm mymod oneaction anotheraction etc crudm mymod 5 mytable OR crudm mymod mytable >> modelm help Usage: modelm <moduleID> <class-name> [table-name] ... This command generates a model class with the specified class name. * ModuleID: your module name directory * class-name: required, model class name. It can be specified in dot syntax (it defaults to application.models.class-name). * table-name: optional, the associated database table name. If not given, it is assumed to be the model class name. >> controllerm USAGE controllerm <moduleID> <controller-ID> [action-ID] ... DESCRIPTION This command generates a controller and views associated with the specified actions. PARAMETERS * ModuleID: your module name directory * controller-ID: required, controller ID (e.g. 'post', 'admin/user') * action-ID: optional, action ID. You may supply one or several action IDs. A default 'index' action will always be generated. >> crudm USAGE crudm <moduleID> <columns> <model-class> [controller-ID] ... DESCRIPTION This command generates a controller and views that accomplish CRUD operations for the specified data model. PARAMETERS * ModuleID: your module name directory * Columns: Number os columns to show at admin and list actions * model-class: required, the name of the data model class. This can also be specified using dot syntax (e.g. application.models.Post) * controller-ID: optional, the controller ID (e.g. 'post', 'admin.user'). If absent, the model class name will be used as the ID.
v1.2 30 MARCH crudm have option to limit the columns generated from table only for list and admin action, update,edit addnew work normal with full table columns.
Total 6 comments
Yii finally add to core all funcions in a web interface called GII. thanks for all people that help improving with ideas for this.
regards
Max
it generated something like this:
<?php /** * This is the template for generating a controller class file. * The following variables are available in this template: * - $className: the class name of the controller * - $actions: a list of action names for the controller */ ?> <?php echo "<?php\n"; ?>
class <?php echo $className; ?> extends Controller { <?php foreach($actions as $action): ?> public function action<?php echo ucfirst($action); ?>() { $this->render('<?php echo $action; ?>'); }
<?php endforeach; ?> ...
this script have an interesting function that not have present on YIIC:
limit the number of table columns that you want display at the admin page of CRUD, imagine, you have 30 colummns in your table;
YIIC CRUD generate 30 large columns in the horizontal way of course out of lay-out
typing crudm mymod 5 inventory this generate only 5 columns at the admin site and at the list action;
http://code.google.com/p/yii/source/detail?r=903
At this date (svn) YIIC only support module command for create a module structure nothing more.. :(
this functionality was finally implanted into the core, making this pretty much obsolete (except for those who don't like using the SVN)
Leave a comment
Please login to leave your comment.