繁体   English   中英

在cakephp中显示另一个表的属性

[英]Showing the attribute from another table in cakephp

我有两个表Shift和ShiftSession。 这种关系就像班次有很多班次,而班次属于班次。

我像这样在shiftsession的模型上定义关系。

var $name = 'ShiftSession';                    
var $belongsTo = array(        
      'Shift' => array(            
         'className'    => 'Shift',            
         'foreignKey'    => 'ShiftID'
       )    
    );  

问题是我想显示从shift表中移出的名称,而不是shiftsession表中的shiftID。

你得试试:

$this->ShiftSession->find('all');

这将从Shift表返回相应的数据。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM