Cake:让PHP也跑在铁轨上
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。
<pre class="brush:php;toolbar:false"><small>app/models/post.php</small><?PHPclass Post extends AppModel {}?>
然后创建Control
<pre class="brush:php;toolbar:false"><pre class="brush:php;toolbar:false"><small>app/controllers/posts_controller.php</small><?PHPclass PostsController extends AppController {}?>
在其中加入index方法:
<pre class="brush:php;toolbar:false">app/controllers/posts_controller.php (fragment)function index () {}
最后创建view
<pre class="brush:php;toolbar:false"><small>app/views/posts/index.thtml</small>
ID | Title | Created |
---|---|---|
=$post['id']?> | =$this->link_for($post['title'], "/posts/view/{$post['id']}"?> | =$post['created']?> |
这样一个应用就完成了。
<pre class="brush:php;toolbar:false">输入http://cake.com/posts/index 即可访问到我们刚才创建的程序。
<pre class="brush:php;toolbar:false">IDTitleCreated1The title2005-05-23 09:30:342A title once again2005-05-23 09:30:353Title strikes back2005-05-23 09:30:35

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

Title is the meaning that defines the title of the web page. It is located within the tag and is the text displayed in the title bar of the browser. Title is very important for the search engine optimization and user experience of the web page. When writing HTML web pages, you should pay attention to using relevant keywords and attractive descriptions to define the title element to attract more users to click and browse.

PancakeSwap bakes about 150,000 cakes every day, can be minted manually, has an inflation rate of about 10%, implements a burning mechanism, and has a total supply of 750 million cakes.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

The title in HTML displays the title tag of the web page, which allows the viewer to know what the current page is about, so each web page should have a separate title.

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.
