I'm programming code with MySQLi prepared statements. I'm a beginner and just want to ask to experts if my code is correct.
function getPaymentMethodName( $id ) {
global $mysqli;
if ( $stmt = $mysqli->prepare( 'SELECT name FROM `payment_methods` WHERE id = ?' ) ) {
if ( $stmt->bind_param( 'i', $id ) ) {
if ( $stmt->execute() ) {
$stmt->bind_result( $name);
if ( $stmt->fetch() ) {
$stmt->close();
return $name;
}
}
}
}
$stmt->close();
return false;
}