您的位置:首页 > 编程语言 > PHP开发

(3)WePHP控制器与模型

2016-02-29 10:32 537 查看
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");
}
}
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: