Skip to content

Commit 78567b1

Browse files
authored
Fix: support MariDB
Fix: support MariDB
2 parents 07c5df1 + 02c3ee3 commit 78567b1

6 files changed

Lines changed: 64 additions & 4 deletions

File tree

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/CommentToMail.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php.xml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Plugin.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
*
1313
* @package CommentToMail
1414
* @author xcsoft
15-
* @version 1.2.8
15+
* @version 1.2.9
1616
* @link https://xsot.cn
17-
* @LastEditDate 20220213
17+
* @LastEditDate 20240722
1818
*/
1919

2020
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
@@ -243,10 +243,18 @@ public static function personalConfig(\Typecho\Widget\Helper\Form $form)
243243
public static function dbInstall()
244244
{
245245
$installDb = Db::get();
246-
$type = array_pop(explode('_', $installDb->getAdapterName())); //数据库类型 mysql/sqlite/postgres
246+
247+
$adapter = explode('_', $installDb->getAdapterName());
248+
$adapter_typ = array_pop($adapter); //数据库类型 mysql/sqlite/postgres
249+
if ($adapter_typ == "Mysqli") $type = "Mysql";
250+
$supported_adapter = ["Mysql", "Pgsql", "SQLite"];
251+
if (!in_array($adapter_typ, $supported_adapter)) {
252+
throw new \Typecho\Plugin\Exception('数据表建立失败, 不支持的数据库驱动, (仅支持 Mysql, SQLite, PgSQL)');
253+
}
254+
247255
$prefix = $installDb->getPrefix(); //表前缀
248256

249-
$scripts = file_get_contents(__DIR__ . '/sql/' . $type . '.sql');
257+
$scripts = file_get_contents(__DIR__ . '/sql/' . $adapter_typ . '.sql');
250258
$scripts = str_replace('typecho_', $prefix, $scripts);
251259
$scripts = str_replace('%charset%', 'utf8', $scripts);
252260
$scripts = explode(';', $scripts);

0 commit comments

Comments
 (0)