[英]Codeigniter : How to fetch different column data from foreign table using foreign key id?
[英]how to fetch data from the two table with different foreign key names
我是蛋糕php的新手。 請和我保持冷靜。 我試圖從兩個表ce_actionitems
和ce_projects
獲取數據。 我想從操作項中獲取數據。 我的模特是
public $hasOne = array(
'Project' => array(
'className' => 'Project',
'foreignKey' => 'id',
'joinTable' => 'actionitems',
'unique' => 'keepExisting',
'associatedKey' => 'project_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
但返回的是空數據,因為它與項目中的ID匹配且操作項中的ID匹配。 這是生成的查詢
左加入
EB
。ce_projects
ASProject
打開(Project
id
=Actionitems
id
)
但我希望這是
左加入
EB
。ce_projects
ASProject
ON(Project
。id
=Actionitems
。project_id
)
如果我提到public $primaryKey = 'project_id';
我就可以工作了public $primaryKey = 'project_id';
在我的Actionitems
但隨后它停止插入操作項。
任何幫助都會得到幫助。
在Actionitems中提及“ project_id”作為外鍵
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.