From e4ec17ad60187325233565c57d529ec3d288e00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julio=20Cesar=20Laura=20Avenda=C3=B1o?= Date: Tue, 15 May 2018 12:31:51 -0400 Subject: [PATCH] HOR-4559 --- gulliver/system/class.phpSqlParser.php | 2 +- workflow/engine/classes/DbConnections.php | 18 ++------ workflow/engine/classes/Net.php | 54 ++++++++++++++++++----- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/gulliver/system/class.phpSqlParser.php b/gulliver/system/class.phpSqlParser.php index 0c0c1e941..eaa43187b 100644 --- a/gulliver/system/class.phpSqlParser.php +++ b/gulliver/system/class.phpSqlParser.php @@ -1103,7 +1103,7 @@ EOREGEX; */ private function process_expr_list ($tokens) { - $expr = ""; + $expr = []; $type = ""; $prev_token = ""; $skip_next = false; diff --git a/workflow/engine/classes/DbConnections.php b/workflow/engine/classes/DbConnections.php index ec8060fd9..22962ec0f 100644 --- a/workflow/engine/classes/DbConnections.php +++ b/workflow/engine/classes/DbConnections.php @@ -258,22 +258,10 @@ class DbConnections $dbServices = array ('mysql' => array ('id' => 'mysql','command' => 'mysqli_connect','name' => 'MySql' ),'pgsql' => array ('id' => 'pgsql','command' => 'pg_connect','name' => 'PostgreSql' - ),'mssql' => array ('id' => 'mssql','command' => 'mssql_connect','name' => 'Microsoft SQL Server' + ),'mssql' => array ('id' => 'mssql','command' => 'mssql_connect','name' => 'Microsoft SQL Server (mssql extension)' + ),'sqlsrv' => array ('id' => 'mssql','command' => 'sqlsrv_connect','name' => 'Microsoft SQL Server (sqlsrv extension)' ),'oracle' => array ('id' => 'oracle','command' => 'oci_connect','name' => 'Oracle' - ) - ); - /*, - 'informix'=> Array( - 'id' => 'informix', - 'command' => 'ifx_connect', - 'name' => 'Informix' - ), - 'sqlite' => Array( - 'id' => 'sqlite', - 'command' => 'sqlite_open', - 'name' => 'SQLite' - ) - */ + )); foreach ($dbServices as $service) { if (@function_exists($service['command'])) { diff --git a/workflow/engine/classes/Net.php b/workflow/engine/classes/Net.php index dd8e2232d..c410abeed 100644 --- a/workflow/engine/classes/Net.php +++ b/workflow/engine/classes/Net.php @@ -253,12 +253,27 @@ class Net break; case 'mssql': //todo - if ($this->db_instance != "") { - $str_port = ""; - $link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd); + if (!extension_loaded('sqlsrv')) { + if ($this->db_instance != "") { + $link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd); + } else { + $port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port; + $link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd); + } } else { - $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port; - $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); + if ($this->db_instance != "") { + $server = $this->ip . "\\" . $this->db_instance; + } else { + $server = $this->ip; + } + $port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ", " . $this->db_port; + $server .= $port; + $opt = [ + 'UID' => $this->db_user, + 'PWD' => $this->db_passwd, + 'Database' => $this->db_sourcename + ]; + $link = @sqlsrv_connect($server, $opt); } if ($link) { @@ -382,15 +397,32 @@ class Net } break; case 'mssql': - if ($this->db_instance != "") { - $str_port = ""; - $link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd); + if (!extension_loaded('sqlsrv')) { + if ($this->db_instance != "") { + $link = @mssql_connect($this->ip . "\\" . $this->db_instance, $this->db_user, $this->db_passwd); + } else { + $port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port; + $link = @mssql_connect($this->ip . $port, $this->db_user, $this->db_passwd); + } } else { - $str_port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ":" . $this->db_port; - $link = @mssql_connect($this->ip . $str_port, $this->db_user, $this->db_passwd); + if ($this->db_instance != "") { + $server = $this->ip . "\\" . $this->db_instance; + } else { + $server = $this->ip; + } + $port = (($this->db_port == "") || ($this->db_port == 0) || ($this->db_port == 1433)) ? "" : ", " . $this->db_port; + $server .= $port; + $opt = [ + 'UID' => $this->db_user, + 'PWD' => $this->db_passwd, + 'Database' => $this->db_sourcename + ]; + $link = $db = @sqlsrv_connect($server, $opt); } if ($link) { - $db = @mssql_select_db($this->db_sourcename, $link); + if (!extension_loaded('sqlsrv')) { + $db = @mssql_select_db($this->db_sourcename, $link); + } if ($db) { $stat->status = 'SUCCESS'; $this->errstr = "";