簡體   English   中英

無法通過YIIC Migreate創建來創建表

[英]Not able to create Table through YIIC Migreate create

我剛剛開始學習YII框架,現在在嘗試通過YIIC MIGRATE創建表時遇到了一個問題。 下面是我表的代碼。

class m140627_072906_create_test_table extends CDbMigration
{
   public function up()
   {
        $this->create('tbl_locations',
            array(
                'id'=>'pk',
                'location_name'=>'string NOT NULL',
                'create_time'=>'datetime NOT NULL',
                'create_user_id'=>'int(11) NOT NULL',
                'update_time'=>'datetime NOT NULL',
                'update_user_id'=>'int(11) NOT NULL',
            ), 'ENGINE=InnoDB'
        );
}
}
public function down()
{
    echo "m140627_072906_create_test_table does not support migration down.\n";
    return false;
}
}

我的項目在C:\\ wamp \\ www \\ bookmyroom \\下,下面是文件夾結構

C:\\ wamp \\ www \\ bookmyroom> dir驅動器C中的卷沒有標簽。 卷序列號是5291-FE18 C:\\ wamp \\ www \\ bookmyroom目錄

06/25/2014  08:58 PM    <DIR>          .
06/25/2014  08:58 PM    <DIR>          ..    
06/27/2014  12:32 PM    <DIR>          assets
06/25/2014  07:05 PM    <DIR>          css
06/25/2014  09:04 PM    <DIR>          framework
06/25/2014  07:05 PM    <DIR>          images
06/25/2014  07:05 PM               466 index-test.php
06/25/2014  09:10 PM               456 index.php
06/25/2014  07:08 PM    <DIR>          nbproject
06/25/2014  07:05 PM    <DIR>          protected
06/25/2014  07:05 PM    <DIR>          themes
               2 File(s)            922 bytes
               9 Dir(s)   8,986,624,000 bytes free

我在受保護的文件夾中運行了YIIC MIgrate命令。 運行遷移命令時出現以下錯誤。

C:\wamp\www\bookmyroom\protected>YIIC Migrate

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

Total 1 new migration to be applied:
m140627_074906_create_table_locations

Apply the above migration? (yes|no) [no]:y
*** applying m140627_074906_create_table_locations
exception 'CException' with message 'm140627_074906_create_table_locations and its    
behaviors do not have a method or closure named "create".' in 
C:\wamp\www\yii\framework\base\CComponent.php:266
Stack trace:
#0         
C:\wamp\www\bookmyroom\protected\migrations\m140627_074906_create_table_locations.php
(16): CComponent->__call('create', Array)
#1             
C:\wamp\www\bookmyroom\protected\migrations\m140627_074906_create_table_locations.php
(16): m140627_074906_create_table_locations->create('tbl_locat
ions', Array, 'ENGINE=InnoDB')
#2 C:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(385):            
m140627_074906_create_table_locations->up()
#3 C:\wamp\www\yii\framework\cli\commands\MigrateCommand.php(109): 
MigrateCommand->migrateUp('m140627_074906_...')
#4 [internal function]: MigrateCommand->actionUp(Array)
#5 C:\wamp\www\yii\framework\console\CConsoleCommand.php(172): 
ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)
#6 C:\wamp\www\yii\framework\console\CConsoleCommandRunner.php(71): 
CConsoleCommand->run(Array)
#7 C:\wamp\www\yii\framework\console\CConsoleApplication.php(92): 
CConsoleCommandRunner->run(Array)
#8 C:\wamp\www\yii\framework\base\CApplication.php(180): 
CConsoleApplication->processRequest()
#9 C:\wamp\www\yii\framework\yiic.php(33): CApplication->run()
#10 C:\wamp\www\bookmyroom\protected\yiic.php(7): require_once('C:\wamp\www\yii...')
#11 {main}

您能檢查一下並讓我知道我面臨的錯誤嗎? 如果有任何糾正要求,請告訴我。

嘗試使用執行

$this->execute("CREATE TABLE `tbl_locations` (
                'location_name'=>'string NOT NULL',
                'create_time'=>'datetime NOT NULL',
                'create_user_id'=>'int(11) NOT NULL',
                'update_time'=>'datetime NOT NULL',
                'update_user_id'=>'int(11) NOT NULL'
                PRIMARY KEY (`id`),
        ) ENGINE=InnoDB");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM