My table is called "book" and my columns are "title" and "author".
In my view file I added:
use yii\helpers\Html;
use frontend\models\Book;
use yii\db\ActiveQuery;
use yii\db\Connection;
use yii\db\ActiveRecord;
<?php $model = Book::find(1);
if($model){
echo $model->title;
echo $model->author;
}?>
But strangely I cannot retrieve this data from the database, what did I miss please?
I am also not sure if all my "use" statements are correct.
I have done a few changes but still nothing showing on the page:
<?php
use yii\helpers\Html;
use frontend\models\Book;
/* @var $this yii\web\View */
$this->title = 'About';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="site-about">
<h1><?= Html::encode($this->title) ?></h1>
<p>This is the About page. You may modify the following file to customize its content:</p>
<p>
<?php $model = Book::findOne(1);
if($model){
echo $model->title;
}?>
</p>
<code><?= __FILE__ ?></code>
</div>