report_mode; $driver->report_mode = MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT; $flags = $enable_env_flags ? get_environment_connection_flags() : 0; if ($flags !== 0) { $link = mysqli_init(); mysqli_real_connect($link, $host, $user, $password, $db, $port, $socket, $flags); } else { /* TODO Investigate why on LINUX_X64_RELEASE_NTS CI pipeline * Warning: mysqli_connect(): php_network_getaddresses: getaddrinfo for mysql failed: * Temporary failure in name resolution in test_helpers.inc on line 91 */ $link = @mysqli_connect($host, $user, $password, $db, $port, $socket); } // Restore error mode $driver->report_mode = $report_mode; return $link; } function default_mysqli_connect(): \mysqli{ return my_mysqli_connect( get_default_host(), get_default_user(), get_default_password(), get_default_database(), get_default_port(), null, ); } function mysqli_check_skip_test(): void { mysqli_connect_or_skip(); } function mysqli_connect_or_skip() { try { return default_mysqli_connect(); } catch (\mysqli_sql_exception) { die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); } } function have_innodb(mysqli $link): bool { $res = $link->query("SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'InnoDB'"); $supported = $res->fetch_column(); return $supported === 'YES' || $supported === 'DEFAULT'; } function mysqli_check_innodb_support_skip_test(): void { try { $link = default_mysqli_connect(); } catch (\mysqli_sql_exception) { die(sprintf("skip Can't connect to MySQL Server - [%d] %s", mysqli_connect_errno(), mysqli_connect_error())); } if (! have_innodb($link)) { die(sprintf("skip Needs InnoDB support")); } } function tear_down_table_on_default_connection(string $table) { $link = default_mysqli_connect(); mysqli_query($link, 'DROP TABLE IF EXISTS ' . $table); } function setup_table_with_data_on_default_connection(string $table): mysqli { $link = default_mysqli_connect(); mysqli_query($link, 'SET SESSION sql_mode=\'\''); mysqli_query($link, 'CREATE TABLE '. $table .'(id INT DEFAULT 0, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . get_default_db_engine()); mysqli_query($link, 'INSERT INTO '. $table .'(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")'); return $link; } //$engine = getenv("MYSQL_TEST_ENGINE") ?: "InnoDB";