2

我已按照分步说明使用 migrate 命令在我的数据库中创建一个表,但我想知道它是如何在最后一步完成的。运行“ yiic migrate ”命令后,我收到以下消息:

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

exception 'CDbException' with message 'CDbConnection.connectionString cannot be
empty.' in D:\wamp\www\news\framework\db\CDbConnection.php:369
Stack trace:
#0 D:\wamp\www\news\framework\db\CDbConnection.php(330): CDbConnection->open()
#1 D:\wamp\www\news\framework\db\CDbConnection.php(308): CDbConnection->setActiv
e(true)
#2 D:\wamp\www\news\framework\base\CModule.php(387): CDbConnection->init()
#3 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(442): CModule->get
Component('db')
#4 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(451): MigrateComma
nd->getDbConnection()
#5 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(482): MigrateComma
nd->getMigrationHistory(-1)
#6 D:\wamp\www\news\framework\cli\commands\MigrateCommand.php(84): MigrateComman
d->getNewMigrations()
#7 [internal function]: MigrateCommand->actionUp(Array)
#8 D:\wamp\www\news\framework\console\CConsoleCommand.php(172): ReflectionMethod
->invokeArgs(Object(MigrateCommand), Array)
#9 D:\wamp\www\news\framework\console\CConsoleCommandRunner.php(67): CConsoleCom
mand->run(Array)
#10 D:\wamp\www\news\framework\console\CConsoleApplication.php(91): CConsoleComm
andRunner->run(Array)
#11 D:\wamp\www\news\framework\base\CApplication.php(169): CConsoleApplication->
processRequest()
#12 D:\wamp\www\news\framework\yiic.php(33): CApplication->run()
#13 D:\wamp\www\news\framework\yiic(14): require_once('D:\wamp\www\new...')
#14 {main}

我不知道我必须在它之后运行什么命令以及如何完成迁移过程!

有人对此问题有解决方案吗?(我也在使用Windows 7)

4

2 回答 2

2

在 config/console.php 里面添加数据库配置

'components' => array(
  'db'=> array(
    'connectionString' => '',
  'username' => '',
  'password' => '',
  )
)   

具有适当的数据库详细信息

于 2013-08-21T07:14:57.457 回答
0

您似乎错过dbconfig/console.php.

于 2013-08-21T07:10:19.483 回答