簡體   English   中英

如何從具有不同外鍵名稱的兩個表中獲取數據

[英]how to fetch data from the two table with different foreign key names

我是蛋糕php的新手。 請和我保持冷靜。 我試圖從兩個表ce_actionitemsce_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 AS Project打開( Project id = Actionitems id

但我希望這是

左加入EB ce_projects AS Project ON( Projectid = Actionitemsproject_id

如果我提到public $primaryKey = 'project_id';我就可以工作了public $primaryKey = 'project_id'; 在我的Actionitems但隨后它停止插入操作項。

任何幫助都會得到幫助。

在Actionitems中提及“ project_id”作為外鍵

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM