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,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 '?';
}
/**

View File

@ -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 '?';
}

View File

@ -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 '?';
}
/**

View File

@ -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 '';
}
/**