dqhdz04240 2010-01-11 01:18 采纳率: 0%
浏览 8

CakePHP控制器交互问题

I have two separate controller, view, database combos: Users and Jobs. Users contains: id, name, jobid. Jobs contains: id, name, wage.

In my user container, I want to retrieve my job name and wage to send to the user view. I wanted to know what is the best practices here. I have tried two methods:

1.) $this->requestAction('/Jobs/getArray', array('pass' => user['jobid'])); I heard this is not the best practice, especially if you have a lot of interaction between controllers, which I probably will. It is also a pain to try and do all of the sending and receiving this way.

2.) App::import the jobs Connector. $Jobs = new JobsConnector. $Jobs->getArray($user['jobid']); Any time I try to do this, I get undefined errors. JobConnector::Job does not exist. I then get an error on the find() method, which otherwise is working.

I have spent hours trying to work out both methods and have been pulling my hair out. I am on the verge of going back to my own personal class interaction because of how much of a PitA these class interactions are.

Someone, please help!

  • 写回答

4条回答 默认 最新

  • douci4026 2010-01-11 01:22
    关注

    Have you tried doing this with table relations instead of request actions? That way you get the related data from one model in the referencing model throughout your app.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂