In what ways does transitioning from MySQL to MySQLi impact the object-oriented approach in PHP programming?

Transitioning from MySQL to MySQLi impacts the object-oriented approach in PHP programming by requiring a different set of functions and methods to interact with the database. MySQLi introduces a more secure and efficient way to handle database operations, making it necessary to update existing code to utilize the new features and functionality provided by MySQLi.

// MySQLi object-oriented approach
$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 "ID: " . $row["id"] . " - Name: " . $row["name"] . "<br>";
    }
} else {
    echo "0 results";
}

$mysqli->close();