From 1d66d970321ccef7410613131ef4d8cec14df3a6 Mon Sep 17 00:00:00 2001 From: fhenry Date: Wed, 24 Oct 2012 11:20:40 +0200 Subject: [PATCH] Task 581 : Implement DDLInfoTable for postgreSQL --- htdocs/core/db/pgsql.class.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 4d4d95ea150..9b9f3bf4d11 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1025,23 +1025,35 @@ class DoliDBPgsql * * @param string $table Name of table * @return array Tableau des informations des champs de la table - * TODO modify for postgresql + * */ function DDLInfoTable($table) { - /* $infotables=array(); - $sql="SHOW FULL COLUMNS FROM ".$table.";"; + $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->pg_query($this->db,$sql); + $result = $this->query($sql); while($row = $this->fetch_row($result)) { $infotables[] = $row; - } - return $infotables; - */ + } + return $infotables; }