2
我有2个表。cakephp 3用于关联数据的queryBuilder
表1:
product_prices:
id | price |description |pack |display |created |modified |
表2:
payment_infos:
id |payer |pay_date |product_price_id |product_price |
在payment_infos
模型
$this->belongsTo('ProductPrices', [
'foreignKey' => 'product_price_id',
'className' => 'ProductPrices',
]);
我有这样的查询:
$query = $this->find('all', [
'contain' => ['ProductPrices']
]));
当运行上面的查询我收到以下错误:
Warning (512): Association property name "product_price" clashes
with field of same name of table "payment_infos".
You should explicitly specify the "propertyName" option.
[CORE\src\ORM\Association.php, line 722]
取代' '的className'=> 'ProductPrices''与'' joinType '=>' INNER''。您是否使用烘焙控制台生成模型?另外,你想达到什么目的? – Sam