MySqli查询在phpmyadmin中工作,不适用于php脚本

时间:2016-01-09 06:09:57

标签: php mysql mysqli

我遇到了问题。

我尝试做简单的查询:

        $this->db->query("  INSERT INTO prognosis(stamp,day_ep,day_ep_sum,day_time,day_time_sum,week_ep,week_ep_sum,week_time,week_time_sum,month_ep,month_ep_sum,month_time,month_ep_sum,year_ep,year_ep_sum,year_time,year_time_sum)
                        VALUES('$stamp',$today_ep,$today_ep_sum,$today_time,$today_time_sum,$week_ep,$week_ep_sum,$week_time,$week_time_sum,$month_ep,$month_ep_sum,$month_time,$month_time_sum,$year_ep,$year_ep_sum,$year_time,$year_time_sum)
                    ");

...并且表仍然是空的,所以我使用echo打印带有html文件(meta charset = utf-8)值的完整查询:

INSERT INTO prognosis ( stamp, day_ep, day_ep_sum, day_time, day_time_sum, week_ep, week_ep_sum, week_time, week_time_sum, month_ep, month_ep_sum, month_time, month_time_sum, year_ep, year_ep_sum, year_time, year_time_sum ) VALUES ( '2016-01-09', 7, 5544, 318, 210948, 53, 5547, 2240, 211040, 289, 5744, 12844, 219835, 3366, 8822, 151232, 358223 )

ctrl + C,ctrl + V到phpmyadmin,表接受该查询(为什么?)

说明:

Array
(
[0] => Array
    (
        [Field] => id
        [Type] => int(11)
        [Null] => NO
        [Key] => PRI
        [Default] => 
        [Extra] => auto_increment
    )

[1] => Array
    (
        [Field] => stamp
        [Type] => date
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[2] => Array
    (
        [Field] => day_ep
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[3] => Array
    (
        [Field] => day_ep_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[4] => Array
    (
        [Field] => day_time
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[5] => Array
    (
        [Field] => day_time_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[6] => Array
    (
        [Field] => week_ep
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[7] => Array
    (
        [Field] => week_ep_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[8] => Array
    (
        [Field] => week_time
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[9] => Array
    (
        [Field] => week_time_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[10] => Array
    (
        [Field] => month_ep
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[11] => Array
    (
        [Field] => month_ep_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[12] => Array
    (
        [Field] => month_time
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[13] => Array
    (
        [Field] => month_time_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[14] => Array
    (
        [Field] => year_ep
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[15] => Array
    (
        [Field] => year_ep_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[16] => Array
    (
        [Field] => year_time
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

[17] => Array
    (
        [Field] => year_time_sum
        [Type] => int(11)
        [Null] => YES
        [Key] => 
        [Default] => 
        [Extra] => 
    )

我注意到有趣的事情: 当我试图找到该行为的原因时,我尝试执行更短的查询:

        $this->db->query("  INSERT INTO prognosis(stamp,year_ep,year_ep_sum,year_time,year_time_sum)
                        VALUES('$stamp',$year_ep,$year_ep_sum,$year_time,$year_time_sum)

并且它工作正常,但我必须执行完整版本的查询。

1 个答案:

答案 0 :(得分:-1)

请检查phpmyadmin中的Collaction Field,如果有任何选择,则设置为空白。