2013-08-22 50 views
0

我有一個項目Yii。我把模型從我的控制器在一個表中在Yiiibase.php中包含錯誤 - Yii Framework

$model = new NewAccForm(); 
$post = Post::model()->find($model); 
var_dump($post); 

顯示數據我在一個錯誤運行代碼:

PHP warning 

include(Post.php) [<a href='function.include'>function.include</a>]: failed to open stream: 

No such file or directory

E:\wamp\www\yii\framework\YiiBase.php(427) 

415       { 
416        include($classFile); 
417        if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php') 
418         throw new CException(Yii::t('yii','Class name "{class}" does not match class 

file "{file}".', array( 419 '{class}'=>$className,

420          '{file}'=>$classFile, 

421        ))); 

422        break; 

423       } 

424      } 

425     } 

426     else 

427      include($className.'.php'); 

428    } 

429    else // class name with namespace in PHP 5.3 

430    { 
431     $namespace=str_replace('\\','.',ltrim($className,'\\')); 

432     if(($path=self::getPathOfAlias($namespace))!==false) 

433      include($path.'.php'); 

434     else 

435      return false; 

436    } 
437    return class_exists($className,false) || 

interface_exists($className,false);

438   } 

439   return true; 

Stack Trace 
#0  
+ E:\wamp\www\yii\framework\YiiBase.php(427): YiiBase::autoload() 
#1  
unknown(0): YiiBase::autoload("Post") 
#2  
– E:\wamp\www\yii\amica\protected\controllers\front\ReportController.php(10): 

spl_autoload_call("Post") 05 '1'=>'Mới', 06 '2' => 'Đã Xóa' 07 ); 08 public function actionIndex() { 09 $model = new ReportForm(); 10 $post = Post::model()->find($model); 11 var_dump($post); 12 echo "

Thông báo lỗi cho ban quản trị

"; 13 } 14 15 public function actionCreate() { #3
+ E:\wamp\www\yii\framework\web\actions\CInlineAction.php(49): ReportController->actionIndex() #4
+ E:\wamp\www\yii\framework\web\CController.php(308): CInlineAction->runWithParams(array("r" => "report")) #5
+ E:\wamp\www\yii\framework\web\CController.php(286): CController->runAction(CInlineAction) #6
+ E:\wamp\www\yii\framework\web\CController.php(265): CController->runActionWithFilters(CInlineAction, array()) #7
+ E:\wamp\www\yii\framework\web\CWebApplication.php(282): CController->run("") #8
+ E:\wamp\www\yii\framework\web\CWebApplication.php(141): CWebApplication->runController("report") #9
+ E:\wamp\www\yii\framework\base\CApplication.php(180): CWebApplication->processRequest() #10
– E:\wamp\www\yii\amica\protected\components\WebApplicationEndBehavior.php(24): CApplication->run() 19 // Attach the changeModulePaths event handler 20 // and raise it. 21 $this->onModuleCreate = array($this, 'changeModulePaths'); 22 $this->onModuleCreate(new CEvent($this->owner)); 23 24 $this->owner->run(); // Run application. 25 } 26 27 // This event should be raised when CWebApplication 28 // or CWebModule instances are being initialized. 29 public function onModuleCreate($event) { #11
unknown(0): WebApplicationEndBehavior->runEnd("front") #12
+ E:\wamp\www\yii\framework\base\CComponent.php(261): call_user_func_array(array(WebApplicationEndBehavior, "runEnd"), array("front")) #13
– E:\wamp\www\yii\amica\index.php(13): CComponent->__call("runEnd", array("front")) 08 defined('YII_DEBUG') or define('YII_DEBUG',true); 09 // specify how many levels of call stack should be shown in each log message 10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3); 11 12 require_once($yii); 13 Yii::createWebApplication($config)->runEnd('front'); #14
+ E:\wamp\www\yii\amica\index.php(13): CWebApplication->runEnd("front")

爲什麼會出現這樣的問題?以及如何解決它?謝謝。

回答

2

Post::model()

Post模型應在路徑protected/models/Post.php或模型後使用的命名空間,應該比你會設置的Yii::setPathOfAlias($alias,$path)

+0

謝謝。我已糾正它 –

0

別名檢查型號名稱的文件名的拼寫和內部模型類名/Post.php因爲區分大小寫,所以第一個字符必須是大寫字母。