Skip to content

Commit

Permalink
Fix: support MariDB
Browse files Browse the repository at this point in the history
Fix: support MariDB
  • Loading branch information
soxft committed Jul 22, 2024
2 parents 07c5df1 + 02c3ee3 commit 78567b1
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/CommentToMail.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*
* @package CommentToMail
* @author xcsoft
* @version 1.2.8
* @version 1.2.9
* @link https://xsot.cn
* @LastEditDate 20220213
* @LastEditDate 20240722
*/

if (!defined('__TYPECHO_ROOT_DIR__')) exit;
Expand Down Expand Up @@ -243,10 +243,18 @@ public static function personalConfig(\Typecho\Widget\Helper\Form $form)
public static function dbInstall()
{
$installDb = Db::get();
$type = array_pop(explode('_', $installDb->getAdapterName())); //数据库类型 mysql/sqlite/postgres

$adapter = explode('_', $installDb->getAdapterName());
$adapter_typ = array_pop($adapter); //数据库类型 mysql/sqlite/postgres
if ($adapter_typ == "Mysqli") $type = "Mysql";
$supported_adapter = ["Mysql", "Pgsql", "SQLite"];
if (!in_array($adapter_typ, $supported_adapter)) {
throw new \Typecho\Plugin\Exception('数据表建立失败, 不支持的数据库驱动, (仅支持 Mysql, SQLite, PgSQL)');
}

$prefix = $installDb->getPrefix(); //表前缀

$scripts = file_get_contents(__DIR__ . '/sql/' . $type . '.sql');
$scripts = file_get_contents(__DIR__ . '/sql/' . $adapter_typ . '.sql');
$scripts = str_replace('typecho_', $prefix, $scripts);
$scripts = str_replace('%charset%', 'utf8', $scripts);
$scripts = explode(';', $scripts);
Expand Down

0 comments on commit 78567b1

Please sign in to comment.