1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-10-24 20:36:06 +02:00

Allow for specification of database name, schema or other qualifier

This commit is contained in:
Marco
2018-08-28 22:03:40 +02:00
parent 2b3bf611e2
commit 521e73662d
3 changed files with 12 additions and 6 deletions

View File

@@ -45,6 +45,8 @@ abstract class UserManager {
/** @var PdoDatabase the database connection to operate on */
protected $db;
/** @var string|null the schema name for all database tables used by this component */
protected $dbSchema;
/** @var string the prefix for the names of all database tables used by this component */
protected $dbTablePrefix;
@@ -70,8 +72,9 @@ abstract class UserManager {
/**
* @param PdoDatabase|PdoDsn|\PDO $databaseConnection the database connection to operate on
* @param string|null $dbTablePrefix (optional) the prefix for the names of all database tables used by this component
* @param string|null $dbSchema (optional) the schema name for all database tables used by this component
*/
protected function __construct($databaseConnection, $dbTablePrefix = null) {
protected function __construct($databaseConnection, $dbTablePrefix = null, $dbSchema = null) {
if ($databaseConnection instanceof PdoDatabase) {
$this->db = $databaseConnection;
}
@@ -87,6 +90,7 @@ abstract class UserManager {
throw new \InvalidArgumentException('The database connection must be an instance of either `PdoDatabase`, `PdoDsn` or `PDO`');
}
$this->dbSchema = $dbSchema !== null ? (string) $dbSchema : null;
$this->dbTablePrefix = (string) $dbTablePrefix;
}