[英]how to fetch data from the two table with different foreign key names
I am new to cake php . 我是蛋糕php的新手。 Please be cool with me .
请和我保持冷静。 I am trying to fetch the data from the two table
ce_actionitems
and ce_projects
. 我试图从两个表
ce_actionitems
和ce_projects
获取数据。 i want to fetch the data from action items . 我想从操作项中获取数据。 my model is
我的模特是
public $hasOne = array(
'Project' => array(
'className' => 'Project',
'foreignKey' => 'id',
'joinTable' => 'actionitems',
'unique' => 'keepExisting',
'associatedKey' => 'project_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
but is is returning the null data because it is matching id in projects with id in action items. 但返回的是空数据,因为它与项目中的ID匹配且操作项中的ID匹配。 this is the generated query
这是生成的查询
LEFT JOIN
EB
.左加入
EB
。ce_projects
ASProject
ON (Project
.id
=Actionitems
.id
)ce_projects
ASProject
打开(Project
id
=Actionitems
id
)
but i want this to be 但我希望这是
LEFT JOIN
EB
.左加入
EB
。ce_projects
ASProject
ON (Project
.id
=Actionitems
.project_id
)ce_projects
ASProject
ON(Project
。id
=Actionitems
。project_id
)
i got this working if i mention public $primaryKey = 'project_id';
如果我提到
public $primaryKey = 'project_id';
我就可以工作了public $primaryKey = 'project_id';
in my Actionitems
but then it stop inserting the action items. 在我的
Actionitems
但随后它停止插入操作项。
any help will be appriciated. 任何帮助都会得到帮助。
在Actionitems中提及“ project_id”作为外键
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.