diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index 0be65dfe2e6..2df3e341452 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -192,8 +192,12 @@ class DoliDBMssql extends DoliDB function getVersion() { $resql=$this->query("SELECT @@VERSION"); - $version=$this->fetch_array($resql); - return $version['computed']; + if ($resql) + { + $version=$this->fetch_array($resql); + return $version['computed']; + } + else return ''; } /** @@ -203,10 +207,7 @@ class DoliDBMssql extends DoliDB */ function getDriverInfo() { - // FIXME: Dummy method - // TODO: Implement - - return ''; + return 'php mssql driver'; } /** @@ -648,7 +649,7 @@ class DoliDBMssql extends DoliDB function last_insert_id($tab,$fieldid='rowid') { $res = $this->query("SELECT @@IDENTITY as id"); - if ($data = $this->fetch_array($res)) + if ($res && $data = $this->fetch_array($res)) { return $data["id"]; } @@ -709,8 +710,12 @@ class DoliDBMssql extends DoliDB function DDLGetConnectId() { $resql=$this->query('SELECT CONNECTION_ID()'); - $row=$this->fetch_row($resql); - return $row[0]; + if ($resql) + { + $row=$this->fetch_row($resql); + return $row[0]; + } + else return '?'; } /** diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 34a7ebdf9f5..a92bb09e0b3 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -549,8 +549,12 @@ class DoliDBMysql extends DoliDB function DDLGetConnectId() { $resql=$this->query('SELECT CONNECTION_ID()'); - $row=$this->fetch_row($resql); - return $row[0]; + if ($resql) + { + $row=$this->fetch_row($resql); + return $row[0]; + } + else return '?'; } diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index d21caecea36..b6df8420490 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -532,8 +532,12 @@ class DoliDBMysqli extends DoliDB function DDLGetConnectId() { $resql=$this->query('SELECT CONNECTION_ID()'); - $row=$this->fetch_row($resql); - return $row[0]; + if ($resql) + { + $row=$this->fetch_row($resql); + return $row[0]; + } + else return '?'; } /** diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 048ef2d450d..c8b72ebcdd9 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -874,31 +874,34 @@ class DoliDBPgsql extends DoliDB */ function DDLInfoTable($table) { - $infotables=array(); + $infotables=array(); - $sql="SELECT "; - $sql.=" infcol.column_name as \"Column\","; - $sql.=" CASE WHEN infcol.character_maximum_length IS NOT NULL THEN infcol.udt_name || '('||infcol.character_maximum_length||')'"; - $sql.=" ELSE infcol.udt_name"; - $sql.=" END as \"Type\","; - $sql.=" infcol.collation_name as \"Collation\","; - $sql.=" infcol.is_nullable as \"Null\","; - $sql.=" '' as \"Key\","; - $sql.=" infcol.column_default as \"Default\","; - $sql.=" '' as \"Extra\","; - $sql.=" '' as \"Privileges\""; - $sql.=" FROM information_schema.columns infcol"; - $sql.=" WHERE table_schema='public' "; - $sql.=" AND table_name='".$table."'"; - $sql.=" ORDER BY ordinal_position;"; + $sql="SELECT "; + $sql.=" infcol.column_name as \"Column\","; + $sql.=" CASE WHEN infcol.character_maximum_length IS NOT NULL THEN infcol.udt_name || '('||infcol.character_maximum_length||')'"; + $sql.=" ELSE infcol.udt_name"; + $sql.=" END as \"Type\","; + $sql.=" infcol.collation_name as \"Collation\","; + $sql.=" infcol.is_nullable as \"Null\","; + $sql.=" '' as \"Key\","; + $sql.=" infcol.column_default as \"Default\","; + $sql.=" '' as \"Extra\","; + $sql.=" '' as \"Privileges\""; + $sql.=" FROM information_schema.columns infcol"; + $sql.=" WHERE table_schema='public' "; + $sql.=" AND table_name='".$table."'"; + $sql.=" ORDER BY ordinal_position;"; - dol_syslog($sql,LOG_DEBUG); - $result = $this->query($sql); - while($row = $this->fetch_row($result)) - { - $infotables[] = $row; - } - return $infotables; + dol_syslog($sql,LOG_DEBUG); + $result = $this->query($sql); + if ($result) + { + while($row = $this->fetch_row($result)) + { + $infotables[] = $row; + } + } + return $infotables; } @@ -1111,8 +1114,12 @@ class DoliDBPgsql extends DoliDB function getDefaultCharacterSetDatabase() { $resql=$this->query('SHOW SERVER_ENCODING'); - $liste=$this->fetch_array($resql); - return $liste['server_encoding']; + if ($resql) + { + $liste=$this->fetch_array($resql); + return $liste['server_encoding']; + } + else return ''; } /** @@ -1127,7 +1134,7 @@ class DoliDBPgsql extends DoliDB if ($resql) { $i = 0; - while ($obj = $this->fetch_object($resql) ) + while ($obj = $this->fetch_object($resql)) { $liste[$i]['charset'] = $obj->server_encoding; $liste[$i]['description'] = 'Default database charset'; @@ -1148,8 +1155,12 @@ class DoliDBPgsql extends DoliDB function getDefaultCollationDatabase() { $resql=$this->query('SHOW LC_COLLATE'); - $liste=$this->fetch_array($resql); - return $liste['lc_collate']; + if ($resql) + { + $liste=$this->fetch_array($resql); + return $liste['lc_collate']; + } + else return ''; } /**