MVC的先进理念就是程序流程 数据库操作 模板制作三个流程分离
大M函数会把模型引入到当前控制器的方法中,注意这个"excel"对应M文件夹的excel.php 同时也是整个excel.php操作的数据库表名,这样每个表它自己对应的操作都在同名PHP中
<?php class C_index extends Action { public function __initialize() { echo"自动执行"; } public function index() { echo "index"; } public function test() { $a="我是模板"; $this->assign("pass",$a); $this->display(); $mo=M("excel"); $mo->index(); } } ?>
<?php class M_excel extends Model { public function index() { echo "我是mode2l"; $row=$this->table("test")->where("1")->select("queryOnce"); dump($row); //$this->select(); //dump($sqlquery); dump("zhenian"); } } ?>
原文:http://www.cnblogs.com/saw2012/p/5226625.html