Issue
I am beginner in Yii2 basic. I have done this code in Yii 1.1. This is working working fine in Yii 1. But unable to load model in yii2.
Please check my code:
components/UserFun.php
<?php
namespace app\components;
use yii\base\Component;
use Yii;
use yii\base\Model;
class UserFun extends Component {
public function getStudioId($params = '') {
$studio = Studio::find()->where("id=:id",[':id' => $studio_id]); /* Skipped rest code */
return $studio->id;
}
}
Above my code I am getting this error.
PHP Fatal Error – yii\base\ErrorException
Class 'app\components\Studio' not found
Please help me
Solution
you have to include you Studio
model first.
like use frontend\models\Studio;
or whatever your model namespace is.
In Yii1
it was a different story, because there was no namespaces.
Answered By - ArtOsi
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.