Fix minor error management

This commit is contained in:
Laurent Destailleur 2016-05-17 23:14:30 +02:00
parent 4e46a01d51
commit 753c5c7fc4
4 changed files with 65 additions and 41 deletions

View File

@ -192,9 +192,13 @@ class DoliDBMssql extends DoliDB
function getVersion() function getVersion()
{ {
$resql=$this->query("SELECT @@VERSION"); $resql=$this->query("SELECT @@VERSION");
if ($resql)
{
$version=$this->fetch_array($resql); $version=$this->fetch_array($resql);
return $version['computed']; return $version['computed'];
} }
else return '';
}
/** /**
* Return version of database client driver * Return version of database client driver
@ -203,10 +207,7 @@ class DoliDBMssql extends DoliDB
*/ */
function getDriverInfo() function getDriverInfo()
{ {
// FIXME: Dummy method return 'php mssql driver';
// TODO: Implement
return '';
} }
/** /**
@ -648,7 +649,7 @@ class DoliDBMssql extends DoliDB
function last_insert_id($tab,$fieldid='rowid') function last_insert_id($tab,$fieldid='rowid')
{ {
$res = $this->query("SELECT @@IDENTITY as id"); $res = $this->query("SELECT @@IDENTITY as id");
if ($data = $this->fetch_array($res)) if ($res && $data = $this->fetch_array($res))
{ {
return $data["id"]; return $data["id"];
} }
@ -709,9 +710,13 @@ class DoliDBMssql extends DoliDB
function DDLGetConnectId() function DDLGetConnectId()
{ {
$resql=$this->query('SELECT CONNECTION_ID()'); $resql=$this->query('SELECT CONNECTION_ID()');
if ($resql)
{
$row=$this->fetch_row($resql); $row=$this->fetch_row($resql);
return $row[0]; return $row[0];
} }
else return '?';
}
/** /**
* Create a new database * Create a new database

View File

@ -549,9 +549,13 @@ class DoliDBMysql extends DoliDB
function DDLGetConnectId() function DDLGetConnectId()
{ {
$resql=$this->query('SELECT CONNECTION_ID()'); $resql=$this->query('SELECT CONNECTION_ID()');
if ($resql)
{
$row=$this->fetch_row($resql); $row=$this->fetch_row($resql);
return $row[0]; return $row[0];
} }
else return '?';
}
/** /**

View File

@ -532,9 +532,13 @@ class DoliDBMysqli extends DoliDB
function DDLGetConnectId() function DDLGetConnectId()
{ {
$resql=$this->query('SELECT CONNECTION_ID()'); $resql=$this->query('SELECT CONNECTION_ID()');
if ($resql)
{
$row=$this->fetch_row($resql); $row=$this->fetch_row($resql);
return $row[0]; return $row[0];
} }
else return '?';
}
/** /**
* Create a new database * Create a new database

View File

@ -894,10 +894,13 @@ class DoliDBPgsql extends DoliDB
dol_syslog($sql,LOG_DEBUG); dol_syslog($sql,LOG_DEBUG);
$result = $this->query($sql); $result = $this->query($sql);
if ($result)
{
while($row = $this->fetch_row($result)) while($row = $this->fetch_row($result))
{ {
$infotables[] = $row; $infotables[] = $row;
} }
}
return $infotables; return $infotables;
} }
@ -1111,9 +1114,13 @@ class DoliDBPgsql extends DoliDB
function getDefaultCharacterSetDatabase() function getDefaultCharacterSetDatabase()
{ {
$resql=$this->query('SHOW SERVER_ENCODING'); $resql=$this->query('SHOW SERVER_ENCODING');
if ($resql)
{
$liste=$this->fetch_array($resql); $liste=$this->fetch_array($resql);
return $liste['server_encoding']; return $liste['server_encoding'];
} }
else return '';
}
/** /**
* Return list of available charset that can be used to store data in database * Return list of available charset that can be used to store data in database
@ -1148,9 +1155,13 @@ class DoliDBPgsql extends DoliDB
function getDefaultCollationDatabase() function getDefaultCollationDatabase()
{ {
$resql=$this->query('SHOW LC_COLLATE'); $resql=$this->query('SHOW LC_COLLATE');
if ($resql)
{
$liste=$this->fetch_array($resql); $liste=$this->fetch_array($resql);
return $liste['lc_collate']; return $liste['lc_collate'];
} }
else return '';
}
/** /**
* Return list of available collation that can be used for database * Return list of available collation that can be used for database