mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Work around MySQL stupidity
This commit is contained in:
parent
64ca5f1be0
commit
5cfa01f4d5
3 changed files with 11 additions and 2 deletions
|
@ -164,6 +164,8 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
|||
|
||||
protected function makeConnection(string $db, string $user, string $password, string $host, int $port, string $socket): void {
|
||||
$this->db = mysqli_init();
|
||||
$this->db->options(\MYSQLI_SET_CHARSET_NAME, "utf8mb4");
|
||||
$this->db->options(\MYSQLI_OPT_INT_AND_FLOAT_NATIVE, false);
|
||||
$this->db->options(\MYSQLI_OPT_CONNECT_TIMEOUT, ceil(Arsse::$conf->dbTimeoutConnect));
|
||||
@$this->db->real_connect($host, $user, $password, $db, $port, $socket);
|
||||
if ($this->db->connect_errno) {
|
||||
|
|
|
@ -324,11 +324,15 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
|||
}
|
||||
|
||||
public function assertResult(array $expected, Result $data): void {
|
||||
$data = $data->getAll();
|
||||
// stringify our expectations if necessary
|
||||
if (static::$stringOutput ?? false) {
|
||||
$expected = $this->stringify($expected);
|
||||
// MySQL is extra-special and mixes strings and integers, so we cast the data, too
|
||||
if ((static::$implementation ?? "") === "MySQL") {
|
||||
$data = $this->stringify($data);
|
||||
}
|
||||
}
|
||||
$data = $data->getAll();
|
||||
$this->assertCount(sizeof($expected), $data, "Number of result rows (".sizeof($data).") differs from number of expected rows (".sizeof($expected).")");
|
||||
if (sizeof($expected)) {
|
||||
// make sure the expectations are consistent
|
||||
|
|
|
@ -21,7 +21,10 @@ trait MySQL {
|
|||
if (!class_exists("mysqli")) {
|
||||
return null;
|
||||
}
|
||||
$d = @new \mysqli(Arsse::$conf->dbMySQLHost, Arsse::$conf->dbMySQLUser, Arsse::$conf->dbMySQLPass, Arsse::$conf->dbMySQLDb, Arsse::$conf->dbMySQLPort);
|
||||
$d = mysqli_init();
|
||||
$d->options(\MYSQLI_OPT_INT_AND_FLOAT_NATIVE, false);
|
||||
$d->options(\MYSQLI_SET_CHARSET_NAME, "utf8mb4");
|
||||
@$d->real_connect(Arsse::$conf->dbMySQLHost, Arsse::$conf->dbMySQLUser, Arsse::$conf->dbMySQLPass, Arsse::$conf->dbMySQLDb, Arsse::$conf->dbMySQLPort);
|
||||
if ($d->connect_errno) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue