- * Throws an exception if the table is not found.
- *
- * @param string $name Name of the table to get
- *
- * @return TableDef tabledef for that table.
- */
-
- public function getTableDef($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());
- }
-
- $td = new TableDef();
-
- $td->name = $name;
- $td->columns = array();
-
- $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'];
-
- $packed = $row['type'];
-
- if (preg_match('/^(\w+)\((\d+)\)$/', $packed, $match)) {