diff --git a/src/Models/PropertyModel.php b/src/Models/PropertyModel.php index e4c3a6ce..7404ef2d 100644 --- a/src/Models/PropertyModel.php +++ b/src/Models/PropertyModel.php @@ -13,11 +13,9 @@ final class PropertyModel implements IModel static $allProperties; static $loaded; - static $database; public static function init() { - self::$database = Core::getDatabase(); self::$allProperties = null; self::$loaded = false; } @@ -37,7 +35,7 @@ final class PropertyModel implements IModel $stmt = Sql\Statements::select(); $stmt ->setColumn('*'); $stmt ->setTable('property'); - foreach (self::$database->fetchAll($stmt) as $row) + foreach (Core::getDatabase()->fetchAll($stmt) as $row) self::$allProperties[$row['prop_id']] = $row['value']; } @@ -52,13 +50,13 @@ final class PropertyModel implements IModel public static function set($propertyId, $value) { self::loadIfNecessary(); - self::$database->transaction(function() use ($propertyId, $value) + Core::getDatabase()->transaction(function() use ($propertyId, $value) { $stmt = Sql\Statements::select(); $stmt->setColumn('id'); $stmt->setTable('property'); $stmt->setCriterion(Sql\Functors::equals('prop_id', new Sql\Binding($propertyId))); - $row = self::$database->fetchOne($stmt); + $row = Core::getDatabase()->fetchOne($stmt); if ($row) { @@ -73,7 +71,7 @@ final class PropertyModel implements IModel $stmt->setTable('property'); $stmt->setColumn('value', new Sql\Binding($value)); - self::$database->execute($stmt); + Core::getDatabase()->execute($stmt); self::$allProperties[$propertyId] = $value; }); diff --git a/src/core.php b/src/core.php index 9812a698..adf93065 100644 --- a/src/core.php +++ b/src/core.php @@ -168,7 +168,7 @@ final class Core { try { - Core::getDatabase()->executeUnprepared(new \Chibi\Sql\RawStatement($query)); + Core::getDatabase()->executeUnprepared(\Chibi\Sql\Statements::raw($query)); } catch (Exception $e) { diff --git a/tests/SzurubooruTestRunner.php b/tests/SzurubooruTestRunner.php index 38ce0843..b30457b7 100644 --- a/tests/SzurubooruTestRunner.php +++ b/tests/SzurubooruTestRunner.php @@ -103,9 +103,9 @@ class SzurubooruTestRunner implements ITestRunner private function cleanMysqlDatabase() { $stmt = \Chibi\Sql\Statements::raw('DROP DATABASE IF EXISTS ' . $this->getMysqlDatabaseName()); - Core::getDatabase()->exec($stmt); + Core::getDatabase()->executeUnprepared($stmt); $stmt = \Chibi\Sql\Statements::raw('CREATE DATABASE ' . $this->getMysqlDatabaseName()); - Core::getDatabase()->exec($stmt); + Core::getDatabase()->executeUnprepared($stmt); } private function removeTestFolders()