是否违反诚信约束?

时间:2018-08-23 08:37:20

标签: yii2

 $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“

1 个答案:

答案 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;