Answer the question
In order to leave comments, you need to log in
Tell me how in YII (ActiveRecord) to specify which column to return from the table?
Now it turns out, I just do a loop through the loop to select a value.
/**
* @return \yii\db\ActiveQuery
*/
public function getAuthors()
{
$data = $this->hasMany(Authors2products::className(), ['products_id' => 'id'])->asArray()->all();
if(count($data)) {
$result = [];
foreach($data as $k => $v) {
$result[] = $v['authors_id'];
}
return $result;
}
return [];
}
Answer the question
In order to leave comments, you need to log in
$data = $this->hasMany(Authors2products::className(), ['products_id' => 'id'])->select('authors_id')->column()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question