i can't use model!?

hi everyone

i got a wired issue when i try to use Model

i have one table in mysql named ‘user’,i wanna make it into User Model

however,when i try to generate it through Model Generator,as i click preview button,my browser says "Internet Explorer cannot display the webpage",(same situation happened when try it in Chrome)

well,i thought its maybe some problems with Gii,so i use yiic shell to create that model.and it works.i got the User.php.

however,when i try to printf that model,i got that damn error page again.it seems that i can’t use any AR model in my browser or something.

i have totally no idea about it,does anyone have the same problem?

Give some more info. What url are you calling to access gii. How have you configured gii in your config/main.php How are you trying to access the model?

( ! ) Fatal error: Maximum execution time of 30 seconds exceeded in C:\yii-1.1.3.r2247\framework\base\CApplication.php on line 610

Call Stack

Time Memory Function Location

1 0.0037 335488 {main}( ) …\index.php:0

2 0.1027 1768760 CApplication->run( ) …\index.php:13

3 0.1029 1768760 CWebApplication->processRequest( ) …\CApplication.php:135

4 0.1109 1956976 CWebApplication->runController( string(0) ) …\CWebApplication.php:121

5 0.1289 2348728 CController->run( string(0) ) …\CWebApplication.php:324

6 0.1348 2370912 CController->runActionWithFilters( object(CInlineAction)[11], array(0) ) …\CController.php:257

7 0.1349 2370936 CController->runAction( object(CInlineAction)[11] ) …\CController.php:278

8 0.1350 2370984 CInlineAction->run( ) …\CController.php:300

9 0.1353 2371040 SiteController->actionIndex( ) …\CInlineAction.php:32

10 0.1585 3094032 User::model( ??? ) …\SiteController.php:30

11 0.1585 3094080 CActiveRecord::model( string(4) ) …\User.php:18

12 0.1587 3096032 CActiveRecordMetaData->__construct( object(User)[12] ) …\CActiveRecord.php:353

13 0.1588 3096096 CActiveRecord->getDbConnection( ) …\CActiveRecord.php:2048

14 0.1591 3096128 CApplication->getDb( ) …\CActiveRecord.php:553

15 0.1591 3096176 CModule->getComponent( string(2), ??? ) …\CApplication.php:391

16 0.1695 3240312 CDbConnection->init( ) …\CModule.php:363

17 0.1697 3240376 CDbConnection->setActive( bool ) …\CDbConnection.php:221

18 0.1697 3240376 CDbConnection->open( ) …\CDbConnection.php:242

19 0.1738 3241192 CDbConnection->createPdoInstance( ) …\CDbConnection.php:261

20 0.1743 3241688 PDO->__construct( string(35), string(4), string(4), array(0) ) …\CDbConnection.php:310

21 30.1912 3248424 CApplication->handleError( long, string(184), string(49), long, array(3) ) …\CApplication.php:0

841

error.jpg

well,the output above displayed after i set "show_errors=on"

i try to printf User Model in index page,so this message comes out as i visit the index page

it looks creating db connection failed.

i did nothing but uncomment the mysql setting in protected/config/main.php,and defined the correct mysql connection information,i think the config is correct,so that i can create model through shell,but i don’t know why i can’t use db connection in php directly.

hope someone can tell me what’s wrong,thx

more details below

PHP Error

Description

Source File

C:\yii-1.1.3.r2247\framework\db\CDbConnection.php(310)

00298: * @since 1.0.4

00299: */

00300: protected function createPdoInstance()

00301: {

00302: $pdoClass=‘PDO’;

00303: if(($pos=strpos($this->connectionString,’:’))!==false)

00304: {

00305: $driver=strtolower(substr($this->connectionString,0,$pos));

00306: if($driver===‘mssql’ || $driver===‘dblib’)

00307: $pdoClass=‘CMssqlPdoAdapter’;

00308: }

00309: return new $pdoClass($this->connectionString,$this->username,

00310: $this->password,$this->_attributes);

00311: }

00312:

00313: /**

00314: * Initializes the open db connection.

00315: * This method is invoked right after the db connection is established.

00316: * The default implementation is to set the charset for MySQL and PostgreSQL database connections.

00317: * @param PDO the PDO instance

00318: */

00319: protected function initConnection($pdo)

00320: {

00321: $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

00322: if($this->emulatePrepare && constant(‘PDO::ATTR_EMULATE_PREPARES’))

Stack Trace

#0 C:\yii-1.1.3.r2247\framework\db\CDbConnection.php(310): PDO->__construct()

#1 C:\yii-1.1.3.r2247\framework\db\CDbConnection.php(261): CDbConnection->createPdoInstance()

#2 C:\yii-1.1.3.r2247\framework\db\CDbConnection.php(242): CDbConnection->open()

#3 C:\yii-1.1.3.r2247\framework\db\CDbConnection.php(221): CDbConnection->setActive()

#4 C:\yii-1.1.3.r2247\framework\base\CModule.php(363): CDbConnection->init()

#5 C:\yii-1.1.3.r2247\framework\base\CApplication.php(391): CWebApplication->getComponent()

#6 C:\yii-1.1.3.r2247\framework\db\ar\CActiveRecord.php(553): CWebApplication->getDb()

#7 C:\yii-1.1.3.r2247\framework\db\ar\CActiveRecord.php(2048): User->getDbConnection()

#8 C:\yii-1.1.3.r2247\framework\db\ar\CActiveRecord.php(353): CActiveRecordMetaData->__construct()

#9 C:\Users\Kent\phpWorkspace\pinball\protected\models\User.php(18): model()

#10 C:\Users\Kent\phpWorkspace\pinball\protected\controllers\SiteController.php(30): model()

#11 C:\yii-1.1.3.r2247\framework\web\actions\CInlineAction.php(32): SiteController->actionIndex()

#12 C:\yii-1.1.3.r2247\framework\web\CController.php(300): CInlineAction->run()

#13 C:\yii-1.1.3.r2247\framework\web\CController.php(278): SiteController->runAction()

#14 C:\yii-1.1.3.r2247\framework\web\CController.php(257): SiteController->runActionWithFilters()

#15 C:\yii-1.1.3.r2247\framework\web\CWebApplication.php(324): SiteController->run()

#16 C:\yii-1.1.3.r2247\framework\web\CWebApplication.php(121): CWebApplication->runController()

#17 C:\yii-1.1.3.r2247\framework\base\CApplication.php(135): CWebApplication->processRequest()

#18 C:\Users\Kent\phpWorkspace\pinball\index.php(13): CWebApplication->run()

2010-09-30 03:34:13 Apache/2.2.16 (Win32) PHP/5.3.3 Yii Framework/1.1.3

anyone help?

Your php has not pdo_mysql extension enabled.

You should inlcude this module for make the database work.

well, finally,i solved that problem after i replace ‘localhost’ with ‘127.0.0.1’ in connection string.

i don’t know why yii can’t recognize ‘localhost’,even though other mysql manager softwares know it at the same time.