浏览代码

Update DB drivers

Visman 3 年之前
父节点
当前提交
cdea5ce590
共有 3 个文件被更改,包括 15 次插入12 次删除
  1. 4 4
      app/Core/DB/Mysql.php
  2. 4 4
      app/Core/DB/Pgsql.php
  3. 7 4
      app/Core/DB/Sqlite.php

+ 4 - 4
app/Core/DB/Mysql.php

@@ -69,7 +69,7 @@ class Mysql
      */
     public function __call(string $name, array $args)
     {
-        throw new PDOException("Method '{$name}' not found in DB driver.");
+        throw new PDOException("Method '{$name}' not found in DB driver");
     }
 
     /**
@@ -77,8 +77,8 @@ class Mysql
      */
     protected function nameCheck(string $str): void
     {
-        if (\preg_match('%[^a-zA-Z0-9_]%', $str)) {
-            throw new PDOException("Name '{$str}' have bad characters.");
+        if (\preg_match('%[^\w]%', $str)) {
+            throw new PDOException("Name '{$str}' have bad characters");
         }
     }
 
@@ -138,7 +138,7 @@ class Mysql
         } elseif (\is_bool($data)) {
             return $data ? 'true' : 'false';
         } else {
-            throw new PDOException('Invalid data type for DEFAULT.');
+            throw new PDOException('Invalid data type for DEFAULT');
         }
     }
 

+ 4 - 4
app/Core/DB/Pgsql.php

@@ -76,7 +76,7 @@ class Pgsql
      */
     public function __call(string $name, array $args)
     {
-        throw new PDOException("Method '{$name}' not found in DB driver.");
+        throw new PDOException("Method '{$name}' not found in DB driver");
     }
 
     /**
@@ -84,8 +84,8 @@ class Pgsql
      */
     protected function nameCheck(string $str): void
     {
-        if (\preg_match('%[^a-zA-Z0-9_]%', $str)) {
-            throw new PDOException("Name '{$str}' have bad characters.");
+        if (\preg_match('%[^\w]%', $str)) {
+            throw new PDOException("Name '{$str}' have bad characters");
         }
     }
 
@@ -145,7 +145,7 @@ class Pgsql
         } elseif (\is_bool($data)) {
             return $data ? 'true' : 'false';
         } else {
-            throw new PDOException('Invalid data type for DEFAULT.');
+            throw new PDOException('Invalid data type for DEFAULT');
         }
     }
 

+ 7 - 4
app/Core/DB/Sqlite.php

@@ -67,9 +67,12 @@ class Sqlite
      */
     public function __call(string $name, array $args)
     {
-        throw new PDOException("Method '{$name}' not found in DB driver.");
+        throw new PDOException("Method '{$name}' not found in DB driver");
     }
 
+    /**
+     * Проверяет минимально допустимую версию
+     */
     protected function vComp(string $version): bool
     {
         return \version_compare($this->db->getAttribute(PDO::ATTR_SERVER_VERSION), $version, '>=');
@@ -80,8 +83,8 @@ class Sqlite
      */
     protected function nameCheck(string $str): void
     {
-        if (\preg_match('%[^a-zA-Z0-9_]%', $str)) {
-            throw new PDOException("Name '{$str}' have bad characters.");
+        if (\preg_match('%[^\w]%', $str)) {
+            throw new PDOException("Name '{$str}' have bad characters");
         }
     }
 
@@ -141,7 +144,7 @@ class Sqlite
         } elseif (\is_bool($data)) {
             return $data ? 'true' : 'false';
         } else {
-            throw new PDOException('Invalid data type for DEFAULT.');
+            throw new PDOException('Invalid data type for DEFAULT');
         }
     }