Следующий вызов дает ошибку "Warning: call_user_func_array() expects parameter 1 to be a valid callback, first array member is not a valid class name or object in ..."
function query($sql, $params = array()) {
if(!empty($params)) {
$stmt = $this->dbc->prepare($sql);
call_user_func_array(array($stmt, "bind_param"), $this->refValues($params));
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc())
$data[] = $row;
$stmt->free_result();
$stmt->close();
} else
$result = $this->dbc->query($sql);
return $data ? $data : $result;
}
function refValues($arr) {
if(strnatcmp(phpversion(),'5.3') >= 0) {
$refs = array();
foreach($arr as $key => $value)
$refs[$key] = &$arr[$key];
return $refs;
}
return $arr;
}
DB->query("INSERT INTO `codes` SET (`DATE`, `CODE`) VALUES (?, ?)", array("si", date("Y-m-d H:i:s"), $code));