簡體   English   中英

dbforge在CodeIgniter中導致錯誤No 1064

[英]Dbforge causing error no 1064 in CodeIgniter

我已經在CodeIgniter中編寫了與Dbforge一起使用的這段代碼。

$fields = array(

                    'time_stamp' => array(
                                             'type' => 'STRING',
                                             'constraint' => 9,
                                              'null' => TRUE
                                      ),

                    'curr_property' => array(
                                             'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE
                                      ),

                    'curr_property_cost' => array(
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE
                                      ),

                    'day_property' => array(
                                             'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'day_property_cost' => array(
                                             'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'curr_solar_generating' => array(
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'curr_solar_export' => array(
                                             'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'day_solar_generated' => array(
                                               'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                     'day_solar_export' => array(
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'curr_chan1' => array(  
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE
                                      ),

                    'curr_chan2' => array(
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'curr_chan3' => array(
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'day_chan1' => array(
                                              'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'day_chan2' => array(
                                               'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      ),

                    'day_chan3' => array(
                                             'type' => 'INT',
                                             'constraint' => 5, 
                                             'unsigned' => TRUE,
                                             'auto_increment' => TRUE

                                      )

                );


                $this->dbforge->add_field($fields);

                $this->dbforge->create_table($this->table_name);

我不斷收到以下錯誤

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STRING(9) NULL, `curr_property` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr' at line 2

CREATE TABLE `admin_tmp` ( `time_stamp` STRING(9) NULL, `curr_property` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr_property_cost` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_property` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_property_cost` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr_solar_generating` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr_solar_export` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_solar_generated` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_solar_export` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr_chan1` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr_chan2` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `curr_chan3` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_chan1` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_chan2` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT, `day_chan3` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT ) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

我已經找到了與錯誤“否”相關的原因,但除了此鏈接之外,我找不到與我的問題有關的任何內容。 如果有人可以告訴我什么地方不對,將不勝感激。

在MySQL中, STRING不是有效的數據類型。 我認為您正在尋找CHARVARCHAR

暫無
暫無

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

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