代码之家  ›  专栏  ›  技术社区  ›  Vidar Vestnes

如何使用代码点火器从另一个模块加载模型

  •  4
  • Vidar Vestnes  · 技术社区  · 14 年前

    我用的是HMVC扩展和CodeIgniter,我得到了2个模块

    modules/frontpage
      -- controllers
        frontpage.php ( <- this controller needs to load the person model)
      -- models
      -- views
    modules/person
      -- controllers
      -- models
        person_model.php ( defines Person_Model extends Model )
      -- views
    

    使用 $this->load->model('person_model') 在FrontPage控制器内部,似乎只加载全局或包含在同一模块(FrontPage模型)中的模型。

    这里有点火器专家吗?

    3 回复  |  直到 8 年前
        1
  •  15
  •   Vidar Vestnes    14 年前

    找到它…这是一个简单的解决办法。

    只需使用: $this->load->model('person/person_model');

        2
  •  0
  •   Rehan Anis    12 年前

    根据我在另一个版本的CodeIgniter中的经验,加载模型的正确方法是 $this->加载->模型($model='person',$module='person');

        3
  •  0
  •   alex GmonC    8 年前
    $rand=rand(1,9999999);
    $currentModel="currentModel".$rand;
    $this->load->model($call_model,$currentModel);
    $call_method=$method;            
    $currentMod=$currentModel;
    $CI =& get_instance();
    $re_data= $CI->$currentMod->$call_method($paramArr);