Answer the question
In order to leave comments, you need to log in
Yii2 output information from the database?
Valar Morghulis!
I can't retrieve information from the database, help me out
class AboutController extends AppController
{
public function actionView()
{
$about = About::find()->where('id' >= 1)->limit(6)->all();
return $this->render('view', compact('about'));
}
}
class About extends ActiveRecord{
public function behaviors()
{
return [
'image' => [
'class' => 'rico\yii2images\behaviors\ImageBehave',
]
];
}
public static function tableName(){
return 'about';
}
public function About(){
return $this->hasMany(About::className(), 'id' >= '1');
}
}
<?= $about->name?>
Answer the question
In order to leave comments, you need to log in
In the controller
return $this->render('view', [
'about' => About::find()->where(['>=', 'id', 1])->limit(6)->all(); // <= where другой
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question