Yii模块内生成CRUD
生活随笔
收集整理的这篇文章主要介绍了
Yii模块内生成CRUD
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
2019独角兽企业重金招聘Python工程师标准>>>
刚接触Yii框架不太了解其中内容,做一个简单的讲解,以便以后使用。
操作
module 命令生成 module
config中设置读取module
model 命令生成 model
crud 命令生成 CRUD
具体如下
先在数据库中做一个表
create table customers( id int primary key auto_increment, name varchar(255), zip varchar(7), tel varchar(30), address varchar(255), email varchar(255), birthday datetime ) Engine=InnoDB;生成module
$ ./protected/yiic shell Yii Interactive Tool v1.1 (based on Yii v1.1.0) Please type 'help' for help. Type 'exit' to quit. >> module kokyakumkdir /home/nakano/yii/testdrive/protected/modulesmkdir /home/nakano/yii/testdrive/protected/modules/kokyakumkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/viewsmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/views/defaultgenerate views/default/index.phpmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/views/layoutsmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/controllersgenerate controllers/DefaultController.phpmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/messagesmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/componentsmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/modelsgenerate KokyakuModule.phpModule 'kokyaku' has been created under the following folder:/home/nakano/yii/testdrive/protected/modules/kokyakuYou may access it in the browser using the following URL:http://hostname/path/to/index.php?r=kokyakuNote, the module needs to be installed first by adding 'kokyaku' to the 'modules' property in the application configuration.>> exit设置config
生成model和crud
$ ./protected/yiic shell Yii Interactive Tool v1.1 (based on Yii v1.1.0) Please type 'help' for help. Type 'exit' to quit. >> model kokyaku.models.Customer customersgenerate models/Customer.phpgenerate fixtures/customers.phpgenerate unit/CustomerTest.phpThe following model classes are successfully generated:CustomerIf you have a 'db' database connection, you can test these models now with:$model=Customer::model()->find();print_r($model);>> crud kokyaku.models.Customer generate CustomerController.phpgenerate CustomerTest.phpmkdir /home/nakano/yii/testdrive/protected/modules/kokyaku/views/customergenerate create.phpgenerate update.phpgenerate index.phpgenerate view.phpgenerate admin.phpgenerate _form.phpgenerate _view.phpCrud 'customer' has been successfully created. You may access it via: http://hostname/path/to/index.php?r=kokyaku/customer完成了。
转载于:https://my.oschina.net/songfei1983/blog/264764
总结
以上是生活随笔为你收集整理的Yii模块内生成CRUD的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: linux uniq 命令详解
- 下一篇: (转)微信公众平台关于fakeid和op