mirror of
https://codeberg.org/vlw/wp.git
synced 2026-02-26 03:51:58 +01:00
fix: pass static db credentials for Database::current()
This commit is contained in:
parent
cfe10401a3
commit
6658443836
1 changed files with 27 additions and 8 deletions
|
|
@ -5,11 +5,16 @@
|
|||
use Exception;
|
||||
use vlw\Scaffold\Database as DatabaseFramework;
|
||||
|
||||
require_once dirname(__DIR__, 2) . "/scaffold/src/Database/Database.php";
|
||||
|
||||
class Database extends DatabaseFramework {
|
||||
public static string $name = "";
|
||||
public static string $site_url = "";
|
||||
|
||||
private static string $prefix = "wp";
|
||||
private static string $hostname = "";
|
||||
private static string $username = "";
|
||||
private static string $password = "";
|
||||
|
||||
/**
|
||||
* Get a prefixed table name from the database
|
||||
|
|
@ -27,7 +32,13 @@
|
|||
* @return static
|
||||
*/
|
||||
public static function current(): static {
|
||||
return new static(self::$name, self::$prefix);
|
||||
return new static(
|
||||
self::$hostname,
|
||||
self::$username,
|
||||
self::$password,
|
||||
self::$name,
|
||||
self::$prefix
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -36,9 +47,17 @@
|
|||
* @param string $database
|
||||
* @param string|null $table_prefix
|
||||
*/
|
||||
public function __construct(string $database, ?string $table_prefix = null) {
|
||||
$env = parse_ini_file(dirname(__DIR__, 1) . "/.env.ini", process_sections: true);
|
||||
|
||||
public function __construct(
|
||||
string $hostname,
|
||||
string $username,
|
||||
string $password,
|
||||
string $database,
|
||||
?string $table_prefix = null
|
||||
) {
|
||||
self::$hostname = $hostname;
|
||||
self::$username = $username;
|
||||
self::$password = $password;
|
||||
self::$password = $password;
|
||||
self::$name = $database;
|
||||
|
||||
if ($table_prefix) {
|
||||
|
|
@ -46,10 +65,10 @@
|
|||
}
|
||||
|
||||
Database::set_credentials(
|
||||
$env["mariadb"]["host"],
|
||||
$env["mariadb"]["user"],
|
||||
$env["mariadb"]["pass"],
|
||||
self::$name
|
||||
$hostname,
|
||||
$username,
|
||||
$password,
|
||||
$database
|
||||
);
|
||||
|
||||
$this->set_site_url();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue