Answer the question
In order to leave comments, you need to log in
Yii2 how to correctly fetch data from the database and display it?
Hello, I've run into this problem.
I write the following code:
$answers = Answers::findOne(['ticket_id' => '47']);
echo $answers->title;
$answers = Answers::find()->where(['ticket_id'=> '47']);
foreach ($answers as $answer) {
echo $answer->title." ";
}
Answer the question
In order to leave comments, you need to log in
all/one after where forgot:
$answers = Answers::find()->where(['ticket_id'=> '47'])->one();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question