model文件
<?php
namespace app\models;
use Yii;
use yii\base\Model;
use yii\db\ActiveRecord;
class Folder extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'Folder';
}
public function search()
{
$query = Folder::find();
$folders = $query->where(['pid' => 0,'type'=>0])->all();
return $folders;
}
}
controller文件:
<?php
namespace app\controllers;
use Yii;
use app\controllers\CommonController;
use app\models\LoginForm;
use app\models\home\Folder;
class HomeController extends CommonController
{
public function actionIndex()
{
$model = new Folder();
$folders = $model->search();
return $this->render('index',[
'folders' => $folders,
]);
}
}
出现错误:
Unknown Class – yiibaseUnknownClassException
Unable to find 'appmodelshomeFolder' in file: /var/www/html/CodeNote/models/home/Folder.php. Namespace missing?
怎么处理???