Page MenuHomeDevCentral

D2513.id6338.diff
No OneTemporary

D2513.id6338.diff

diff --git a/src/Engines/WithSQLite.php b/src/Engines/WithSQLite.php
new file mode 100644
--- /dev/null
+++ b/src/Engines/WithSQLite.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Keruald\Database\Engines;
+
+trait WithSQLite {
+
+ public function isExistingTable (string $database, string $table) : bool {
+ $escapedTable = $this->escape($table);
+ $sql = "SHOW TABLE STATUS
+ FROM `$database`
+ WHERE Name = '$escapedTable'";
+
+ return $this->queryScalar($sql) === $table;
+ }
+
+ public function isView (string $database, string $view) : bool {
+ $escapedView = $this->escape($view);
+ $escapedDatabase = $this->escape($database);
+
+ $sql = <<<EOF
+SELECT type
+FROM sqlite_master
+WHERE TABLE_SCHEMA = "$escapedDatabase" AND TABLE_NAME = "$escapedView"
+EOF;
+
+ return $this->queryScalar($sql) === "VIEW";
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 12:30 (2 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2310621
Default Alt Text
D2513.id6338.diff (908 B)

Event Timeline