gpt4 book ai didi

php - Dbforge 在 CodeIgniter 中导致错误编号 1064

转载 作者:行者123 更新时间:2023-11-29 12:59:39 24 4
gpt4 key购买 nike

我编写了这段代码,以便与 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;

我已经查找了与错误相关的原因,但除了 this link 之外,我找不到与我的问题相关的任何内容。 。如果有人能告诉我出了什么问题,我将不胜感激。

最佳答案

STRING 不是 MySQL 中的有效数据类型。我认为您正在寻找 CHARVARCHAR

关于php - Dbforge 在 CodeIgniter 中导致错误编号 1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23525456/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com