日期:2014-05-17 浏览次数:20481 次
初识CakePHP,感觉不错;
按照官方的博客示例教程练习了一下,有点自信继续学下去了。下面是示例:
地址:http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
?
?
The Model class is the bread and butter of CakePHP applications. By creating a CakePHP 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.
CakePHP’s model class files go in?/app/Model, and the file we’ll be creating will be saved to?/app/Model/Post.php. The completed file should look like this:
<?php
class Post extends AppModel {
}
Naming convention is very important in CakePHP. By naming our model Post, CakePHP can automatically infer that this model will be used in the PostsController, and will be tied to a database table called?posts.
CakePHP will dynamically create a model object for you if it cannot find a corresponding file in /app/Model. This also means that if you accidentally name your file wrong (i.e. post.php or posts.php), CakePHP will not recognize any of your settings a