Find one record from the database


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);


	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.

Thank you,


Should be findOne and not find:

<?php $model = Book::findOne(1); ?>

Thank you Fabrizio,

I have done a few changes but still nothing showing on the page:


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>


<?php $model = Book::findOne(1);


      echo $model->title;










    <code><?= __FILE__ ?></code>


Check model content with:


$model = Book::findOne(1);


Test it with DEBUG, so if there are other errors you can see them.

Thanks Fabrizio, Will check this debug mod out:-)