php - Cake PHP 2 模型与查找器查询的关联
问题描述
我有一个场景,我必须将同一个模型与 hasMany 相关联。
Children
在PatientPaymentTransaction
模型中具有多关系:
public $hasMany = [
'Children' => [
'className' => 'PatientPaymentTransaction',
'foreignKey' => false,
'dependent' => true,
// 'conditions' => ['Children.reference_id' => 'PatientPaymentTransaction.transaction_id' ],
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => 'SELECT *,children.reference_id as patient_payment_transaction_id FROM patient_payment_transactions children WHERE children.reference_id = {$__cakeID__$}',
'counterQuery' => ''
]
];
响应
数据在儿童中找到但未附加。
我做错了什么?
解决方案
试着这样说,在我正在工作的模型中,我的关系$hasMany
是这样排列的:
'PatientPaymentTransaction' => array(
'className' => 'PatientPaymentTransaction',
'foreignKey' => 'reference_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => 'SELECT *,children.reference_id from children FROM patient_payment_transactions children WHERE children.reference_id = {$__cakeID__$}',
'counterQuery' => ''
);
推荐阅读
- oracle - 带有连接的 Oracle 子查询
- python - 无法在python中使用scrapy迭代数据
- c++ - 如何在 C++ 中从 curl 获取原始数据
- angular - 角度自动完成材料
- android - 在 AsyncTask 中测试一个涉及侦听器回调的类
- sql - 如何根据 SQL Server 中的列对多记录求和
- mysql - 有什么方法可以隐藏我的 MySQL 备份还原代码上的连接字符串?
- sql - 如何通过指定字节数对字符串进行子串化
- css - Header tag appearing on top of another element partially hidden
- java - jvm中如何将native代码转换为机器码