0
刪除逗號我在我的控制器,這樣創建一個命令:yii2:從createCommand
public function actionTotal($id)
{
$query1 = new Query;
$query1 ->select('sum(patient_services.price) price, sum(receipts.price) receipts ,')
->from('patient_services ')
->leftJoin(' receipts ON patient_services.patient_id=receipts.patient_id')
->where('patient_services.patient_id=:id', array(':id'=>$id));
$command1 = $query1->createCommand();
$price = $command1->queryAll();
echo Json::encode($price);
}
當我嘗試...選擇代碼有一個逗號和。我不知道如何刪除它
SELECT sum(patient_services.price) price, sum(receipts.price) receipts FROM `patient_services` LEFT JOIN ` receipts ON` `patient_services`.`patient_id=receipts`.`patient_id` WHERE patient_services.patient_id=1
當我從SQL代碼中刪除所有逗號,並嘗試在phpMyAdmin ..它正常工作:(
非常感謝你,它工作正常,,,但我有一個新問題,我該如何添加IFNull到我的命令? –
$ query1-> select(['sum(patient_services.price)price,sum(IFNULL(receipts.price,0))receipts']) –