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/Plugin.php b/Plugin.php index 85ba299..0420d52 100644 --- a/Plugin.php +++ b/Plugin.php @@ -5,10 +5,13 @@ * * @package Links * @author 懵仙兔兔 - * @version 1.2.7 + * @version 1.2.8 * @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('.' . __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('.' . __TYPECHO_PLUGIN_DIR__. '/Links/Update_' . $type . '.sql'); $scripts = str_replace('typecho_', $prefix, $scripts); $scripts = str_replace('%charset%', 'utf8', $scripts); $scripts = explode(';', $scripts); diff --git a/Update_Pgsql.sql b/Update_Pgsql.sql new file mode 100644 index 0000000..e69de29