mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-05-16 05:07:34 +08:00
migrations boolean() -> smallInteger()
This commit is contained in:
@@ -3,7 +3,7 @@ namespace Nexus\Database;
|
||||
|
||||
interface DBInterface
|
||||
{
|
||||
public function connect($host, $username, $password, $database, $port);
|
||||
public function connect($host, $username, $password, $database, $port, $driver = 'mysql');
|
||||
|
||||
public function query(string $sql);
|
||||
|
||||
@@ -29,4 +29,4 @@ interface DBInterface
|
||||
|
||||
public function freeResult($result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class DBMysqli implements DBInterface
|
||||
{
|
||||
private $mysqli;
|
||||
|
||||
public function connect($host, $username, $password, $database, $port)
|
||||
public function connect($host, $username, $password, $database, $port, $driver = 'mysql')
|
||||
{
|
||||
$mysqli = new \mysqli($host, $username, $password, $database, $port);
|
||||
/* check connection */
|
||||
|
||||
@@ -8,10 +8,9 @@ class DBPdo implements DBInterface
|
||||
private $driver;
|
||||
private $lastStmt;
|
||||
|
||||
public function connect($host, $username, $password, $database, $port)
|
||||
public function connect($host, $username, $password, $database, $port, $driver = 'mysql')
|
||||
{
|
||||
$driver = $this->driver = nexus_config('nexus.database.default');
|
||||
|
||||
$this->driver = $driver;
|
||||
if ($driver === 'mysql') {
|
||||
$dsn = "mysql:host={$host};port={$port};dbname={$database};charset=utf8mb4";
|
||||
} elseif ($driver === 'pgsql') {
|
||||
|
||||
@@ -63,9 +63,9 @@ class NexusDB
|
||||
return self::$instance = $instance;
|
||||
}
|
||||
|
||||
public function connect($host, $username, $password, $database, $port)
|
||||
public function connect($host, $username, $password, $database, $port, $driver = 'mysql')
|
||||
{
|
||||
$result = $this->driver->connect($host, $username, $password, $database, $port);
|
||||
$result = $this->driver->connect($host, $username, $password, $database, $port, $driver);
|
||||
if (!$result) {
|
||||
throw new DatabaseException(sprintf('[%s]: %s', $this->errno(), $this->error()));
|
||||
}
|
||||
@@ -78,8 +78,9 @@ class NexusDB
|
||||
if ($this->isConnected()) {
|
||||
return null;
|
||||
}
|
||||
$config = nexus_config('nexus.mysql');
|
||||
return $this->connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port']);
|
||||
$dbType = self::getConnectionName();
|
||||
$config = nexus_config('nexus.database.connections.' . $dbType);
|
||||
return $this->connect($config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $dbType);
|
||||
}
|
||||
|
||||
public function query(string $sql)
|
||||
@@ -485,6 +486,4 @@ class NexusDB
|
||||
return $indexesNames;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
use Nexus\Database\NexusDB;
|
||||
|
||||
function mysql_connect($host, $username, $password, $database, $port)
|
||||
function mysql_connect($host, $username, $password, $database, $port, $driver = 'mysql')
|
||||
{
|
||||
return NexusDB::getInstance()->connect($host, $username, $password, $database, $port);
|
||||
return NexusDB::getInstance()->connect($host, $username, $password, $database, $port, $driver);
|
||||
}
|
||||
|
||||
function mysql_errno()
|
||||
|
||||
Reference in New Issue
Block a user