zoukankan      html  css  js  c++  java
  • (3)WePHP控制器与模型

    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");
        }
    }
    ?>

     1.M模型输出当前执行SQL $this->querySqlStr

    2.C控制器跳转$this->redirect(index/index);

  • 相关阅读:
    数据库中总结2
    PyMySQL的基本使用
    数据库总结
    并发编程之多线程
    并发编程之多进程知识
    并发编程之多进程
    操作系统基础知识
    模块二总结
    Python函数进阶
    文件操作
  • 原文地址:https://www.cnblogs.com/saw2012/p/5226625.html
Copyright © 2011-2022 走看看