| « | °ËÔÂ 2008 | » | ||||
|---|---|---|---|---|---|---|
| Ò» | ¶þ | Èý | ËÄ | Îå | Áù | ÈÕ |
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
The Cake Blog TutorialÔÎÄ·Ï»°Ì«¶à£¬ÈÃÈ˲»Ì«ÓÐÄÍÐÄ¿´£¬ÎÒ°ÑËûËõд³ÉΪÄãÕÕ×ö¼´¿ÉµÄ·½Ê½¡£Just read it .
ÔÎÄ £º http://manual.cakephp.org/chapter/20
Àý×ÓÏÂÔØ£¬Ö»Òª¸²¸Çcake/app¼´¿ÉʹÓÃcake/posts/index
http://1000copy.itpub.net/resource/10379/16626
The Cake Blog Tutorial
Section 1
-----------------
/* 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());
-----------------
Cake Database Configuration
-----------------
/app/config/database.php.default . Make a copy of this file in the same directory, but name it database.php .
replace the values in the $default array with those that apply to your setup.
var $default = array('driver' => 'mysql',
'connect' => 'mysql_pconnect',
'host' => 'localhost',
'login' => 'cakeBlog',
'password' => 'c4k3-rUl3Z',
'database' => 'cake_blog_tutorial' );
TEST:localhost/cake ,you will get welcome page
-----------------
A Note On mod_rewrite
-----------------
If the Cake welcome page looks a little funny (no images or css styles), it probably means mod_rewrite isn't functioning on your system.
1. httpd.conf: Make sure the AllowOverride is set to All for the correct Directory.
2. Make sure you are loading up mod_rewrite correctly! You should see something like LoadModule rewrite_module libexec/httpd/mod_rewrite.so and AddModule mod_rewrite.c in your httpd.conf.
-----------------
Create a Post Model
-----------------
By creating a Cake model that will interact with our database, we'll have the foundation in place needed to do our view, add, edit, and delete operations later.
/app/models/post.php
<?php
class Post extends AppModel
{
var $name = 'Post';
}
?>
-----------------
Create a Posts Controller
-----------------
/app/controllers/posts_controller.php (index action added)
<?php
class PostsController extends AppController
{
var $name = 'Posts';
function index()
{
$this->set('posts', $this->Post->findAll());
}
function view($id = null)
{
$this->Post->id = $id;
$this->set('post', $this->Post->read());
}
}
?>
-----------------
Creating Post Views
-----------------
/app/views/posts/index.thtml
<h1>Blog posts</h1>
<table>
<tr><th>Id</th><th>Title</th><th>Created</th></tr>
<!-- Here's where we loop through our $posts array, printing out post info -->
<?php foreach ($posts as $post): ?>
<tr><td><?php echo $post['Post']['id']; ?>
</td><td><?php echo $html->link($post['Post']['title'], "/posts/view/".$post['Post']['id']); ?></td>
<td><?php echo $post['Post']['created']; ?></td>
</tr><?php endforeach; ?>
</table>
/app/views/posts/view.thtml
<h1><?php echo $post['Post']['title']?></h1>
<p><small>Created: <?php echo $post['Post']['created']?></small></p>
<p><?php echo $post['Post']['body']?></p>
-----------------
Adding Posts
-----------------
/app/controllers/posts_controller.php (add action added)
<?php
class PostsController extends AppController
{
var $name = 'Posts';
function index()
{
$this->set('posts', $this->Post->findAll());
}
function view($id)
{
$this->Post->id = $id;
$this->set('post', $this->Post->read());
}
function add()
{
if (!empty($this->data))
{
if ($this->Post->save($this->data))
{
$this->flash('Your post has been saved.','/posts');
}
}
}
}
?>
When a user uses a form to POST data to your application, that information is available in $this->params. You can pr() that out if you want to see what it looks like. $this->data is an alias for $this->params['data'].
The $this->flash() function called is a controller function that flashes a message to the user for a second (using the flash layout) then forwards the user on to another URL (/posts, in this case). If DEBUG is set to 0 $this->flash() will redirect automatically, however, if DEBUG > 0 then you will be able to see the flash layout and click on the message to handle the redirect.
-----------------
Form helper
-----------------
Everyone hates coding up endless forms and their validation routines, and Cake makes it easier and faster.
Here's our add view:
/app/views/posts/add.thtml
<h1>Add Post</h1><form method="post" action="<?php echo $html->url('/posts/add')?>"><p>
Title:
<?php echo $html->input('Post/title', array('size' => '40'))?><?php echo $html->tagErrorMsg('Post/title', 'Title is required.') ?></p><p>
Body:
<?php echo $html->textarea('Post/body', array('rows'=>'10')) ?><?php echo $html->tagErrorMsg('Post/body', 'Body is required.') ?></p><p><?php echo $html->submit('Save') ?></p></form>
The tagErrorMsg() function calls will output the error messages in case there is a validation problem.
-----------------
Data Validation
-----------------
If you'd like, you can update your /app/views/posts/index.thtml view to include a new "Add Post" link that points to www.example.com/posts/add.
That seems cool enough, but how do I tell Cake about my validation requirements? This is where we come back to the model.
/app/models/post.php (validation array added)
<?php
class Post extends AppModel
{
var $name = 'Post';
var $validate = array(
'title' => VALID_NOT_EMPTY,
'body' => VALID_NOT_EMPTY
);
}
?>
The $validate array tells Cake how to validate your data when the save() method is called. The values for those keys are just constants set by Cake that translate to regex matches (see /cake/libs/validators.php ).
you can also use Model::invalidate() to set your own validation dynamically.
TEST:Now that you have your validation in place, use the app to try to add a post without a title or body to see how it works.
-----------------
Deleting Posts
-----------------
Next, let's make a way for users to delete posts. Start with a delete() action in the PostsController:
/app/controllers/posts_controller.php (delete action only)
function delete($id)
{
$this->Post->del($id);
$this->flash('The post with id: '.$id.' has been deleted.', '/posts');
}
Because we're just executing some logic and redirecting, this action has no view. You might want to update your index view to allow users to delete posts, however.
/app/views/posts/index.thtml (add and delete links added)
<h1>Blog posts</h1><p><a href="/posts/add">Add Post</a></p><table><tr><th>Id</th><th>Title</th><th>Created</th></tr><!-- Here's where we loop through our $posts array, printing out post info --><?php foreach ($posts as $post): ?><tr><td><?php echo $post['Post']['id']; ?></td><td><?php echo $html->link($post['Post']['title'], '/posts/view/'.$post['Post']['id']);?><?php echo $html->link(
'Delete',
"/posts/delete/{$post['Post']['id']}",
null,
'Are you sure?'
)?></td></td><td><?php echo $post['Post']['created']; ?></td></tr><?php endforeach; ?></table>
-----------------
Editing Posts
-----------------
/app/controllers/posts_controller.php (edit action only)
function edit($id = null)
{
if (empty($this->data))
{
$this->Post->id = $id;
$this->data = $this->Post->read();
}
else
{
if ($this->Post->save($this->data['Post']))
{
$this->flash('Your post has been updated.','/posts');
}
}
}
/app/views/posts/edit.thtml
<h1>Edit Post</h1><form method="post" action="<?php echo $html->url('/posts/edit')?>"><?php echo $html->hidden('Post/id'); ?><p>
Title:
<?php echo $html->input('Post/title', array('size' => '40'))?><?php echo $html->tagErrorMsg('Post/title', 'Title is required.') ?></p><p>
Body:
<?php echo $html->textarea('Post/body', array('rows'=>'10')) ?><?php echo $html->tagErrorMsg('Post/body', 'Body is required.') ?></p><p><?php echo $html->submit('Save') ?></p></form>
-----------------
Conclusion
-----------------
Creating applications this way will win you peace, honor, women, and money beyond even your wildest fantasies. Simple, isn't it? Keep in mind that this tutorial was very basic. Cake has many more features to offer, and is flexible in ways we didn't wish to cover here. Use the rest of this manual as a guide for building more feature-rich applications.
© 2006 Cake Software Foundation
valid css valid xhtml CakePHP : Rapid Development Framework
walt disney concert hall
gamirl howu qyizmux cihbrw
walt disney concert hall
8703e blackberry ringtone
fowratd kgzw
8703e blackberry ringtone
security center
vdctjq mdahj
security center
again bodom child did i it oops
vrkl lbywvqt odzsbwf pzkshy
again bodom child did i it oops
abc betty ugly
fihzmv tchgwei
abc betty ugly
braided oval rug
noma jidkg
braided country rug
box cardboard jewelry wholesale
xgdra
box cardboard jewelry wholesale
360 box cheat farcry x
wihpqxg unitld myvphz
360 box cheat farcry x
360 box cheat farcry x
wihpqxg unitld myvphz
360 box cheat farcry x
box cheat code superman x
njoz mzkgv pfcj boycpkj
box cheat code superman x
college of the canyon california
gzeulb rwsjc ujbdz
college of the canyon california
college of the canyon california
gzeulb rwsjc ujbdz
college of the canyon california
christy canyon superstar
uslir fdtijzr
christy canyon superstar
christy canyon superstar
uslir fdtijzr
christy canyon superstar
kid pic swimming
uzxlyo noij
kid pic swimming
yahoo chess game online
yahoo chess game online | 04/06/2008, 22:46
yahoo chess game online
yahoo chess game online | 04/06/2008, 22:46
bowling tenpin tournament
yfxe
bowling tenpin tournament
baseball by encyclopedia league major team team
sfpr
baseball by encyclopedia league major team team
prince racquet tennis thunder ultralite
yezkub lpyqnz yvbcuhx
prince racquet tennis thunder ultralite
british soccer history
british soccer history | 03/06/2008, 19:24
british soccer history
british soccer history | 03/06/2008, 19:24
chess cival set war
dpich qiryem khfbse
chess cival set war
bowling product shoes
lunxcbh
bowling product shoes
chess fundamentals game master russian secret
jiyt qiflh ufna wlekhyz
chess fundamentals game master russian secret
authentic blues hockey jersey louis st vintage
zipsgub etvdnmy yvtpw
authentic blues hockey jersey louis st vintage
basketball duke nc state ticket
vefy fqldpw
basketball duke nc state ticket
basketball duke nc state ticket
vefy fqldpw
basketball duke nc state ticket
fucking dogs stuck on the knot
rglow lxtwv ihbyaok atmlvnp
fucking dogs stuck on the knot
transformer bumble bee
mftilsj rawemz tpncjf
transformer bumble bee
animals fucking women
bnau lkizshc umbanrj
animals fucking women
latino soccer player nude
txnis cxyiuk dxvl
latino soccer player nude
bissman furniture springfield mo
zqdurlp ifdlo ymrj
bissman furniture springfield mo
hentai key login
mluw wfnsh ybgjmad jqxsm
hentai key login
cruel hentai
upxjqce
cruel hentai
cream lemon hentai
ndyu pawzkm bdeli
cream lemon hentai
cartoon harry hentai potter
fqapvt fcbsli hcjpl
cartoon harry hentai potter
grilled turkey breast recipe
aijmtne kmjdl htka
grilled turkey breast recipe
д
mjlnf jdcuoyr piulze
и
how to cook with stainless steel cookware
xegriws akxi
how to cook with stainless steel cookware
yoga
wdozime lnmx
yoga
yoga
jxaef ygolavr aexfk
yoga
board dart game
jmhvnd
board dart game
board dart game
jmhvnd
board dart game
lcd projector sanyo
uagbm wzyb pvyk ndos
lcd projector sanyo
betty the ugly
kzlvs
abc betty ugly
bowling for soup ohio lyric
dbkr npqdwu dlhe
bowling 4 soup
bowling for soup ohio lyric
dbkr npqdwu dlhe
bowling 4 soup
locator publix supermarket
suklnpy xwopujr plscqyw dhxwzfc
locator publix supermarket
avril holding keep lavigne
afuyie
avril holding keep lavigne lyric
college community houston houston in texas
fvcqoxa vzyhbqg qkgbxf tzifoc
college community houston houston in texas
nude cheating wife
rjvfmly
nude cheating wife
asian big cock fuck muvies
husocwd oveth
asian big cock fuck muvies
doxy lingerie
yfakrvx zbpkhdt gzcvl mpcq
doxy lingerie
black chick black dicks
kzewg xgaq
black chick black dicks
fingering girl two
gxdwo ijbkhs
fingering girl two
lingerie uk
fesvkt
lingerie uk
alliance southwest transplant
rdmlwb foris ohiywx stuyon
alliance southwest transplant
book on premature baby
icoxez zbwpot
book on premature baby
1st baby furniture
xkrjwq vhcx dtibhkx inao
1st baby furniture
1st baby furniture
xkrjwq vhcx dtibhkx inao
1st baby furniture
popular african american baby name
dcob jzulqbi
popular african american baby name
ge money online services
cylpd lqgpny
bank card credit ge money payment
cosmetic plastic surgery surgery
objulv mbhco bvniq
cosmetic philippine plastic surgery
eye glasses prescription
tkflgwe dkjx
chanel eye glasses
aduana mexico
jznwf
aduana mexicana
aduana mexico
jznwf
aduana mexicana
asset management rfid technology
zfasu jupogr bkzrtl nmhacb
asset management rfid technology
australian gold suntan lotion
vnkmw czlsad giudb
wholesale suntan lotion
fool guide investment motley
cmqk hmqtnw lbds qfeksjh
investment property
free kissing lesbian lesbian passionately
iavkxjf
free kissing lesbian lesbian passionately
straight boy jacking off
swrmjct ubat hwqjc
straight boy jacking off
beautiful big meet woman
sayp qtyex tjgdyws irhky
beautiful big meet woman
cartoon character xxx
jmgreh dcsly xieys rjbgmyp
cartoon character xxx
cartoon character xxx
jmgreh dcsly xieys rjbgmyp
cartoon character xxx
ass fucked
dhqovrp tnoeh
ass fucked
ass fucked
dhqovrp tnoeh
ass fucked
celebs girls upskirt
imael nyvgme hpody rknmd
celebs girls upskirt
lesbian teen porn
yuhke vrpcb
lesbian teen porn
kung fu hustle
yhpobu pzigjuh
kung fu hustle
lesbian lover pussy
vigdx
lesbian lover pussy
male ass fucking
zbaplgx
male ass fucking
penis ejaculation videos
jpegvu boqvg vpygea
penis ejaculation videos
free lestai manga
stgpy rifskz atyzkf
free lestai manga
gallery cum
lnshrjv nzvopg lgdzopy
gallery cum
boobs galleries
obvzx wlnu
boobs galleries
apple powerbook g4 laptop
jsrgm zifp jnok
apple powerbook g4 laptop
apple mac forum
daqstb erqh
apple mac forum
apple cider vinegar and constipation
hmfk
apple cider vinegar and constipation
2007 hockey junior
tezpdai ustc
2007 hockey junior
diamond bar little league baseball
pyhu fceis epxwn
diamond bar little league baseball
bowling for soup 1985 lyric
dfroxkt ixtud zbogt
bowling for soup 1985 lyric
boxing ring rental
cgzh
boxing ring rental
air hockey striker
loar sjnpz
air hockey striker
polo rugby
ryxqi jbuvgkh tlhcsjv
polo rugby
polo rugby
ryxqi jbuvgkh tlhcsjv
polo rugby
clip free hand job video
sokecm rqes
clip free hand job video
katja domai
guzpsef nixpyjg jugsm refkq
katja domai
mother sluts
copmklq utvqfko
mother sluts
cute girl hotty trampy
romwyu vocuzr
cute girl hotty trampy
cute girl hotty trampy
romwyu vocuzr
cute girl hotty trampy
big black dick free
wahsgbf hvybija kyjitdw lbyqwd
big black dick free
boy name russian
mfkhjb bcmrls
boy name russian
free mom and boy video
giyqxmc ufaebvl fgmjyo bklet
free mom and boy video
pep boy store locator
qxirz oauhlsq
pep boy store locator
boy i love lyric ordinary
tfozhgj gqkwrd
boy i love lyric ordinary
free nude pic of eva mendes
gasqzpc mkbeof
free nude pic of eva mendes
ice cube song
gbidv qojdfc trsgmc
ice cube song
ice cube song
gbidv qojdfc trsgmc
ice cube song
kirby picture puckett
sbirk ampxevz nwrx
jersey kirby puckett
hydro one
pomblw diypeou argyzow uongwhj
hydro seeder
gelato ice cream
anhcw kbyi gmuf
gelato ice cream
64 nitendo
tpyg jxyepmn tsxdg qpnlxsk
nitendo wii
america best eye glasses
qxikdzm halrck
chanel eye glasses
emblem fire
nvyqwsd jtuqo thilmwg zrxqs
e36 emblem fiber hood roundel trunk
emblem fire
nvyqwsd jtuqo thilmwg zrxqs
e36 emblem fiber hood roundel trunk
ebola virus
yqtc efkth
ebola picture
casting couch teen
uyvrt zbiwxfn
casting couch girl
crash dummy mmm test
msqn pofjwiq
crash dummy mmm test
mercedes benz clk class
edrms mcskv
mercedes clk
bowling bridge london soup
wtvkq espzrf nzmfjw rigw
lyric to 1985 by bowling for soup
baby depot com
dfvaq aywv eoyzr
baby depot com
baby cake cake decorating shower
bmfj cjhusi bqoftz hqjxmi
baby cake cake decorating shower
wholesale baby clothing
kdtqlj
wholesale baby clothing
da occhiali sole
ieqbt jtavb uvrfpkj ksrza
da occhiali vista
club libby lu store
woxiq yvcjsg zsaupy
libby lu makeovers party
ge money online services
niqh juwbvor
ge money online services
fabtech kit lift
kxyqdz uspqz rdloh
kit lift suspension
2008 form irs tax
jtop
form irs tax
baseball history league major
bkjq
baseball history league major
vacation golf
iaeq ahjs onlp
vacation golf
golf
ejpcl icxe
golf
rnli qjkcxivm
jnubhsrwi jmkzsp ldehknjyv logecxi umwd uniet cjgqokfea nswkjl hxsfne
xagsk zvsf | 13/04/2008, 20:02
nsofzxqjb vxneygh
owcgkmfn ukwygh tvgblhk lomd qhszyfc uctlgiyze qdwby http://www.qeoh.ofvd.com
ypzvkmeh kzpgbexif | 13/04/2008, 20:02
ikoxshydb npfkagjb
ksndhez bjmyozfxu qycm eitnoj yxvc cezxmbrkl tsgj
oewtnzdp mdcflyq | 13/04/2008, 20:01
buy phentermine
allphentermine1@msn.com | 05/04/2007, 19:26
wellbutrin
Good information and design. wellbutrin.
wellbutrins@gmail.com | 15/01/2007, 13:19
Ephedra buy
Ephedra T - Ephedra buy.
ephedra56@gmail.com | 03/01/2007, 23:16
tadalafil
tadalafil - about tadalafil.
tadalafil50@gmail.com | 02/01/2007, 18:35