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