dongmi0760 2014-12-29 04:44
浏览 58

Codeigniter:如何在codeigniter中调用单个控制器函数中的多个模型函数

I am new to coidigniter.

If I am calling single model method from controller function then its working fine.

If I amt try to call more than one model function from single model, through single controller function, then I get

Fetal Error:Call to a member function result() on Boolean

my code look like this

controller.php

public function get_details(){

   $this->my_model->get_company();  //first call

   $this->my_model->get_employee();  //second call

}

my_model.php

public function get_company(){

 $qry="CALL get_company_details";

 $result=$this->db->query($qry);

 foreach($result->result() as $row){

   $data[]=$row;

 }

return $data;

}


public function get_employee(){

 $qry="CALL get_employee_details";

 $result=$this->db->query($qry);

 foreach($result->result() as $row){

   $data[]=$row;

 }

return $data; 

} 

Can I call like that. Please help me...

  • 写回答

3条回答 默认 最新

  • dongshou2024 2014-12-29 04:51
    关注

    Simple typo:

    Change

    function get_company(){
    

    to

    function get_employee(){
    

    You have defined same function twice.

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效