源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

攻克CakePHP(PHP中的Ruby On Rails框架)图文介绍第1/2页

  • 时间:2020-10-01 09:50 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:攻克CakePHP(PHP中的Ruby On Rails框架)图文介绍第1/2页
CakePHP框架首页: [url=http://www.cakephp.org/]http://www.cakephp.org/[/url] [b]下载后导入工程中,目录结构如下图(使用版本:1.1.19.6305)[/b][img]http://files.jb51.net/upload/20081022215650913.JPG[/img] [b]搭建PHP环境,这里使用了AppServ2.5.9。[/b] 下载主页 [url=http://www.appservnetwork.com/]http://www.appservnetwork.com/[/url] [b]MySQL中新建数据库blog,并运行如下SQL文建表。[/b]
[img]http://files.jb51.net/upload/20081022215650275.gif[/img] [img]http://files.jb51.net/upload/20081022215650387.gif[/img] /* First, create our posts table: */ [img]http://files.jb51.net/upload/20081022215650208.gif[/img] CREATE TABLE posts ( [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     title VARCHAR(50), [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     body TEXT, [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     created DATETIME DEFAULT NULL, [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     modified DATETIME DEFAULT NULL [img]http://files.jb51.net/upload/20081022215650208.gif[/img] ); [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650275.gif[/img] [img]http://files.jb51.net/upload/20081022215650387.gif[/img] /* Then insert some posts for testing: */ [img]http://files.jb51.net/upload/20081022215650208.gif[/img] INSERT INTO posts (title,body,created) [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     VALUES ('The title''This is the post body.', NOW()); [img]http://files.jb51.net/upload/20081022215650208.gif[/img] INSERT INTO posts (title,body,created) [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     VALUES ('A title once again''And the post body follows.', NOW()); [img]http://files.jb51.net/upload/20081022215650208.gif[/img] INSERT INTO posts (title,body,created) [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     VALUES ('Title strikes back''This is really exciting! Not.', NOW());
[b]修改工程app/config/目录下database.php.default文件名为database.php,并修改其配置。[/b][img]http://p.blog.csdn.net/images/p_blog_csdn_net/kunshan_shenbin/q2.JPG[/img] [b]修改Apache的httpd.conf文件。[/b] Apache2.2版本的,直接把[b]#LoadModule rewrite_modulemodules/mod_rewrite.so[/b]的注释删掉即可。 2.0以前的版本,据说要修改2个地方:[b]LoadModule rewrite_module libexec/httpd/mod_rewrite.so[/b] 和[b]AddModule mod_rewrite.c[/b] [b]增加Model:[/b] [b]/app/models/post.php[img]http://files.jb51.net/upload/20081022215651114.JPG[/img] [/b] [b]代码:[/b]
[img]http://files.jb51.net/upload/20081022215650208.gif[/img] <?php [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650208.gif[/img] require_once ('cake/app_model.php'); [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650208.gif[/img] class Post extends AppModel { [img]http://files.jb51.net/upload/20081022215650208.gif[/img]      [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     public $name = 'Post'; [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     public $validate = array( [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650208.gif[/img]         'title'  => VALID_NOT_EMPTY, [img]http://files.jb51.net/upload/20081022215650208.gif[/img]         'body'   => VALID_NOT_EMPTY [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650208.gif[/img]     ); [img]http://files.jb51.net/upload/20081022215650208.gif[/img] } [img]http://files.jb51.net/upload/20081022215650208.gif[/img] [img]http://files.jb51.net/upload/20081022215650208.gif[/img] ?>
当前1/2页 [b]1[/b][url=http://www.1sucai.cn/article/16244_2.htm]2[/url][url=http://www.1sucai.cn/article/16244_2.htm]下一页[/url][url=http://www.1sucai.cn/article/16244_all.htm]阅读全文[/url]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部