问题描述
这里对下面的部分进行了排序,但是现在插入记录时出现了问题.我将file
的NULL
值格式化为字符串的%s
,但它没有插入NULL
,而是插入了[BLOB - 0B]
. mySQL表中的列格式为longblob
.有什么想法吗?
Got the lower portion here sorted, but now there's an issue when it inserts the record. I have the NULL
value for file
formatted as %s
for string, but it's not inserting NULL
it's inserting [BLOB - 0B]
. The column format in the mySQL table is longblob
. Any ideas?
这是我第一次使用$wpdb->insert
,看来我错过了一些东西.
this is my first time using $wpdb->insert
and it looks like I've missed something.
这是我要使用的循环.当前,数组中有2个时间戳.
Here's the loop I'm trying to use. There are currently 2 timestamps in the array.
for ( $i = 0; $i < count($timestamps); $i++ ) {
$working_time = $timestamps[$i];
$working_form = $formnames[$i];
$status_data = array(
'submit_time' => $working_time,
'form_name' => $working_form,
'field_name' => 'lead_status',
'field_value' => 'new',
'field_order' => 10001,
'file' => NULL
);
$status_data_types = array(
'%f',
'%s',
'%s',
'%s',
'%d',
'%s'
);
$result = $wpdb->get_results("SELECT field_value FROM ".$leadtable." WHERE submit_time = ".$working_time);
if(!$result) {
$insert = $wpdb->insert($leadtable, $status_data, $status_data_types);
if( !$insert ) {
echo 'didn\'t work';
}
}
}
我知道$working_time
和$working_form
都已正确设置. $working_time
是长浮点,如1387175380.9600
,$working_form
是字符串.
I know that $working_time
and $working_form
are both set properly. $working_time
is a long float like 1387175380.9600
and $working_form
is a string.
即使通过if( !$insert )
检查也没有返回任何内容,所以我猜想它在该点之前出现了错误.我知道if( !$result )
将返回true,因为该数据尚不存在.
Nothing is being returned, even by the if( !$insert )
check so I'm guessing it's erring somewhere before that point. I know that if( !$result )
will return true because that data does not exist yet.
发现了问题.由于缺少时间段,get_results查询失败.我的HS英语老师说得对...错过课时可能是一个大问题!
Found the issue. The get_results query was failing due to a missed period. My HS English teacher was right... a missed period can be a HUGE problem!
推荐答案
也许您的配置隐藏了显示的错误.您是否尝试过$wpdb->print_error();
?
Maybe your config hides error showing. Have you tried $wpdb->print_error();
?
这篇关于$ wpdb->插入不起作用.没有错误讯息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!