In what scenarios would it be more beneficial to use mysqli directly instead of using an abstraction layer like PDO in PHP development?

In scenarios where you need to work with MySQL-specific features or optimizations that are not supported by PDO, it may be more beneficial to use mysqli directly. Additionally, if you require a more low-level control over your database interactions or need to utilize advanced functionalities provided by the mysqli extension, using it directly would be more suitable.

<?php
$mysqli = new mysqli("localhost", "username", "password", "database");

if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

$sql = "SELECT * FROM table";
$result = $mysqli->query($sql);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {
        echo "Name: " . $row["name"] . "<br>";
    }
} else {
    echo "0 results";
}

$mysqli->close();
?>