【发布时间】:2015-11-08 13:23:57
【问题描述】:
我的模型常见问题解答有 4 个属性
* @property integer $id
* @property string $chapter
* @property string $question
* @property string $answer
现在我的 actionIndex 函数看起来像
public function actionIndex()
{
$faq = Faq::find()->all();
$dataProvider = new ActiveDataProvider([
'query' => Faq::find(),
]);
return $this->render('index', [
'dataProvider' => $dataProvider,
'faq' => $faq
]);
}
如何在 Controller 中使用 Yii2 或 PHP 获取 $chapter 的唯一值数组?让我们在 sql 中说它看起来像
SELECT DISTINCT chapter FROM ' faq_table'
【问题讨论】:
标签: php sql arrays activerecord yii2