Yii Framework Forum: yiic migrate gives CDbException "could not find driver" - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

yiic migrate gives CDbException "could not find driver" yiic migrate gives CDbException "could not find driver" Rate Topic: -----

#1 User is offline   kunalroy85 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-November 11

Posted 17 November 2011 - 05:39 AM

Hi,
I have been trying to create and execute the migration class for a database upgrade that I am trying for the first time. In the command prompt, I have been able to create the class file using the command :

yiic migrate create add_column_user


But when I run the command to upgrade the database,

yiic migrate


I get the following error on the console.

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driv
er' in F:\wamp\www\yii\framework\db\CDbConnection.php:364
Stack trace:
#0 F:\wamp\www\yii\framework\db\CDbConnection.php(313): CDbConnection->open()
#1 F:\wamp\www\yii\framework\db\CDbConnection.php(291): CDbConnection->setActive(true)
#2 F:\wamp\www\yii\framework\base\CModule.php(372): CDbConnection->init()
#3 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(415): CModule->getComponent('db')
#4 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(423): MigrateCommand->getDbConnection()
#5 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(448): MigrateCommand->getMigrationHistory(-1)

#6 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(75): MigrateCommand->getNewMigrations()
#7 [internal function]: MigrateCommand->actionUp(Array)


I have checked that PDO Mysql is installed, as I can see the module pdo_mysql by running the command

php -m


I can also connect to the mysql server from the command prompt.
Can anyone help me out what am I missing here?

Thanks!
Kunal
0

#2 User is offline   kunalroy85 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 16-November 11

Posted 18 November 2011 - 04:03 AM

View PostKunal Roy, on 17 November 2011 - 05:39 AM, said:

Hi,
I have been trying to create and execute the migration class for a database upgrade that I am trying for the first time. In the command prompt, I have been able to create the class file using the command :

yiic migrate create add_column_user


But when I run the command to upgrade the database,

yiic migrate


I get the following error on the console.

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driv
er' in F:\wamp\www\yii\framework\db\CDbConnection.php:364
Stack trace:
#0 F:\wamp\www\yii\framework\db\CDbConnection.php(313): CDbConnection->open()
#1 F:\wamp\www\yii\framework\db\CDbConnection.php(291): CDbConnection->setActive(true)
#2 F:\wamp\www\yii\framework\base\CModule.php(372): CDbConnection->init()
#3 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(415): CModule->getComponent('db')
#4 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(423): MigrateCommand->getDbConnection()
#5 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(448): MigrateCommand->getMigrationHistory(-1)

#6 F:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(75): MigrateCommand->getNewMigrations()
#7 [internal function]: MigrateCommand->actionUp(Array)


I have checked that PDO Mysql is installed, as I can see the module pdo_mysql by running the command

php -m


I can also connect to the mysql server from the command prompt.
Can anyone help me out what am I missing here?

Thanks!
Kunal


Found the problem. I had not configured the database component for the console in /protected/config/console.php
1

#3 User is offline   dbalencar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 17-November 10

Posted 27 November 2012 - 05:19 PM

View Postkunalroy85, on 18 November 2011 - 04:03 AM, said:

Found the problem. I had not configured the database component for the console in /protected/config/console.php


Thank you! The yii-user extension does not tell to configure the DB in console!!!
1

#4 User is offline   diegoalmesp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 22-May 13

Posted 22 May 2013 - 08:15 AM

Hi guys! i'm having some similar problems. I'm trying the 'first application' tutorial and, when I execute '>> model User' in yiic console I get this error:

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /opt/lampp/htdocs/yii/framework/db/CDbConnection.php:381
Stack trace:
#0 /opt/lampp/htdocs/yii/framework/db/CDbConnection.php(330): CDbConnection->open()
#1 /opt/lampp/htdocs/yii/framework/db/CDbConnection.php(308): CDbConnection->setActive(true)
#2 /opt/lampp/htdocs/yii/framework/base/CModule.php(387): CDbConnection->init()
#3 /opt/lampp/htdocs/yii/framework/base/CApplication.php(438): CModule->getComponent('db')
#4 /opt/lampp/htdocs/yii/framework/cli/commands/shell/ModelCommand.php(259): CApplication->getDb()
#5 /opt/lampp/htdocs/yii/framework/cli/commands/ShellCommand.php(128): ModelCommand->run(Array)
#6 /opt/lampp/htdocs/yii/framework/cli/commands/ShellCommand.php(99): ShellCommand->runShell()
#7 /opt/lampp/htdocs/yii/framework/console/CConsoleCommandRunner.php(67): ShellCommand->run(Array)
#8 /opt/lampp/htdocs/yii/framework/console/CConsoleApplication.php(91): CConsoleCommandRunner->run(Array)
#9 /opt/lampp/htdocs/yii/framework/base/CApplication.php(169): CConsoleApplication->processRequest()
#10 /opt/lampp/htdocs/yii/framework/yiic.php(33): CApplication->run()
#11 /opt/lampp/htdocs/yii/testdrive/protected/yiic.php(7): require_once('/opt/lampp/htdo...')
#12 {main}


As kunalroy says, I tried o configure the protected/config/console.php file exactly like the main.php. Now they look like this:

protected/config/main.php :
'db'=>array(
			'connectionString' => 'sqlite:protected/data/testdrive.db',


and /protected/config/console.php :
// application components
	'components'=>array(
		'db'=>array(
			'connectionString' => 'sqlite:protected/data/testdrive.db',
		),


I don't know if I'm missing something, I did exactly as the tutorial says, server is working, php is working and the application can be succesfully accesed via localhost. Btw, I'm working in Ubuntu 12.10.

Thanks!!

p.s.: sorry for my english, still working on that too :)
0

#5 User is offline   Nanhe Kumar 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 03-December 12

Posted 26 October 2013 - 02:00 PM

This problem arise becuase i you have not congigure datbase connection for console.

Open your console.php (protected/config/console.php)


//uncomment the following to use a MySQL database

'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),

Your can set your detail or simpy copy from main.php and replace wit it.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users