Hello Friends I am new to Yii2 Framework.
i am writing following code as specified in mention filename still....
While i am calling model method then does not showing output showing 500 error in console
Is Any Mistake in code then please mention here ..
SiteController.php
<?php
use yii\web\Controller;
use yii\data\Pagination;
use app\models\Site;
class SiteController extends CController
{
// Define an action. actionIndex is a default action
public function actionIndex()
{
$data = Site::models()->getData();
$this->render('view',array(
'data'=>$data,
));
// $this->render('view');
}
}
Site.php - Model
<?php
namespace app\models;
use yii\db\ActiveRecord;
class Site extends ActiveRecord
{
public function getData() {
$connection = Yii::app()->db;
$command = $connection->createCommand("Select * from site");
return $caterow = $command->queryAll();
}
public static function tableName()
{
return 'site';
}
}