本文介绍了mysqli_stmt :: bind_param()类型定义字符串中的元素数与数字不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用mysqli_stmt::bind_param()
时遇到问题.
I have a problem with using mysqli_stmt::bind_param()
.
public function init($cards, $table, $seats) {
$operation = $this->operation($table, $seats);
return $this->insertCards($cards, $operation, count($cards));
}
public function operation($table, $seats) {
$operation = "insert into ".$table."(";
$values = "(";
for ($i = 0; $i < count($seats); $i++) {
$operation .= " cardsSeat".$seats[$i].",";
$values .= "?,";
}
$values .= "?,?,?)";
$operation .= " flop, turn, river) values ".$values;
return $operation;
}
public function insertCards($cards, $operation, $x) {
$insertCards = $this->spojenie->prepare($operation);
$refArray = array();
foreach ($cards as $key => $value) {
$refArray[$key] = &$cards[$key];
}
call_user_func_array(array($insertCards, 'bind_param'), $refArray);
$insertCards->execute();
return true;
}
推荐答案
已解决
-
字符串类型("sss ...");
string types ("sss...");
public function insertCards($cards, $operation, $x)
{
$types = "";
foreach($cards as $value)
$types .= "s";
$cards = array_merge(array($types),$cards);
$insertCards = $this->spojenie->prepare($operation);
$refArray = array();
foreach($cards as $key => $value) $refArray[$key] = &$cards[$key];
call_user_func_array(array($insertCards, 'bind_param'), $refArray);
$insertCards->execute();
return true;
}
这篇关于mysqli_stmt :: bind_param()类型定义字符串中的元素数与数字不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!