0
這是我的類代碼:的mysqli - mysqli_stmt :: bind_param()預計將參考
class DAL
{
public function paramtypez($val)
{
$types = ''; //initial sting with types
foreach($val as $para)
{
if(is_int($para)) {
$types .= 'i'; //integer
} elseif (is_float($para)) {
$types .= 'd'; //double
} elseif (is_string($para)) {
$types .= 's'; //string
} else {
$types .= 'b'; //blob and unknown
}
}
return $types;
}
public function execsql($query,$param)
{
$conn=new mysqli("127.0.0.1","root","","sample");
if($row=$conn->prepare($query))
{
array_unshift($param,array(DAL::paramtypez($param)));
call_user_func_array(array($row, 'bind_param'), $param);
$row->execute();
return true;
}
else
return false;
}
}
,並使用這個類是這樣的:
$vars = new DAL();
$vars->execsql('insert into tesst (name,family,age) values(?,?,?)',array('mori','gre','25'));
但是這回我這個錯誤:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given in ..\htdocs\inc.php on line 30
如何解決這個錯誤? 感謝您的幫助
謝謝,但...警告:mysqli_stmt :: bind_param()預計參數1是字符串數組中inc.php給出上線31 – Nulled
你可能想看看http://ca.php.net/manual/en/mysqli-stmt.bind-param.php#96770 –