2019-01-12 17:43:06 +00:00
|
|
|
<?php
|
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-08-25 17:19:11 +00:00
|
|
|
namespace JKingWeb\Arsse\Test\DatabaseDrivers;
|
2019-01-12 17:43:06 +00:00
|
|
|
|
|
|
|
use JKingWeb\Arsse\Arsse;
|
|
|
|
|
|
|
|
trait MySQL {
|
2022-01-11 22:54:02 +00:00
|
|
|
use MySQLCommon;
|
|
|
|
|
2019-01-12 17:43:06 +00:00
|
|
|
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;
|
2019-01-14 04:17:19 +00:00
|
|
|
protected static $stringOutput = true;
|
2020-03-01 20:16:50 +00:00
|
|
|
|
2019-01-12 17:43:06 +00:00
|
|
|
public static function dbInterface() {
|
2020-10-30 16:16:03 +00:00
|
|
|
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);
|
2019-01-14 04:17:19 +00:00
|
|
|
if ($d->connect_errno) {
|
2020-10-30 16:16:03 +00:00
|
|
|
return null;
|
2019-01-14 04:17:19 +00:00
|
|
|
}
|
|
|
|
$d->set_charset("utf8mb4");
|
|
|
|
foreach (\JKingWeb\Arsse\Db\MySQL\PDODriver::makeSetupQueries() as $q) {
|
|
|
|
$d->query($q);
|
|
|
|
}
|
|
|
|
return $d;
|
2019-01-12 17:43:06 +00:00
|
|
|
}
|
|
|
|
}
|