2
在SQL列名的引用我想寫這樣的SQL與誼2:如何防止Yii2
select id, 1 as type from user;
這是我的代碼:
$query = User::find()->select(['id', '1 as type'])->all();
1
是一個常數,不用戶的字段
我想將字段type = 1
添加到查詢結果。
在SQL列名的引用我想寫這樣的SQL與誼2:如何防止Yii2
select id, 1 as type from user;
這是我的代碼:
$query = User::find()->select(['id', '1 as type'])->all();
1
是一個常數,不用戶的字段
我想將字段type = 1
添加到查詢結果。
要禁用報價和在查詢的某些部分逸出,它包裝在yii\db\Expression:
use yii\db\Expression;
...
$query = User::find()->select(['id', new Expresssion('1 as type')])->all();