controllers调用models报错 [ 2.0 版本 ]
Test.php
<?
namespace app\models;
use yii\db\ActiveRecord;
class Test extends ActiveRecord
{
public static function tableName(){
return "test";
}
}
IndexController.php
<?php
namespace app\controllers;
use yii\web\Controller;
use app\models\Test;
class IndexController extends Controller
{
public function actionIndex()
{
$model = new Test();
$data = $model->find()->one();
return $this->render("index",array("row"=>$data));
}
}
为什么$model = new Test();报错
Unknown Class – yii\base\UnknownClassException
Unable to find 'app\models\Test' in file: D:\phpStudy\PHPTutorial\WWW\bs/models/Test.php. Namespace missing?
最佳答案
其他 3 个回答
rudy5348
注册时间:2018-02-24
最后登录:2018-05-15
在线时长:1小时13分
最后登录:2018-05-15
在线时长:1小时13分
- 粉丝0
- 金钱0
- 威望0
- 积分10