Есть код как его правильно переписать в PDO?
if (!empty($_POST['email']) && !empty($_POST['apiKey'])) {
$conn = mysqli_connect("localhost", "root", "", "db_user");
$email = $POST['email'];
$apiKey = $_POST['apiKey'];
$result = array();
if ($db) {
$sql = "SELECT * FROM users WHERE email = '".$email."' AND apiKey = '".$apiKey."'";
$res = mysqli_query($db, $sql);
if (mysqli_num_rows($res) != 0) {
$row = mysqli_fetch_assoc($res);
$result = array("status"=>"success", "message"=>"Data fetched successfully", "login"=> $row['login'], "email"=> $row['email'], "apiKey"=> $row['apiKey']);
} else $result = array("status"=>"failed", "message"=>"Unauthorised access");
} else $result = array("status"=>"failed", "message"=>"Database connection failed");
} else $result = array("status"=>"failed", "message"=>"All fields are required");