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() function getVersion()
{ {
$resql=$this->query("SELECT @@VERSION"); $resql=$this->query("SELECT @@VERSION");
$version=$this->fetch_array($resql); if ($resql)
return $version['computed']; {
$version=$this->fetch_array($resql);
return $version['computed'];
}
else return '';
} }
/** /**
@ -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,8 +710,12 @@ class DoliDBMssql extends DoliDB
function DDLGetConnectId() function DDLGetConnectId()
{ {
$resql=$this->query('SELECT CONNECTION_ID()'); $resql=$this->query('SELECT CONNECTION_ID()');
$row=$this->fetch_row($resql); if ($resql)
return $row[0]; {
$row=$this->fetch_row($resql);
return $row[0];
}
else return '?';
} }
/** /**

View File

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

View File

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

View File

@ -874,31 +874,34 @@ class DoliDBPgsql extends DoliDB
*/ */
function DDLInfoTable($table) function DDLInfoTable($table)
{ {
$infotables=array(); $infotables=array();
$sql="SELECT "; $sql="SELECT ";
$sql.=" infcol.column_name as \"Column\","; $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.=" CASE WHEN infcol.character_maximum_length IS NOT NULL THEN infcol.udt_name || '('||infcol.character_maximum_length||')'";
$sql.=" ELSE infcol.udt_name"; $sql.=" ELSE infcol.udt_name";
$sql.=" END as \"Type\","; $sql.=" END as \"Type\",";
$sql.=" infcol.collation_name as \"Collation\","; $sql.=" infcol.collation_name as \"Collation\",";
$sql.=" infcol.is_nullable as \"Null\","; $sql.=" infcol.is_nullable as \"Null\",";
$sql.=" '' as \"Key\","; $sql.=" '' as \"Key\",";
$sql.=" infcol.column_default as \"Default\","; $sql.=" infcol.column_default as \"Default\",";
$sql.=" '' as \"Extra\","; $sql.=" '' as \"Extra\",";
$sql.=" '' as \"Privileges\""; $sql.=" '' as \"Privileges\"";
$sql.=" FROM information_schema.columns infcol"; $sql.=" FROM information_schema.columns infcol";
$sql.=" WHERE table_schema='public' "; $sql.=" WHERE table_schema='public' ";
$sql.=" AND table_name='".$table."'"; $sql.=" AND table_name='".$table."'";
$sql.=" ORDER BY ordinal_position;"; $sql.=" ORDER BY ordinal_position;";
dol_syslog($sql,LOG_DEBUG); dol_syslog($sql,LOG_DEBUG);
$result = $this->query($sql); $result = $this->query($sql);
while($row = $this->fetch_row($result)) if ($result)
{ {
$infotables[] = $row; while($row = $this->fetch_row($result))
} {
return $infotables; $infotables[] = $row;
}
}
return $infotables;
} }
@ -1111,8 +1114,12 @@ class DoliDBPgsql extends DoliDB
function getDefaultCharacterSetDatabase() function getDefaultCharacterSetDatabase()
{ {
$resql=$this->query('SHOW SERVER_ENCODING'); $resql=$this->query('SHOW SERVER_ENCODING');
$liste=$this->fetch_array($resql); if ($resql)
return $liste['server_encoding']; {
$liste=$this->fetch_array($resql);
return $liste['server_encoding'];
}
else return '';
} }
/** /**
@ -1127,7 +1134,7 @@ class DoliDBPgsql extends DoliDB
if ($resql) if ($resql)
{ {
$i = 0; $i = 0;
while ($obj = $this->fetch_object($resql) ) while ($obj = $this->fetch_object($resql))
{ {
$liste[$i]['charset'] = $obj->server_encoding; $liste[$i]['charset'] = $obj->server_encoding;
$liste[$i]['description'] = 'Default database charset'; $liste[$i]['description'] = 'Default database charset';
@ -1148,8 +1155,12 @@ class DoliDBPgsql extends DoliDB
function getDefaultCollationDatabase() function getDefaultCollationDatabase()
{ {
$resql=$this->query('SHOW LC_COLLATE'); $resql=$this->query('SHOW LC_COLLATE');
$liste=$this->fetch_array($resql); if ($resql)
return $liste['lc_collate']; {
$liste=$this->fetch_array($resql);
return $liste['lc_collate'];
}
else return '';
} }
/** /**