模型

来自维基百科原文

模型管理着程序的主要行为和数据原文 响应关于状态的请求信息(通常来自于视图)[原文] (# > responds to requests for information about its state (usually from the view),) 也响应指令来改变状态(通常来源于控制器)[原文] (# > and responds to instructions to change state (usually from the controller).)

创建一个简单的模型原文

  1. class Model_Post extends Model
  2. {
  3. public function do_stuff()
  4. {
  5. // This is where you do domain logic...
  6. }
  7. }

如果要使用数据库,只要使用模型继承Model_Database类即可原文

  1. class Model_Post extends Model_Database
  2. {
  3. public function do_stuff()
  4. {
  5. // This is where you do domain logic...
  6. }
  7. public function get_stuff()
  8. {
  9. // Get stuff from the database:
  10. return $this->db->query(...);
  11. }
  12. }

如果你要 CRUD/ORM 功能,看看ORM Moule这个是数径)原文)