dongsao8279 2010-07-31 14:23
浏览 59
已采纳

在两个控制器之间传递对象

I have two controllers , and I have one object.
I want to pass that object between my two controllers in CodeIgniter.
There is a registry or something like that??


Example -
I am using ipbwi (for invision power board 3.1 integration ) , on my main controller I am doing this - private $ipbwi;

function Main()
{
    parent::Controller();   

    $this->site_url = $this->config->item('base_url');
    $this->ipb_dir = $this->config->item('ipb_dir');

    include('ipbwi/ipbwi.inc.php');
    $this->ipbwi = clone $ipbwi;
}

I want to access $ipbwi from my admin controller and don`t clone this object again.
By passing object , I mean that I can create object add Controller A and access it from Controller B.

FIXED
I used the session class to check if the user is connected or not and if he is admin.

  • 写回答

2条回答 默认 最新

  • drzfz9995 2010-07-31 15:03
    关注

    An MVC controller's purpose is to handle input from the UI and delegate it to an appropriate class in the model. You should not have the need to pass an object between controllers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 算法题:数的划分,用记忆化DFS做WA求调
  • ¥15 chatglm-6b应用到django项目中,模型加载失败
  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile