diff --git a/PHPCI/Plugin/Pgsql.php b/PHPCI/Plugin/Pgsql.php new file mode 100644 index 00000000..89b60170 --- /dev/null +++ b/PHPCI/Plugin/Pgsql.php @@ -0,0 +1,46 @@ +phpci = $phpci; + $this->queries = $options; + + $buildSettings = $phpci->getConfig('build_settings'); + + if(isset($buildSettings['pgsql'])) { + $sql = $buildSettings['pgsql']; + $this->host = $sql['host']; + $this->user = $sql['user']; + $this->pass = $sql['pass']; + } + } + + public function execute() + { + try { + $pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); + + foreach($this->queries as $query) { + $pdo->query($query); + } + } + catch(\Exception $ex) { + $this->phpci->logFailure($ex->getMessage()); + return false; + } + + return true; + } +} \ No newline at end of file