I am new to cake php . Please be cool with me . I am trying to fetch the data from the two table ce_actionitems
and 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. this is the generated query
LEFT JOIN
EB
.ce_projects
ASProject
ON (Project
.id
=Actionitems
.id
)
but i want this to be
LEFT JOIN
EB
.ce_projects
ASProject
ON (Project
.id
=Actionitems
.project_id
)
i got this working if i mention public $primaryKey = 'project_id';
in my Actionitems
but then it stop inserting the action items.
any help will be appriciated.
在Actionitems中提及“ project_id”作为外键
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.