File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -904,6 +904,26 @@ public function __toString(): string
904904 return $ this ->getSql ();
905905 }
906906
907+ public function createView (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 NOT EXISTS " : "" ;
916+
917+ if (mb_strpos (mb_strtolower ($ this ->sql ), 'select ' ) === false ) {
918+ $ this ->setError ('No SELECT found in ' . __METHOD__ );
919+ return $ this ;
920+ }
921+
922+ $ this ->sql = "CREATE VIEW {$ exists }` {$ viewName }` AS " . $ this ->sql ;
923+
924+ return $ this ;
925+ }
926+
907927 public function dropView (string $ viewName , bool $ addExists = true )
908928 {
909929 // this method will be moved to another class
You can’t perform that action at this time.
0 commit comments