Merge branch 'views' into 'noglob'

creating views

See merge request composer/PHP_Library!9
This commit is contained in:
Федор Подлеснов 2023-03-31 15:40:43 +00:00
commit 9e176f3ae2

View file

@ -4,7 +4,7 @@ namespace ctiso\Database;
use ctiso\Database,
ctiso\Tools\SQLStatementExtractor,
ctiso\Path,
Exception;
Exception;
class Manager
{
@ -35,6 +35,9 @@ class Manager
case "renameColumn":
$this->RenameColumn($action["table"], $action["old_name"], $action["new_name"]);
break;
case "createView":
$this->recreateView($action["view"], $action["select"]);
break;
case "executeFile":
if ($this->db->isPostgres() && isset($action["pgsql"])) {
$file = $action["pgsql"];
@ -53,6 +56,12 @@ class Manager
}
}
//Дропает и создаёт SQL VIEW
public function recreateView($viewName, $selectStatement) {
$this->db->query("DROP VIEW ".$viewName);
$this->db->query("CREATE VIEW ".$viewName." AS ".$selectStatement);
}
public function DropTableQuery($table, $cascade=false) {
$statement = "DROP TABLE IF EXISTS ".$table;
if ($this->db->isPostgres()&&$cascade) {