From fd0c980a4e6babd6672866146f9e59e81d070013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=9C=88?= <528kazusa@gmail.com> Date: Sun, 23 Jun 2024 18:03:24 +0800 Subject: [PATCH 1/4] Add postgres sql --- Pgsql.sql | 13 +++++++++++++ Update_Pgsql.sql | 0 2 files changed, 13 insertions(+) create mode 100644 Pgsql.sql create mode 100644 Update_Pgsql.sql diff --git a/Pgsql.sql b/Pgsql.sql new file mode 100644 index 0000000..4ddacf7 --- /dev/null +++ b/Pgsql.sql @@ -0,0 +1,13 @@ +CREATE TABLE + "typecho_links" ( + "lid" SERIAL PRIMARY KEY, -- 自动递增的主键 + "name" VARCHAR(50) DEFAULT NULL, -- links 名称 + "url" VARCHAR(200) DEFAULT NULL, -- links 网址 + "sort" VARCHAR(50) DEFAULT NULL, -- links 分类 + "email" VARCHAR(50) DEFAULT NULL, -- links 邮箱 + "image" VARCHAR(200) DEFAULT NULL, -- links 图片 + "description" VARCHAR(200) DEFAULT NULL, -- links 描述 + "user" VARCHAR(200) DEFAULT NULL, -- 自定义 + "state" INT DEFAULT 1, -- links 状态 + "order" INT DEFAULT 0 -- links 排序 + ); \ No newline at end of file diff --git a/Update_Pgsql.sql b/Update_Pgsql.sql new file mode 100644 index 0000000..e69de29 From ec496889364e1e6276fb912211efb33634b8e443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=9C=88?= <528kazusa@gmail.com> Date: Sun, 23 Jun 2024 19:24:51 +0800 Subject: [PATCH 2/4] Pgsql support --- Plugin.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Plugin.php b/Plugin.php index 85ba299..c0d7461 100644 --- a/Plugin.php +++ b/Plugin.php @@ -9,6 +9,9 @@ * @dependence 14.10.10-* * @link https://2dph.com * + * version 1.2.8 at 2024-06-24 by Ouroboros + * 添加了 Postgres 支持 + * * version 1.2.7 at 2024-06-21 by 泽泽社长 * 解决php8.2一处报错问题 * @@ -272,7 +275,8 @@ public static function linksInstall() $type = explode('_', $installDb->getAdapterName()); $type = array_pop($type); $prefix = $installDb->getPrefix(); - $scripts = file_get_contents('usr/plugins/Links/' . $type . '.sql'); + $scripts = file_get_contents(ltrim(__TYPECHO_PLUGIN_DIR__, '/') . '/Links/' . $type . '.sql'); + if (!$scripts) return '你的数据库' . $type . '尚不支持, 请提交 issues!'; $scripts = str_replace('typecho_', $prefix, $scripts); $scripts = str_replace('%charset%', 'utf8', $scripts); $scripts = explode(';', $scripts); @@ -287,7 +291,8 @@ public static function linksInstall() } catch (Typecho_Db_Exception $e) { $code = $e->getCode(); if (('Mysql' == $type && (1050 == $code || '42S01' == $code)) || - ('SQLite' == $type && ('HY000' == $code || 1 == $code)) + ('SQLite' == $type && ('HY000' == $code || 1 == $code)) || + ('Pgsql' == $type && '42P07' == $code) ) { try { $script = 'SELECT `lid`, `name`, `url`, `sort`, `email`, `image`, `description`, `user`, `state`, `order` from `' . $prefix . 'links`'; @@ -296,7 +301,8 @@ public static function linksInstall() } catch (Typecho_Db_Exception $e) { $code = $e->getCode(); if (('Mysql' == $type && (1054 == $code || '42S22' == $code)) || - ('SQLite' == $type && ('HY000' == $code || 1 == $code)) + ('SQLite' == $type && ('HY000' == $code || 1 == $code)) || + ('Pgsql' == $type && 42601 == $code) ) { return Links_Plugin::linksUpdate($installDb, $type, $prefix); } @@ -310,7 +316,7 @@ public static function linksInstall() public static function linksUpdate($installDb, $type, $prefix) { - $scripts = file_get_contents('usr/plugins/Links/Update_' . $type . '.sql'); + $scripts = file_get_contents(ltrim(__TYPECHO_PLUGIN_DIR__, '/') . '/Links/Update_' . $type . '.sql'); $scripts = str_replace('typecho_', $prefix, $scripts); $scripts = str_replace('%charset%', 'utf8', $scripts); $scripts = explode(';', $scripts); From 616a82757245c78ad71f4189f636518f15f40a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=9C=88?= <528kazusa@gmail.com> Date: Sun, 23 Jun 2024 19:28:25 +0800 Subject: [PATCH 3/4] Update version --- Plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugin.php b/Plugin.php index c0d7461..1534421 100644 --- a/Plugin.php +++ b/Plugin.php @@ -5,7 +5,7 @@ * * @package Links * @author 懵仙兔兔 - * @version 1.2.7 + * @version 1.2.8 * @dependence 14.10.10-* * @link https://2dph.com * From 8ea2867ca8c7294778c3cbb280d77b41e7619e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=9C=88?= <528kazusa@gmail.com> Date: Sun, 23 Jun 2024 20:22:20 +0800 Subject: [PATCH 4/4] Batter path --- Plugin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugin.php b/Plugin.php index 1534421..0420d52 100644 --- a/Plugin.php +++ b/Plugin.php @@ -275,7 +275,7 @@ public static function linksInstall() $type = explode('_', $installDb->getAdapterName()); $type = array_pop($type); $prefix = $installDb->getPrefix(); - $scripts = file_get_contents(ltrim(__TYPECHO_PLUGIN_DIR__, '/') . '/Links/' . $type . '.sql'); + $scripts = file_get_contents('.' . __TYPECHO_PLUGIN_DIR__. '/Links/' . $type . '.sql'); if (!$scripts) return '你的数据库' . $type . '尚不支持, 请提交 issues!'; $scripts = str_replace('typecho_', $prefix, $scripts); $scripts = str_replace('%charset%', 'utf8', $scripts); @@ -316,7 +316,7 @@ public static function linksInstall() public static function linksUpdate($installDb, $type, $prefix) { - $scripts = file_get_contents(ltrim(__TYPECHO_PLUGIN_DIR__, '/') . '/Links/Update_' . $type . '.sql'); + $scripts = file_get_contents('.' . __TYPECHO_PLUGIN_DIR__. '/Links/Update_' . $type . '.sql'); $scripts = str_replace('typecho_', $prefix, $scripts); $scripts = str_replace('%charset%', 'utf8', $scripts); $scripts = explode(';', $scripts);