代码点击器中的查询错误(错误转义) [英] Query error in code igniter ( wrong escape )
问题描述
我尝试在数组中的代码igniter的表中插入一行,但是出现了错误。
数组
(
[Date] => 2001-08-15
[Number] => 962883
[Time] => 17:40
[Etc1] => 0
[Etc2] => 0
)
并插入:
$ this - > db-> insert('mytable',$ myarray);
插入一行,但所有列都为空!
尝试找到错误,我打印最后一个查询
echo $ this-> db-> last_query()。< br>;
我有:
INSERT INTO`mytable`(`Date`,`Number`,`Time`,`Etc1`,`Etc2`)
VALUES
('\02\00 \00\01\0 -\00\08\0 -\01\05\0','\09\06\02\08\08\03 \0','\01\07\0:\04\00\0','\00\0','\00\0')
由于某种原因我无法获取,codeigniter(或PHP)错误地转义了值。
任何想法?
我试过模拟你的问题,
但我在这里粘贴了适用于我的代码:
$ data = array
(
'Date'=>'2001-08-15',
'Number'=>'962883',
' Time'=> '17:40',
'Etc1'=>'0',
'Etc2'=>'0'
);
$ this-> db-> insert('mytable',$ data);让我知道如果这个工作 - 如果没有,错误信息是什么。
I try to insert a row in the table on code igniter from a Array, but something is going wrong.
That's the array:
Array
(
[Date] => 2001-08-15
[Number] => 962883
[Time] => 17:40
[Etc1] => 0
[Etc2] => 0
)
And this the insert:
$this->db->insert('mytable', $myarray);
A new line is inserted, but all columns are empty!
Trying to find de error, I printed the last query by
echo $this->db->last_query() ." <br>";
And I got:
INSERT INTO `mytable` (`Date`, `Number`, `Time`, `Etc1`, `Etc2`)
VALUES
('\02\00\00\01\0-\00\08\0-\01\05\0', '\09\06\02\08\08\03\0', '\01\07\0:\04\00\0', '\00\0', '\00\0')
For some reason I can not get, the codeigniter ( or PHP ) is wrongly escaping the values.
Any Idea?
解决方案 I tried emulating your problem and was able to get the correct SQL statement genrated.
But I am pasting here the code that worked for me:
$data = array
(
'Date' => '2001-08-15',
'Number' => '962883',
'Time' => '17:40',
'Etc1' => '0',
'Etc2' => '0'
);
$this->db->insert('mytable', $data);
Let me know if this works - and if not, what the error message is.
这篇关于代码点击器中的查询错误(错误转义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!