Gii Model Generator problem

Hi all!

My environment is the following:

OS: WinXP pro sp3

PHP: 5.2.17

Apache: 2.2.19 (Win32)

Yii Framework: 1.1.8

MySQL: 5.1 on port 3307

database: anamnesi (uses latin1 charset).

For the first time I installed Yii and created a skeleton with yiic in a separate folder.

I have a small, populated, database named "anamnesi" with dimensional tables named "an_…".

I specified the following connection in protected/config/main.php:


'db'=>array(

    'connectionString' => 'mysql:host=127.0.0.1;port=3307;dbname=anamnesi',

    'emulatePrepare' => true,

    'username' => 'yii',

    'password' => 'yii',

    'charset' => 'latin1',

    'tablePrefix' => 'an_',

),



I login to Gii module but as soon as I click "Model Generator" I get the following PHP error:


PHP Error


include(PDO.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory


C:\host\yii-1.1.8.r3324\framework\YiiBase.php(421)


409          {

410              foreach(self::$_includePaths as $path)

411              {

412                  $classFile=$path.DIRECTORY_SEPARATOR.$className.'.php';

413                  if(is_file($classFile))

414                  {

415                      include($classFile);

416                      break;

417                  }

418              }

419          }

420          else

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

422      }

423      else  // class name with namespace in PHP 5.3

424      {

425          $namespace=str_replace('\\','.',ltrim($className,'\\'));

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

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

428          else

429              return false;

430      }

431      return class_exists($className,false) || interface_exists($className,false);

432  }

433  return true;

Stack Trace

#0	

+  C:\host\yii-1.1.8.r3324\framework\YiiBase.php(421): YiiBase::autoload()

#1	

 unknown(0): YiiBase::autoload("PDO")

#2	

+  C:\host\yii-1.1.8.r3324\framework\db\CDbConnection.php(404): spl_autoload_call("PDO")

#3	

+  C:\host\yii-1.1.8.r3324\framework\db\CDbConnection.php(356): CDbConnection->createPdoInstance()

#4	

+  C:\host\yii-1.1.8.r3324\framework\db\CDbConnection.php(313): CDbConnection->open()

#5	

+  C:\host\yii-1.1.8.r3324\framework\db\CDbConnection.php(291): CDbConnection->setActive(true)

#6	

+  C:\host\yii-1.1.8.r3324\framework\base\CModule.php(372): CDbConnection->init()

#7	

+  C:\host\yii-1.1.8.r3324\framework\base\CModule.php(86): CModule->getComponent("db")

#8	

+  C:\host\yii-1.1.8.r3324\framework\gii\generators\model\ModelCode.php(54): CModule->__get("db")

#9	

+  C:\host\yii-1.1.8.r3324\framework\web\CFormModel.php(40): ModelCode->init()

#10	

+  C:\host\yii-1.1.8.r3324\framework\gii\CCodeGenerator.php(149): CFormModel->__construct()

#11	

+  C:\host\yii-1.1.8.r3324\framework\gii\CCodeGenerator.php(61): CCodeGenerator->prepare()

#12	

+  C:\host\yii-1.1.8.r3324\framework\web\actions\CInlineAction.php(50): CCodeGenerator->actionIndex()

#13	

+  C:\host\yii-1.1.8.r3324\framework\web\CController.php(300): CInlineAction->runWithParams(array("r" => "gii/model"))

#14	

+  C:\host\yii-1.1.8.r3324\framework\web\CController.php(278): CController->runAction(CInlineAction)

#15	

+  C:\host\yii-1.1.8.r3324\framework\web\CController.php(257): CController->runActionWithFilters(CInlineAction, array())

#16	

+  C:\host\yii-1.1.8.r3324\framework\web\CWebApplication.php(277): CController->run("")

#17	

+  C:\host\yii-1.1.8.r3324\framework\web\CWebApplication.php(136): CWebApplication->runController("gii/model")

#18	

+  C:\host\yii-1.1.8.r3324\framework\base\CApplication.php(158): CWebApplication->processRequest()

#19	

–  C:\host\anamnesi\index.php(13): CApplication->run()

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)->run();

2011-08-31 16:32:15 Apache/2.2.19 (Win32) PHP/5.2.17 Yii Framework/1.1.8

How can I test the database connection specified in main.php? (all parameters seems to me corrected).

What else can I test?

Thanks!

Seems like you have to install/enable PDO.

The first step after Yii installation would be to check the Yii requirements - http://www.yiiframework.com/doc/guide/1.1/en/quickstart.installation#requirements

Hi phtamas!

I enabled the following lines in php.ini:


...

extension=php_mysql.dll

extension=php_mysqli.dll

...

extension=php_pdf.dll

extension=php_pdo.dll

...

extension=php_pdo_mysql.dll

then

[list=1]

[*]restarted Apache

[*]run Gii Code Generator, selecting Model Generator

[*]compile required fields (disabling Build Relations)

[/list]

but, as soon as I click "Preview" Apache crashes asking if I want to submit the log to Microsoft etc.:


A problem occurred in Apache HTTP Server:

The identifier is:

szAppName: httpd.exe

szAppVer: 2.2.19.0

szModName: php_pdo_mysql.dll

szModVer: 5.2.17.17

offset: 0000249a



Apache error.log seems not to register specific informations:


[Thu Sep 01 10:25:51 2011] [notice] Parent: child process exited with status 3221225477 -- Restarting.

[Thu Sep 01 10:25:51 2011] [notice] Apache/2.2.19 (Win32) PHP/5.2.17 configured -- resuming normal operations

[Thu Sep 01 10:25:51 2011] [notice] Server built: May 20 2011 17:39:35

[Thu Sep 01 10:25:51 2011] [notice] Parent: Created child process 3676

[Thu Sep 01 10:25:51 2011] [notice] Child 3676: Child process is running

[Thu Sep 01 10:25:51 2011] [notice] Child 3676: Acquired the start mutex.

[Thu Sep 01 10:25:51 2011] [notice] Child 3676: Starting 64 worker threads.

[Thu Sep 01 10:25:51 2011] [notice] Child 3676: Starting thread to listen on port 80.

The output of phpinfo has been attached.

What can I check?

Thanks!

Hi mdomba!

The first thing I tested before go on with the customization was a check for the requirements but all mandatory requirements were Passed and only a few requirements were Warning (I suppose they are to be satisfied only if I want to use specific features).

Attached is my Requirement Checker output page.

1995

Yii Requirement Checker.htm

Any suggestion is welcome! Thanks!

Something is wrong with your php installation (sorry for stating the obvious, I don’t use Apache/PHP under Windows so I can’t help you too much to diagnose the actual problem).

If you use XAMPP or similar package then try to upgrade it to the latest version.