mysqli&bound语句,2031:语句
|中没有数据。
这是我的代码,不起作用,不知道为什么:
$sql = `INSERT INTO `_translations` (id, module, item_id, name_id, output, language) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE output = ?`
$stmt = mysqli_prepare($this->connection, $sql);
$params = array($stmt, $types);
foreach($array as $k=>&$v){
$params[] =& $v;
}
// this call is update call, therefore parameters are merged
if($update && $_update) $params = array_merge($params, $_update);
call_user_func_array(\'mysqli_stmt_bind_param\', $params); # i think the problem is in this line..
if(mysqli_stmt_execute($stmt)){
if($this->transaction){ $this->affected++; }
else{ $this->affected = 1; }
}else{
$error = mysqli_stmt_error($stmt);
$errno = mysqli_stmt_errno($stmt);
die(\"{$sql}<br/><pre>\".var_export($params, true).\"</pre><br/>{$errno}: {$error}\");
}
1分表示:
INSERT INTO `_translations` (id, module, item_id, name_id, output, language) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE output = ?
array (
0 =>
mysqli_stmt::__set_state(array(
\'affected_rows\' => NULL,
\'insert_id\' => NULL,
\'num_rows\' => NULL,
\'param_count\' => NULL,
\'field_count\' => NULL,
\'errno\' => NULL,
\'error\' => NULL,
\'sqlstate\' => NULL,
\'id\' => NULL,
)),
1 => \'isissss\',
2 => \'\',
3 => \'seo\',
4 => \'\',
5 => \'keywords\',
6 => \'tesoutput\',
7 => \'en\',
8 => \'tesoutput\',
)
2031: No data supplied for parameters in prepared statement
好吧,类型计数等于参数,一切都应该正常工作,但事实并非如此。由于此功能可用于简单插入,因此我知道它可以工作...如果需要更多数据,请随时提出。
有什么办法吗?
提前致谢!
更新#1:
这是$ array,$ types和$ update打印输出。
附言在设置所有这三个变量之前,都有一条链,但是它们确实包含所需的内容!
// $array
array(6) {
[\"id\"]=>
string(0) \"\"
[\"module\"]=>
string(3) \"seo\"
[\"item_id\"]=>
string(0) \"\"
[\"name_id\"]=>
string(8) \"keywords\"
[\"output\"]=>
string(9) \"tesoutput\"
[\"language\"]=>
string(2) \"en\"
}
// $types
string(7) \"isissss\"
// $update
array(1) {
[0]=>
string(9) \"tesoutput\"
}
我已经认为问题可能出在$types
字符串而不是ma5ѭ值类型,因为那里的所有值都是字符串。不过,我不确定,因为在不进行更新的情况下插入就可以了,即使这些是字符串也是如此。
更新#2:
看来这是与版本相关的错误,驱动程序错误-http://bugs.php.net/bug.php?id=43568 ...任何人都设法使它与this7一起工作> 5.2
吗?而且,是的,在localhost上,我正在使用默认的ѭ9running驱动程序运行ѭ8where,在生产服务器上,PHP正在使用mysqlnd
运行版本5.3.5
。
没有找到相关结果
已邀请:
1 个回复
谦响局豢报
与:
呵呵,有趣的是5.2如何允许常量绑定,而5.3则不允许。无论如何,我很高兴我已经解决了这个问题,希望以后对其他人有帮助。 这实际上可以解释为什么
不管版本如何都可以工作...这些值开始时都使用参考变量填充。