$data = (new \yii\db\Query())
->select('categoryMaster_id , categoryMaster_name,categoryMaster_image')
->from('categoryMaster')
->join('LEFT JOIN','productType', 'productType.categoryMaster_id = categoryMaster.categoryMaster_id')
->where('categoryMaster_id=:categoryMaster_id', ['categoryMaster_id' => $_GET['categoryMaster_id']])
->all();
return $data;
SQLSTATE [23000]:违反完整性约束:1052 where子句不明确的列'categoryMaster_id'\ n正在执行的SQL是:SELECT * FROM
categoryMaster
左联接productType
ON productType.categoryMaster_id = categoryMaster .categoryMaster_id WHERE categoryMaster_id ='1'“,”代码“:23000,”类型“:” yii \ db \ IntegrityException“
答案 0 :(得分:0)
在select
中含糊不清。添加categoryMaster.categoryMaster_id
$data = (new \yii\db\Query())
->select('categoryMaster.categoryMaster_id, categoryMaster_name, categoryMaster_image')
->from('categoryMaster')
->join('LEFT JOIN','productType', 'productType.categoryMaster_id = categoryMaster.categoryMaster_id')
->where('categoryMaster.categoryMaster_id=:categoryMaster_id', ['categoryMaster_id' => $_GET['categoryMaster_id']])
->all();
return $data;