zoukankan      html  css  js  c++  java
  • Codeigniter夸应用调用model

    Thinkphp里面的model都是可以跨应用调用,ci本身没有实现这个方法。
    可是稍微修改下,比Thinkphp用起来更容易调用。
    找到Loader.php文件的地址/system/core/Loader.php
    找到后打开文件,找到这个类的初始化方法,大概在124行的位置开始。

    public function __construct()
        {
            $this->_ci_ob_level  = ob_get_level();
            $this->_ci_library_paths = array(APPPATH, BASEPATH);
            $this->_ci_helper_paths = array(APPPATH, BASEPATH);
            $this->_ci_model_paths = array(APPPATH);
            $this->_ci_view_paths = array(APPPATH.'views/'   => TRUE);
     
            log_message('debug', "Loader Class Initialized");
        }

    只需要修改几行代码就可以实现了。

    public function __construct()
    {
        $this->_ci_ob_level  = ob_get_level();
        $this->_ci_library_paths = array(APPPATH, BASEPATH);
        $this->_ci_helper_paths = array(APPPATH, BASEPATH);
     
        $paths = array('weixin/', 'application/');
        $paths = array_merge(array(APPPATH,), $paths);
        $paths = array_unique($paths);
        $this->_ci_model_paths = $paths;
     
        $this->_ci_view_paths = array(APPPATH.'views/'   => TRUE);
     
        log_message('debug', "Loader Class Initialized");
     
     
    }

    将几个应用的目录名写在$paths这个数组里面。
    最后$paths这个数组复制给_ci_model_paths这个成员变量就行了。
    ci在加载model的时候会循环这个数组下面的models文件,如果找到文件就会自动跳出
    这里稍微做了一下处理,以当前的调用文件的目录优先查找.

  • 相关阅读:
    JQuery移除事件
    .NET经常调用的外部系统函数举例说明
    sql server日期时间转字符串
    关于无法打开微软网站的解决方法[转]
    Html5 第二章
    style、currentStyle、getComputedStyle区别介绍
    删除右键菜单中多余项
    css制作流程及标准
    CSS的选择器
    Mysql 函数集
  • 原文地址:https://www.cnblogs.com/hubing/p/4047961.html
Copyright © 2011-2022 走看看