diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-11-08 17:26:27 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-11-08 17:30:17 +0100 |
commit | ba3ee3e41cdaf591f9cb1aeb1f6ff5aa83285d1d (patch) | |
tree | a26db25e93d76ab6f92bd90d352d63c8ec38eb9e /ratatoeskr | |
parent | dfa766f738959f0e857c26e7b8336e76db493c73 (diff) | |
download | ratatoeskr-cms-ba3ee3e41cdaf591f9cb1aeb1f6ff5aa83285d1d.tar.gz ratatoeskr-cms-ba3ee3e41cdaf591f9cb1aeb1f6ff5aa83285d1d.tar.bz2 ratatoeskr-cms-ba3ee3e41cdaf591f9cb1aeb1f6ff5aa83285d1d.zip |
Remove last qdb() usage! \(^.^)/
Diffstat (limited to 'ratatoeskr')
-rw-r--r-- | ratatoeskr/setup/create_tables.php | 15 | ||||
-rw-r--r-- | ratatoeskr/sys/db.php | 20 |
2 files changed, 9 insertions, 26 deletions
diff --git a/ratatoeskr/setup/create_tables.php b/ratatoeskr/setup/create_tables.php index 4898e84..e16647c 100644 --- a/ratatoeskr/setup/create_tables.php +++ b/ratatoeskr/setup/create_tables.php @@ -1,12 +1,17 @@ <?php +use r7r\cms\sys\Database; +use r7r\cms\sys\Env; + if (!defined("SETUP")) { die(); } require_once(dirname(__FILE__) . "/../sys/db.php"); -$sql_tables = <<<SQL +function create_mysql_tables(?Database $db = null): void +{ + $sql_tables = <<<SQL CREATE TABLE IF NOT EXISTS `PREFIX_articles` ( `id` int(11) NOT NULL AUTO_INCREMENT, `urlname` text COLLATE utf8_unicode_ci NOT NULL, @@ -164,16 +169,14 @@ CREATE TABLE IF NOT EXISTS `PREFIX_article_extradata` ( ) DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; SQL; -function create_mysql_tables() -{ - global $sql_tables; + $db = $db ?? Env::getGlobal()->database(); $queries = explode(";", $sql_tables); foreach ($queries as $q) { if (!empty($q)) { - qdb($q); + $db->query($q); } } - qdb("INSERT INTO `PREFIX_meta` (`key`, `value`) VALUES ('dbversion', ?)", base64_encode(serialize(1))); + $db->query("INSERT INTO `PREFIX_meta` (`key`, `value`) VALUES ('dbversion', ?)", base64_encode(serialize(1))); } diff --git a/ratatoeskr/sys/db.php b/ratatoeskr/sys/db.php index 9efa9ec..b4f2efb 100644 --- a/ratatoeskr/sys/db.php +++ b/ratatoeskr/sys/db.php @@ -10,28 +10,8 @@ * See "ratatoeskr/licenses/ratatoeskr" for more information. */ -use r7r\cms\sys\Database; -use r7r\cms\sys\Env; - if (!defined("SETUP")) { require_once(dirname(__FILE__) . "/../config.php"); } require_once(dirname(__FILE__) . "/utils.php"); - -/** - * Prepares statement (1st argument) like {@see Database::prepStmt()} and executes it with the remaining arguments. - * - * @param mixed ...$args - * @return PDOStatement - * - * @deprecated Use {@see Database::query()} instead. - */ -function qdb(...$args): PDOStatement -{ - if (count($args) < 1) { - throw new InvalidArgumentException("qdb needs at least 1 argument"); - } - - return Env::getGlobal()->database()->query((string)$args[0], ...array_slice($args, 1)); -} |