All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
解决SQL Server连接中最为常见的错误_[SQL Server教程]
HTML教程-收集的常用的HTML标签(6)_[Html教程]
mscorwks.dll在.Net中的地位以及在.Net代码保护方面的应用_[Asp.Net教程]
详细学习动态网页制作PHP技术的正则表达式_[PHP教程]
Web基础控件开发--属性(续)_[Asp.Net教程]
实例分享:自己开发的自定义分页控件_.net资料_编程技术
C#,3.0新特性系列:隐含类型var_.net资料_编程技术
轻松掌握SQL,Sever中各种语句的完整语法_mssql学习_编程技术
ASP.NET,2.0移动开发入门之使用模拟器_[Asp.Net教程]
一位网友整理出来的网页播放器参数_JavaScript技术_编程技术
Reading number is top 10 pictures
浴室里的美女
西班牙山村小景3
中国女孩大胆自拍,显露完美身材3
The real super beauty4
Female model behind the bitterness, often being overcharged2
Kim jong il's mistress, national beauty JinYuJi actor3
HongMenYan premiere XinLiangGong clairvoyant outfit PK YiFeiLiu2
In 2013 hercules Arnold classic2
Ashlynn Brooke photograph of a group3
全身蕾丝丝质美臀
Download software ranking
传奇私服架设教程
徐若瑄成名作“魔鬼天使”
Love the forty days
JSP+Ajax Web development typical examples
Sora aoi - one of more PK
Tram sex maniac 2 (H) rar bag1
C#与.NET技术平台实战演练
仙剑奇侠传98版歌曲
终极变速大师Speeder3.26
Ashlynn Video1
delv published in(发表于) 2013/12/29 4:38:44 Edit(编辑)
Cake:让PHP也跑在铁轨上_php资料_编程技术

Cake:让PHP也跑在铁轨上_php资料_编程技术

Cake:让PHP也跑在铁轨上_php资料_编程技术-你的首页-uuhomepage.com

Cake是一个根据Ruby on Rails而架构的php 框架。和RoR一样,Cake也封装了对数据库的操作。目前Cake还不算一个成熟的框架,但是已经很值得关注了。

下边介绍下怎么在WAMP上安装Cake。

首先下载Cake Latest version: cake_0.2.9.zip



解压后,进入cakeconfig 将database.php.default改名为database.php,并对数据库的参数进行设置。如:

$DATABASE_CONFIG = array(
'devel' => array(
'host' => 'localhost',
'login' => 'user',
'password' => 'user',
'database' => 'cake'
)
);

然后Cake需要用到Apache的mod_rewrite,打开Apache的/config/httpd.conf,将

#LoadModule rewrite_module modules/mod_rewrite.so

前的#号去掉,


#AddModule mod_rewrite.c

前的#号去掉。

然后添加一个虚拟主机,比如


ServerAdmin Easy@gmail.com
DocumentRoot "F:/cake/"
ServerName cake.com
ErrorLog logs/cake.com.error_log
CustomLog logs/cake.my.com common


AllowOverride all
Order allow,deny
Allow from all

在 C:WINDOWSsystem32driversetchosts中加入一行本地host

127.0.0.1 cake.com

然后重启Apache和浏览器。

这时候Cake已经可以正常工作了。我们来创建一个应用:

在数据库中创建一个表

CREATE TABLE posts (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(50),
body TEXT,
created DATETIME DEFAULT NULL,
modified DATETIME DEFAULT NULL
);
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());
Cake是基于MVC模式的。创建一个应用时,我们先创建它的Model。
app/models/post.php
class Post extends AppModel {
}
?>
然后创建Control
app/controllers/posts_controller.php
class PostsController extends AppController {
}
?>
在其中加入index方法:
app/controllers/posts_controller.php (fragment)
function index () {
}
最后创建view
app/views/posts/index.thtml
post->find_all() as $post): ?>
IDTitleCreated
link_for($post['title'], "/posts/view/{$post['id']}"?>

这样一个应用就完成了。
输入http://cake.com/posts/index 即可访问到我们刚才创建的程序。


IDTitleCreated
1The title2005-05-23 09:30:34
2A title once again2005-05-23 09:30:35
3Title strikes back2005-05-23 09:30:35


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.