instnet 2011-08-05 17:00:03 2519次浏览 2条回复 0 0 0
public function getMysqlVersion() {
  $db = Yii::app()->db; //you have to define db connection in config/main.php
  $sql = "select version()";
  $command = $db->createCommand($sql);
  $results = $command->queryAll();
  foreach($results as $result){
    print_r($result);
  }
}

出现错误,

PHP Error

Undefined variable: results

E:\webTools\htdocs\openShop\public\protected\controllers\AdminController.php(91)

79     {
80         Yii::app()->user->logout();
81         $this->redirect(Yii::app()->homeUrl);
82     }
83     /**
84 85      */
86     public function getMysqlVersion() {
87         $db = Yii::app()->db; //you have to define db connection in config/main.php
88         $sql = "select version()";
89         $command = $db->createCommand($sql);
90 91         foreach($results as $result){
92             print_r($result);
93         }
94 
95     }
96 }

错误页上没有91行,程序中是有的,就是

$results = $command->queryAll();这个个。

请问,大家可以告诉我原因吗?

亿速云
您需要登录后才可以回复。登录 | 立即注册