Database wpdb插入null而不是字符串
我对wpdb有问题 我想在数据库中插入一些内容。查询如下所示:Database wpdb插入null而不是字符串,database,string,null,wordpress,Database,String,Null,Wordpress,我对wpdb有问题 我想在数据库中插入一些内容。查询如下所示: INSERT INTO `table` (`time`, `days_weekly`, `date`, `date_end`, `last_registration_type`, `last_registration`, `blocked_dates`, `length`, `post_id`) VALUES ('06:30:00', '{1,3}', 0, 0, 'hours', 5, 'a:1:{i:0;s:0:\"\";}',
INSERT INTO `table` (`time`, `days_weekly`, `date`, `date_end`, `last_registration_type`, `last_registration`, `blocked_dates`, `length`, `post_id`) VALUES ('06:30:00', '{1,3}', 0, 0, 'hours', 5, 'a:1:{i:0;s:0:\"\";}', '3', 1794)
结果如下:
“days_weekly”为空。为什么??
更新
插入查询:
由此:
$result = $wpdb->insert(
'ct_reservation_dates',
$insert,
$format
);
对此(当我在PHP中插入这段代码时,它可以工作,但与上面的代码不兼容):
注意,其他数据属性!
$insert的变量转储:
array(10) {
["time"]=>
string(8) "03:00:00"
["days_weekly"]=>
string(11) "{1,3,4,5}"
["date"]=>
int(1458601200)
["date_end"]=>
int(1466632800)
["last_registration_type"]=>
string(5) "hours"
["last_registration"]=>
string(1) "7"
["blocked_dates"]=>
string(61) "a:3:{i:0;s:0:"";i:1;s:10:"24.03.2016";i:2;s:10:"23.03.2016";}"
["length"]=>
string(1) "6"
["post_id"]=>
int(2142)
}
$format
的变量转储:
array(10) {
[0]=>
string(2) "%s"
[1]=>
string(2) "%s"
[2]=>
string(2) "%d"
[3]=>
string(2) "%d"
[4]=>
string(2) "%s"
[5]=>
string(2) "%d"
[7]=>
string(2) "%s"
[8]=>
string(2) "%s"
[9]=>
string(2) "%d"
}
如果您确实描述了表
显示为days\u weekly字段的数据类型是什么?days\u weekly
是一个长度为50的varchar字段。。。当我复制sql代码并在PHPMyAdmin上通过它时,它就工作了。但不是在wpdb上。你能发布你的实际wpdb代码吗?你的代码实际上对我来说没有任何问题;代码将{1,3}
插入字段。下面是我与构造的表一起运行的测试的最小pastebin:--您可以运行这样的最小测试来验证相同的错误行为吗?string(11)“{1,3,4,5}”
array(10) {
[0]=>
string(2) "%s"
[1]=>
string(2) "%s"
[2]=>
string(2) "%d"
[3]=>
string(2) "%d"
[4]=>
string(2) "%s"
[5]=>
string(2) "%d"
[7]=>
string(2) "%s"
[8]=>
string(2) "%s"
[9]=>
string(2) "%d"
}