Runcorn
Runcorn

Reputation: 5224

Yii Migration Issue

I am new to PHP and Yii PHP Framework.

I am trying to run an application in my local machine. For which i first need to migrate Database. For which i run following command,

protected/yiic migrate

But it throws CDbException with following Stack Trace ...

Yii Migration Tool v1.0 (based on Yii v1.1.14)

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /var/www/Prepaid-Card/web/framework/db/CDbConnection.php:382
Stack trace:
#0 /var/www/Prepaid-Card/web/framework/db/CDbConnection.php(330): CDbConnection->open()
#1 /var/www/Prepaid-Card/web/framework/db/CDbConnection.php(308): CDbConnection->setActive(true)
#2 /var/www/Prepaid-Card/web/framework/base/CModule.php(387): CDbConnection->init()
#3 /var/www/Prepaid-Card/web/framework/cli/commands/MigrateCommand.php(442): CModule->getComponent('db')
#4 /var/www/Prepaid-Card/web/framework/cli/commands/MigrateCommand.php(451): MigrateCommand->getDbConnection()
#5 /var/www/Prepaid-Card/web/framework/cli/commands/MigrateCommand.php(482): MigrateCommand->getMigrationHistory(-1)
#6 /var/www/Prepaid-Card/web/framework/cli/commands/MigrateCommand.php(84): MigrateCommand->getNewMigrations()
#7 [internal function]: MigrateCommand->actionUp(Array)
#8 /var/www/Prepaid-Card/web/framework/console/CConsoleCommand.php(172): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)
#9 /var/www/Prepaid-Card/web/framework/console/CConsoleCommandRunner.php(71): CConsoleCommand->run(Array)
#10 /var/www/Prepaid-Card/web/framework/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#11 /var/www/Prepaid-Card/web/framework/base/CApplication.php(180): CConsoleApplication->processRequest()
#12 /var/www/Prepaid-Card/web/framework/yiic.php(33): CApplication->run()
#13 /var/www/Prepaid-Card/web/protected/yiic.php(7): require_once('/var/www/Prepai...')
#14 /var/www/Prepaid-Card/web/protected/yiic(4): require_once('/var/www/Prepai...')

And here is my console.php file

<?php

return array(
    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..',
    'name' => 'Prepaid Card',
    // preloading 'log' component
    'preload' => array('log'),
    'import' => array(
        'application.models.*',
        'application.components.*',
        'application.extensions.*',
        'ext.YiiMailer.YiiMailer'
    ),
    // application components
    'components' => array(
        'db' => require(dirname(__FILE__) . '/../../../../DbConfig.php'),
        'log' => array(
            'class' => 'CLogRouter',
            'routes' => array(
                array(
                    'class' => 'CFileLogRoute',
                    'levels' => 'error, warning',
                ),
            ),
        ),
    )
);

I have already installed mysql and have created the subsequent database. My DbConfig file looks like

<?php
return array(
    'connectionString' => 'mysql:host=localhost;dbname=db_ppc',
    'emulatePrepare' => true,
    'username' => 'root',
    'password' => 'helloworld',
    'charset' => 'utf8',
);

I just couldn't figure out the issue here.

What i am doing wrong here ? What could be the cause of this issue ? Please help me to solve it.

Thanks!!!

Upvotes: 3

Views: 710

Answers (1)

zmilan
zmilan

Reputation: 1152

"CDbConnection failed to open the DB connection: could not find driver". This message tell u that something is not good configured on your environment. Check your php configuration for database driver and restart/reload your apache to load new configuration.

Upvotes: 1

Related Questions