Skip to content

Commit

Permalink
create
Browse files Browse the repository at this point in the history
  • Loading branch information
mathsgod committed Oct 14, 2022
1 parent 6342ecf commit a0f0c4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
13 changes: 1 addition & 12 deletions src/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,7 @@ static function SetSchema(Schema $schema)
static function GetSchema()
{
if (self::$_schema == null) {

//load from .env
$dotenv = \Dotenv\Dotenv::createImmutable(getcwd());
$dotenv->load();

$host = $_ENV["DATABASE_HOSTNAME"];
$name = $_ENV["DATABASE_DATABASE"];
$port = $_ENV["DATABASE_PORT"] ?? 3306;
$username = $_ENV["DATABASE_USERNAME"];
$password = $_ENV["DATABASE_PASSWORD"];
$charset = $_ENV["DATABASE_CHARSET"] ?? "utf8mb4";
self::$_schema = new Schema($name, $host, $username, $password, $charset, $port);
self::$_schema = Schema::Create();
}
return self::$_schema;
}
Expand Down
15 changes: 15 additions & 0 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ public function __construct(string $database, string $hostname, string $username
]);
}

static function Create()
{
//load from .env
$dotenv = \Dotenv\Dotenv::createImmutable(getcwd());
$dotenv->load();

$host = $_ENV["DATABASE_HOSTNAME"];
$name = $_ENV["DATABASE_DATABASE"];
$port = $_ENV["DATABASE_PORT"] ?? 3306;
$username = $_ENV["DATABASE_USERNAME"];
$password = $_ENV["DATABASE_PASSWORD"];
$charset = $_ENV["DATABASE_CHARSET"] ?? "utf8mb4";
return new Schema($name, $host, $username, $password, $charset, $port);
}

function beginTransaction(): bool
{
$this->in_transaction = true;
Expand Down

0 comments on commit a0f0c4d

Please sign in to comment.