我有一个如下的AieDetail模型:
class AieDetail extends \yii\db\ActiveRecord
{
public function getDepts()
{
return $this->hasOne(Department::className(), ['DEPT_CODE' => 'DEPT_CODE']);
}
}
我有此查询,我想使用它在Department表中选择不同的COL_ABBREV列
$aie_detail = AieDetail::find()->alias('AD')
->select(['DEPT.COL_ABBREV'])
->joinWith(['depts DEPT'])
->where(['not',['DEPT.COL_ABBREV' => ['CA']]])
->distinct()
->all();
return $aie_detail;
$ aie_detail]的值是一个查询,而不是数据数组。什么是获取行的正确方法?
我有一个AieDetail模型,如下所示:类AieDetail扩展了\ yii \ db \ ActiveRecord {公共函数getDepts(){返回$ this-> hasOne(Department :: className(),['DEPT_CODE'= ...
$aie_detail = AieDetail::find()
->select([Department::tableName() . '.COL_ABBREV'])
->joinWith('depts')
->where([
'!=',
Department::tableName() . '.COL_ABBREV',
'CA'
])
->distinct()
->asArray()
->all();
$aie_detail = AieDetail::find()->alias('AD')
->select('Department.COL_ABBREV')
->joinWith(['depts'])
->where(['not','Department.COL_ABBREV', 'CA'])
->distinct()
->all();