以下代码返回错误:
$orders = Yii::$app->db->createCommand("SELECT
Orders.CustomerName AS BillingName
FROM `Orders`
WHERE `CustomerId` = :student_id ORDER BY Orders.`EntryDate` DESC")->bindValues([":student_id" => $student_id])->queryAll();
$orders_result = [];
$i = 0;
foreach ($orders as $order) {
$total_books_price = 0;
$orders_result[$i] = [
"BillingName" => $order["CustomerName"],
];
但如果我将SELECT COLUMN AS ALIAS
替换为SELECT *
,则可以正常使用。