我在数据库中创建查询函数:
function mysqli($query){
$mysqli = new mysqli('test','test','test','test');
if (mysqli_connect_errno()) {
printf("Bad connect: %s\n", mysqli_connect_error());
exit();
}
$result = $mysqli->query("SET NAMES utf8");
$result = $mysqli->query("set character_set_client='utf8'");
$result = $mysqli->query("set collation_connection='utf8_general_ci'");
$result = $mysqli->query($query);
$mysqli->close();
return $result;
};
在下一步中,我想计算受影响的行数。
为此,我制作:
$res2 = mysqli("INSERT INTO Table (name, value) VALUES ('$name', '$value')");
echo $res2->affected_rows;
但是我Notice: Trying to get property of non-object
上线了echo $res2->affected_rows;
如何计算affected_rows
?