1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-23 17:12:41 +00:00
Arsse/tests/lib/DatabaseDrivers/MySQL.php

42 lines
1.4 KiB
PHP
Raw Normal View History

<?php
/** @license MIT
* Copyright 2017 J. King, Dustin Wilson et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
2021-04-14 15:17:01 +00:00
namespace JKingWeb\Arsse\Test\DatabaseDrivers;
use JKingWeb\Arsse\Arsse;
trait MySQL {
2022-01-11 22:54:02 +00:00
use MySQLCommon;
protected static $implementation = "MySQL";
protected static $backend = "MySQL";
protected static $dbResultClass = \JKingWeb\Arsse\Db\MySQL\Result::class;
protected static $dbStatementClass = \JKingWeb\Arsse\Db\MySQL\Statement::class;
protected static $dbDriverClass = \JKingWeb\Arsse\Db\MySQL\Driver::class;
protected static $stringOutput = true;
2020-03-01 20:16:50 +00:00
public static function dbInterface() {
if (!class_exists("mysqli")) {
return null;
}
2022-01-11 22:54:02 +00:00
$drv = new \mysqli_driver;
$drv->report_mode = \MYSQLI_REPORT_OFF;
2021-03-02 16:04:21 +00:00
$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;
}
$d->set_charset("utf8mb4");
foreach (\JKingWeb\Arsse\Db\MySQL\PDODriver::makeSetupQueries() as $q) {
$d->query($q);
}
return $d;
}
}