如何添加带where条件的orderBy()?
$floor_data = Floors::find()->where(['building_id' => $id])->orderBy->(['floor_no' => SORT_DESC])->all();
这给了我一个语法错误,说
语法错误,意外的'(',期望的标识符(T_STRING)或变量(T_VARIABLE)或'{'或'$'
答案 0 :(得分:0)
多余的->
导致了错误:
$floor_data = Floors::find()
->where(['building_id' => $id])
// Remove ↓↓
// ->orderBy->(['floor_no' => SORT_DESC])
->orderBy(['floor_no' => SORT_DESC])
->all();