cakephp框架首页: http://www.cakephp.org/
下载后导入工程中,目录结构如下图(使用版本:1.1.19.6305)
搭建php环境,这里使用了appserv2.5.9。 下载主页 http://www.appservnetwork.com/
mysql中新建数据库blog,并运行如下sql文建表。
/**//* first, create our posts table: */
create table posts (
id int unsigned auto_increment primary key,
title varchar(50),
body text,
created datetime default null,
modified datetime default null
);
/**//* then insert some posts for testing: */
insert into posts (title,body,created)
values ('the title', 'this is the post body.', now());
insert into posts (title,body,created)
values ('a title once again', 'and the post body follows.', now());
insert into posts (title,body,created)
values ('title strikes back', 'this is really exciting! not.', now());
create table posts (
id int unsigned auto_increment primary key,
title varchar(50),
body text,
created datetime default null,
modified datetime default null
);
/**//* then insert some posts for testing: */
insert into posts (title,body,created)
values ('the title', 'this is the post body.', now());
insert into posts (title,body,created)
values ('a title once again', 'and the post body follows.', now());
insert into posts (title,body,created)
values ('title strikes back', 'this is really exciting! not.', now());
修改工程app/config/目录下database.php.default文件名为database.php,并修改其配置。
修改apache的httpd.conf文件。
apache2.2版本的,直接把#loadmodule rewrite_modulemodules/mod_rewrite.so的注释删掉即可。
2.0以前的版本,据说要修改2个地方: loadmodule rewrite_module libexec/httpd/mod_rewrite.so 和addmodule mod_rewrite.c
增加model:
/app/models/post.php
代码:
<?php
require_once ('cake/app_model.php');
class post extends appmodel {
public $name = 'post';
public $validate = array(
'title' => valid_not_empty,
'body' => valid_not_empty
);
}
?>
require_once ('cake/app_model.php');
class post extends appmodel {
public $name = 'post';
public $validate = array(
'title' => valid_not_empty,
'body' => valid_not_empty
);
}
?>
12下一页阅读全文
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!