connect_error) { throw new RuntimeException( 'Database connection failed: ' . $mysqli->connect_error ); } return $mysqli; }