From ad98a0d9d84b63804106f3d2859068f41e64e78e Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 30 Nov 2022 22:51:55 +0100 Subject: [PATCH] fix table name --- _admin.php | 4 ++-- _init.php | 20 ++++++++++++++++++++ _install.php | 2 +- inc/class.dc.aliases.php | 10 ++++------ 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 _init.php diff --git a/_admin.php b/_admin.php index 7903e36..cd79b56 100644 --- a/_admin.php +++ b/_admin.php @@ -30,13 +30,13 @@ dcCore::app()->addBehavior('exportSingleV2', function ($exp, $blog_id) { $exp->export( 'alias', 'SELECT alias_url, alias_destination, alias_position ' . - 'FROM ' . dcCore::app()->prefix . 'alias A ' . + 'FROM ' . dcCore::app()->prefix . initAlias::ALIAS_TABLE_NAME . ' A ' . "WHERE A.blog_id = '" . $blog_id . "'" ); }); dcCore::app()->addBehavior('importInitV2', function ($bk) { - $bk->cur_alias = dcCore::app()->con->openCursor(dcCore::app()->prefix . 'alias'); + $bk->cur_alias = dcCore::app()->con->openCursor(dcCore::app()->prefix . initAlias::ALIAS_TABLE_NAME); $bk->alias = new dcAliases(); $bk->aliases = $bk->alias->getAliases(); }); diff --git a/_init.php b/_init.php new file mode 100644 index 0000000..976a213 --- /dev/null +++ b/_init.php @@ -0,0 +1,20 @@ +getVersion('alias'), $version, '>=')) { try { $s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); - $s->alias + $s->{initAlias::ALIAS_TABLE_NAME} ->blog_id('varchar', 32, false) ->alias_url('varchar', 255, false) ->alias_destination('varchar', 255, false) diff --git a/inc/class.dc.aliases.php b/inc/class.dc.aliases.php index a5b6dcc..6e56eb6 100644 --- a/inc/class.dc.aliases.php +++ b/inc/class.dc.aliases.php @@ -16,8 +16,6 @@ if (!defined('DC_RC_PATH')) { class dcAliases { - public const ALIAS_TABLE_NAME = 'alias'; - protected $aliases; public function __construct() @@ -32,7 +30,7 @@ class dcAliases $this->aliases = []; $sql = 'SELECT alias_url, alias_destination, alias_position ' . - 'FROM ' . dcCore::app()->prefix . dcAliases::ALIAS_TABLE_NAME . ' ' . + 'FROM ' . dcCore::app()->prefix . initAlias::ALIAS_TABLE_NAME . ' ' . "WHERE blog_id = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' " . 'ORDER BY alias_position ASC '; $this->aliases = dcCore::app()->con->select($sql)->rows(); @@ -77,7 +75,7 @@ class dcAliases throw new Exception(__('Alias destination is empty.')); } - $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcAliases::ALIAS_TABLE_NAME); + $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . initAlias::ALIAS_TABLE_NAME); $cur->blog_id = (string) dcCore::app()->blog->id; $cur->alias_url = (string) $url; $cur->alias_destination = (string) $destination; @@ -88,7 +86,7 @@ class dcAliases public function deleteAlias($url) { dcCore::app()->con->execute( - 'DELETE FROM ' . dcCore::app()->prefix . dcAliases::ALIAS_TABLE_NAME . ' ' . + 'DELETE FROM ' . dcCore::app()->prefix . initAlias::ALIAS_TABLE_NAME . ' ' . "WHERE blog_id = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' " . "AND alias_url = '" . dcCore::app()->con->escape($url) . "' " ); @@ -97,7 +95,7 @@ class dcAliases public function deleteAliases() { dcCore::app()->con->execute( - 'DELETE FROM ' . dcCore::app()->prefix . dcAliases::ALIAS_TABLE_NAME . ' ' . + 'DELETE FROM ' . dcCore::app()->prefix . initAlias::ALIAS_TABLE_NAME . ' ' . "WHERE blog_id = '" . dcCore::app()->con->escape(dcCore::app()->blog->id) . "' " ); }