Compare commits

..

No commits in common. "master" and "1.7.4" have entirely different histories.

2 changed files with 5 additions and 20 deletions

View file

@ -19,8 +19,6 @@
private const DEFAULT_USERNAME = "www-data";
private const DEFAULT_PASSWORD = "";
private static ?Database $instance = null;
/**
* Create a new Database instance from credentials
*
@ -46,16 +44,6 @@
$_ENV["mariadb"]["user"] = $username;
$_ENV["mariadb"]["pass"] = $password;
$_ENV["mariadb"]["db"] = $database;
self::$instance = null;
}
public static function instance(): static {
if (self::$instance) {
return self::$instance;
}
return new static();
}
/**
@ -68,8 +56,6 @@
$_ENV["mariadb"]["pass"],
$_ENV["mariadb"]["db"],
);
self::$instance = $this;
}
/**

View file

@ -15,8 +15,7 @@
abstract public int|string $id { get; }
public readonly Database $db;
protected readonly Database $db;
private bool $_resolved = false;
private bool $_isset;
private ?array $_row;
@ -27,7 +26,7 @@
* @param string $table The target database table
*/
protected static function create(string $table, array $values): bool {
return Database::instance()->from($table)->insert($values);
return new Database()->from($table)->insert($values);
}
/**
@ -42,7 +41,7 @@
public readonly array $columns,
public readonly array $where
) {
$this->db = Database::instance();
$this->db = new Database();
}
/**
@ -75,7 +74,7 @@
* @return bool Entity exists
*/
public function isset(): bool {
return $this->_isset ??= Database::instance()
return $this->_isset ??= new Database()
->from($this->table)
->where($this->where)
->limit(1)
@ -109,6 +108,6 @@
->where($this->where)
->update([$key => $value]);
return func_num_args() === 2 ? $value : $return;
return $return ?? $value;
}
}