Mysqli_query准备好声明

时间:2018-02-09 08:17:49

标签: php mysqli

我是准备好的声明中的新手,这是使用过程的正确顺序吗?

$stmt=mysqli_stmt_init($conn);

mysqli_stmt_prepare($stmt, "SELECT user_id,username, password, user_type FROM user WHERE username=?");
mysqli_stmt_bind_param($stmt, "s", $user);
mysqli_stmt_execute($stmt);

mysqli_stmt_bind_result($stmt, $user_id, $user, $password, $user_type);
mysqli_stmt_store_result($stmt);

if($someCond){
   mysqli_stmt_fetch($stmt);
   mysqli_stmt_free_result($stmt);
}

mysqli_close($conn);

0 个答案:

没有答案