为什么80%的码农都做不了架构师?>>>   

打开命令行窗口,执行下面列表中的命令,

% cd WebRoot/testdrive
% protected/yiic shellYii Interactive Tool v1.1
Please type 'help' for help. Type 'exit' to quit.
>> model User tbl_usergenerate models/User.phpgenerate fixtures/tbl_user.phpgenerate unit/UserTest.phpThe following model classes are successfully generated:UserIf you have a 'db' database connection, you can test these models now with:$model=User::model()->find();print_r($model);>> crud Usergenerate UserController.phpgenerate UserTest.phpmkdir D:/testdrive/protected/views/usergenerate create.phpgenerate update.phpgenerate index.phpgenerate view.phpgenerate admin.phpgenerate _form.phpgenerate _view.phpCrud 'user' has been successfully created. You may access it via:http://hostname/path/to/index.php?r=user

如上所示,我们使用yiic shell命令和应用框架交互. 在提示中,我们执行两个子命令: model User tbl_user 和crud User.前者生成基于tbl_user表的模型类User, 后者分析User模型并且生成相应的CRUD操作代码.

Note: You may encounter errors like "...could not find driver", even though the requirement checker shows you have already enabled PDO and the corresponding PDO driver. If this happens, you may try to run the yiic tool as follows,

% php -c path/to/php.ini protected/yiic.php shell

where path/to/php.ini represents the correct PHP ini file.

Let's enjoy our work by browsing the following URL:

http://hostname/testdrive/index.php?r=user

This will display a list of user entries in the tbl_user table.

Click the Create User button on the page. We will be brought to the login page if we have not logged in before. After logged in, we see an input form that allows us to add a new user entry. Complete the form and click on the Create button. If there is any input error, a nice error prompt will show up which prevents us from saving the input. Back to the user list page, we should see the newly added user appearing in the list.

Repeat the above steps to add more users. Notice that user list page will automatically paginate the user entries if there are too many to be displayed in one page.

If we login as an administrator using admin/admin, we can view the user admin page with the following URL:

http://hostname/testdrive/index.php?r=user/admin

This will show us the user entries in a nice tabular format. We can click on the table header cells to sort the corresponding columns. We can click on the buttons on each row of data to view, update or delete the corresponding row of data. We can browse different pages. We can also filter and search to look for the data we are interested in.

All these nice features come without requiring us to write a single line of code!

 

转载于:https://my.oschina.net/tlkt/blog/210571

Yii框架官方指南系列53——专题:使用命令行生成代码(已废弃)相关推荐

  1. Yii框架官方指南系列41——专题:自动代码生成

    为什么80%的码农都做不了架构师?>>>    自版本 1.1.2 起, Yii 装备了基于 Web 界面的代码生成工具Gii. 它取代了之前的命令行端的代码生成工具 yiic sh ...

  2. Yii框架官方指南系列43——专题:URL(创建、路由、美化及自定义)

    为什么80%的码农都做不了架构师?>>>    Web应用程序完整的URL管理包括两个方面.首先, 当用户请求约定的URL,应用程序需要解析 它变成可以理解的参数.第二,应用程序需求 ...

  3. YOS里面推入AD的命令行生成代码

    把YOS里面生成AD帐户的命令行生成代码共享一下,互通有无: ASP程序: Set rs = Server.CreateObject("ADODB.Recordset") rs.o ...

  4. Yii框架官方指南系列14——基础知识:开发流程

    为什么80%的码农都做不了架构师?>>>    介绍过 Yii 中的基本概念之后,我们现在讲解使用 Yii 开发Web应用时的一般开发流程. 此处的开发流程假设我们已经完成了对应用的 ...

  5. 【PHP框架 | Laravel8 系列4】 - Artisan 命令行

    前言:之前在学习并使用 Laravel 框架过程中,全是碎片化掌握,现在重新学习并记录一次学习的过程. 本文内容对应 Laravel8.* 版本. 直达入口: Laravel 框架专栏 Laravel ...

  6. 中兴zxr10路由器重启命令_中兴ZXR10系列路由交换机用户、命令行手册

    教程名称:中兴ZXR10系列路由交换机用户.命令行手册 课程目录: [IT教程网]2609A&2618A&2626A&2826A&2826A-PS用户手册上 [IT教程 ...

  7. postgresql数据库系列之:cmd命令行访问远程postgresql数据库

    postgresql数据库系列之:cmd命令行访问远程postgresql数据库 psql -h 10.129.88.141 -U iris_read -d iris_test Password fo ...

  8. php怎么创建表命令行,laravel创建数据表(使用命令行结合代码)

    下面由Laravel框架教程栏目给大家介绍laravel 创建数据表,希望对需要的朋友有所帮助! 虽然可以直接在数据库中创建数据表,但是不便于以后项目的迁移.现使用命令行结合代码的方式来进行生成. 1 ...

  9. MATLAB转化彩色图片为灰度图片命令行窗口代码:

    转化彩色图片为灰度图片命令行窗口代码: >> imread docia.png   %打开图片 docia.png >> whos  %显示当前变量,发现产生临时变量ans,里 ...

  10. 命令行生成、运行及调用jar包

    文章目录 一.制作只含有字节码文件的jar包 二.制作含有jar文件的jar包 三.制作含有资源文件的jar包 四.java命令行执行带依赖jar包的main函数 本文参考文章如下: 命令行生成并直接 ...

最新文章

  1. spark Tachyon
  2. Android Studio如何发布APK
  3. Windows安装MySQL教程
  4. Eclipse内存分析工具的用法
  5. 让用户来决定Windows任务管理器的CPU占用率
  6. python编程快速上手_给Python小白推荐的40本入门书籍,帮你快速上手
  7. XCTF WEB cookie
  8. 大学生应当趁早谋划未来
  9. 林轩田《机器学习基石》笔记
  10. C语言 判断并输出完数
  11. 计算机专业的毕设,计算机专业毕设业计要求.doc
  12. hive系列-hive教程
  13. PPT模板,背景图片,等等(千图网大礼包)
  14. windows下用cmd卸载程序
  15. 车牌识别之字符切割2
  16. 本地的registry图形化界面harbor安装与使用--02
  17. 高中政治教师资格证考试成功通过前辈备考经验谈
  18. D. Tournament Countdown
  19. 普元软件获一亿战略投资 董事长刘亚东谈三大核心竞争优势
  20. 【小贴士】合肥工业大学计科与物联网本科毕业设计“外文翻译”tips

热门文章

  1. 怎么调节手机的刷新率_【W21 5G性能篇】120Hz自适应刷新率,用了再也回不去
  2. docker基础3--容器的基本操作
  3. Mysql占用CPU过高的时候,该从哪些方面下手进行优化?
  4. FR获取当前控件位置值并转换(或赋值可参考)
  5. python画哆啦a梦图片_画了个多啦A梦,但是感觉怪怪的
  6. python怎么看待_如何看待将Python作为少儿编程的基础语言?
  7. 关于四川2019ACM省赛热身赛B题的一个证明
  8. 使用 ESLint 禁止项目导入特定模块
  9. jdk的安装及环境变量的配置
  10. wget整站抓取、网站抓取功能