diff options
-rw-r--r-- | config.php.sample | 2 | ||||
-rw-r--r-- | lib/schema.php | 19 |
2 files changed, 15 insertions, 6 deletions
diff --git a/config.php.sample b/config.php.sample index b8852dc67..2aa9326a4 100644 --- a/config.php.sample +++ b/config.php.sample @@ -200,7 +200,7 @@ $config['sphinx']['port'] = 3312; // // $config['twitterbridge']['enabled'] = true; -// Twitter OAuth settings +// Twitter OAuth settings. Documentation is at http://apiwiki.twitter.com/OAuth-FAQ // $config['twitter']['consumer_key'] = 'YOURKEY'; // $config['twitter']['consumer_secret'] = 'YOURSECRET'; diff --git a/lib/schema.php b/lib/schema.php index a7f64ebed..6292a3d56 100644 --- a/lib/schema.php +++ b/lib/schema.php @@ -94,7 +94,12 @@ class Schema public function getTableDef($name) { - $res = $this->conn->query('DESCRIBE ' . $name); + if(common_config('db','type') == 'pgsql') { + $res = $this->conn->query("select column_default as default, is_nullable as Null, udt_name as Type, column_name AS Field from INFORMATION_SCHEMA.COLUMNS where table_name = '$name'"); + } + else { + $res = $this->conn->query('DESCRIBE ' . $name); + } if (PEAR::isError($res)) { throw new Exception($res->getMessage()); @@ -108,12 +113,16 @@ class Schema $row = array(); while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { + //lower case the keys, because the php postgres driver is case insentive for column names + foreach($row as $k=>$v) { + $row[strtolower($k)] = $row[$k]; + } $cd = new ColumnDef(); - $cd->name = $row['Field']; + $cd->name = $row['field']; - $packed = $row['Type']; + $packed = $row['type']; if (preg_match('/^(\w+)\((\d+)\)$/', $packed, $match)) { $cd->type = $match[1]; @@ -122,9 +131,9 @@ class Schema $cd->type = $packed; } - $cd->nullable = ($row['Null'] == 'YES') ? true : false; + $cd->nullable = ($row['null'] == 'YES') ? true : false; $cd->key = $row['Key']; - $cd->default = $row['Default']; + $cd->default = $row['default']; $cd->extra = $row['Extra']; $td->columns[] = $cd; |