找不到Yii2 app \ model \ Db6TrxImportData

时间:2016-02-03 10:18:18

标签: php yii2

我是Yii2的新手,我遇到了这个错误。

  

PHP致命错误 - yii \ base \ ErrorException

     

Class' app \ models \ Db6TrxImportData'找不到

我搜索了你需要添加的地方

  

使用app \ models \ Db6TrxImportData;

我已将此添加到我的控制器但仍然得到相同的错误。我是yob2的菜鸟..请帮助。这是我的代码。

<?php

namespace app\modules\dtv\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use app\components\helpers\User;
use app\components\helpers\Data;
use app\models\Db6TrxImportData;

class ManageController extends \yii\web\Controller
{
    // Properties
    public $layout = '/registerLayout';
    public $breadcrumbItems;
    public $breadcrumbHomeItems;
    public $route_nav = 'dtv/manage/list';
    public $viewPath = 'app/modules/dtv/views';

    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['list', 'delete'],
                'rules' => [
                    [
                        'allow' => true,
                        'actions' => ['list', 'delete'],
                        'roles' => ['@'],
                        'matchCallback' => function ($rule, $action) {
                            $identity = User::initUser();
                            $feature = Yii::$app->params['Modules']['News Video Management'];
                            return User::hasAccess($identity, $feature);
                        },
                    ],
                ],
                'denyCallback' => function ($rule, $action) {
                    if (Yii::$app->user->isGuest) {
                        $this->goHome();
                    } else {
                        $this->redirect(['/dashboard']);
                    }
                }
            ],
        ];
    }

    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
        ];
    }

    public function init()
    {
        if (Yii::$app->user->isGuest) {
            $label  = Yii::t('app', 'Login');
            $url    = '/login';
        } else {
            $label  = Yii::t('app', 'Dashboard');
            $url    = '/dashboard';
        }

        $this->breadcrumbHomeItems = [
            'label' => $label,
            'url'     => $url,
            'template' => '<li>{link}</li> ',
        ];
    }

    public function actionList()
    {
        // Initialize Layout
        $this->breadcrumbItems = [
            Yii::t('app', 'Xml acquisition article list')
        ];

        $identity = User::initUser();
        $ownerId  = User::getOwnerId($identity);

        $dtvMovieModel = new Db6TrxImportData();

        $params = [ 'owner'         => $ownerId,
                    'status'        => 'active',
                    'application'   => 'menumaker'
                  ];
        $dtvMovie = $dtvMovieModel->getRecords($params);

        return $this->render('list', [
            'dtvMovie' => $dtvMovie
        ]);

    }

}       
?>

这是我的模特

<?php

namespace app\models;

use Yii;
use yii\db\Query;
use app\components\helpers\User;
use app\components\helpers\Data;

class Db6TrxImportData extends \yii\db\ActiveRecord
{
    public static function tableName()
    {
        return '_dtvdb.trx_import_data';
    }

    public static function getDb()
    {
        return Yii::$app->get('dtvdb');
    }

    public function rules()
    {
        return [
            [['article_id', 'ctrl_flg', 'image_flg', 'video_flg', 'del_flg', 'news_cat', 'news_cat_cd', 'copyright', 'copyright_cd', 'title', 'article_text', 'zapping_text'], 'required'],
            [['cx_create_date', 'cx_update_date', 'publish_date_from', 'publish_date_to', 'import_date', 'create_time', 'up_time'], 'safe'],
            [['status'], 'string'],
            [['article_id'], 'string', 'max' => 12],
            [['ctrl_flg', 'image_flg', 'video_flg', 'del_flg'], 'string', 'max' => 1],
            [['news_cat', 'news_sub_cat', 'disptach_type', 'copyright', 'lang'], 'string', 'max' => 100],
            [['news_cat_cd', 'dispatch_cd', 'copyright_cd', 'lang_cd', 'article_status', 'zapping_status'], 'string', 'max' => 2],
            [['news_sub_cat_cd'], 'string', 'max' => 4],
            [['title', 'zapping_text'], 'string', 'max' => 300],
            [['article_text'], 'string', 'max' => 1000],
            [['comment'], 'string', 'max' => 500]
        ];
    }

    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'article_id' => 'Article ID',
            'cx_create_date' => 'Cx Create Date',
            'cx_update_date' => 'Cx Update Date',
            'ctrl_flg' => 'Ctrl Flg',
            'image_flg' => 'Image Flg',
            'video_flg' => 'Video Flg',
            'del_flg' => 'Del Flg',
            'news_cat' => 'News Cat',
            'news_cat_cd' => 'News Cat Cd',
            'news_sub_cat' => 'News Sub Cat',
            'news_sub_cat_cd' => 'News Sub Cat Cd',
            'dispatch_cd' => 'Dispatch Cd',
            'disptach_type' => 'Disptach Type',
            'copyright' => 'Copyright',
            'copyright_cd' => 'Copyright Cd',
            'lang_cd' => 'Lang Cd',
            'lang' => 'Lang',
            'publish_date_from' => 'Publish Date From',
            'publish_date_to' => 'Publish Date To',
            'title' => 'Title',
            'article_text' => 'Article Text',
            'comment' => 'Comment',
            'zapping_text' => 'Zapping Text',
            'import_date' => 'Import Date',
            'article_status' => 'Article Status',
            'zapping_status' => 'Zapping Status',
            'status' => 'Status',
            'create_time' => 'Create Time',
            'up_time' => 'Up Time',
        ];
    }

    public static function findByAttribute($arr)
    {
        foreach ($arr as $arrKey => $arrValue) {
            $record = self::find()->where($arrKey.'=:'.$arrKey,[':'.$arrKey => $arrValue])->one();
        }
        return $record;
    }
}

0 个答案:

没有答案