What are the potential pitfalls of using a custom MySQLi class in PHP instead of the built-in object-oriented features?

When using a custom MySQLi class in PHP instead of the built-in object-oriented features, potential pitfalls include reinventing the wheel, lack of compatibility with existing codebases, and potential security vulnerabilities if not implemented correctly. To avoid these pitfalls, it's recommended to utilize the built-in object-oriented features provided by MySQLi for database operations.

// Using built-in object-oriented features of MySQLi
$mysqli = new mysqli("localhost", "username", "password", "database");

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

// Perform database operations using the object-oriented approach
$result = $mysqli->query("SELECT * FROM table");

// Fetch data from the result set
while ($row = $result->fetch_assoc()) {
    // Process data
}

$mysqli->close();