我正在处理下面的代码。如何以 JSON 格式导出一行的结果?
我试过这样
$arr = [];
$arr = $stmt->get_result()->fetch();
但我收到此错误:
未捕获的错误:调用未定义的方法 mysqli_stmt::get_result()
$stmt = $mysqli -> prepare('SELECT id, name, email, phone FROM users WHERE id = ?');
$userId = 1; // or $_GET['userId'];
$stmt -> bind_param('i', $userId);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($id, $name, $email, $phone);
$stmt -> fetch();
MMTTMM
侃侃无极
FFIVE