CakePHP framework home: http://www.cakephp.org/
Import the downloaded directory to the project. The directory structure is shown in figure (Version: 1.1.19.6305)
Set up the PHP environment. Here AppServ2.5.9 is used.Home http://www.appservnetwork.com/
Create a database blog in MySQL and run the following SQL statement to create a table.
/** // * 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 ());
Modify the file name of database. php. default in the app/config/directory of the project to database. php, and modify its configuration.
Modify the httpd. conf file of Apache.
Apache2.2 directly# LoadModule rewrite_modulemodules/mod_rewrite.so.
In versions earlier than 2.0, it is said that two places should be modified:LoadModule rewrite_module libexec/httpd/mod_rewrite.soAndAddModule mod_rewrite.c
Add Model:
/App/models/post. php
Code:
<? 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
);
}
?>