Skip to content

Commit 924775f

Browse files
committed
add dropView() method
1 parent 68cb25b commit 924775f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/QueryBuilder.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,22 @@ public function __toString(): string
904904
return $this->getSql();
905905
}
906906

907+
public function dropView(string $viewName, bool $addExists = true)
908+
{
909+
// this method will be moved to another class
910+
if (empty($viewName)) {
911+
$this->setError('Empty $viewName in ' . __METHOD__);
912+
return $this;
913+
}
914+
915+
$exists = $addExists ? "IF EXISTS " : "";
916+
917+
$this->reset();
918+
$this->sql = "DROP VIEW {$exists}`{$viewName}`";
919+
920+
return $this;
921+
}
922+
907923
/**
908924
* @param string $table
909925
* @param bool $add_exists

0 commit comments

Comments
 (0)