Page MenuHomeDevCentral

D2513.diff
No OneTemporary

D2513.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
Sat, Nov 23, 08:05 (13 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2257542
Default Alt Text
D2513.diff (908 B)

Event Timeline