summaryrefslogtreecommitdiff
path: root/it_dbi_postgres.class
diff options
context:
space:
mode:
authorNathan Gass2021-01-27 12:23:52 +0100
committerNathan Gass2021-01-27 12:23:52 +0100
commit28ac1153604f962093594bcd9b44998636fadb9a (patch)
tree18eb11e572fa912af00aa9f39191ec2d4f3817d8 /it_dbi_postgres.class
parent904d3827bdc4b1647b3f7f90cfa93c41ad916c42 (diff)
downloaditools-28ac1153604f962093594bcd9b44998636fadb9a.tar.gz
itools-28ac1153604f962093594bcd9b44998636fadb9a.tar.bz2
itools-28ac1153604f962093594bcd9b44998636fadb9a.zip
fix boolean handling for postgresql
Diffstat (limited to 'it_dbi_postgres.class')
-rw-r--r--it_dbi_postgres.class9
1 files changed, 9 insertions, 0 deletions
diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class
index c26f5fc..2483ab9 100644
--- a/it_dbi_postgres.class
+++ b/it_dbi_postgres.class
@@ -54,6 +54,11 @@ function _tables($p = array())
return (array)$result;
}
+static function _convertbool($v)
+{
+ return $v == 't' ? true : false;
+}
+
function _get_field_defs()
{
list($table_name, $table_schema) = array_reverse(explode('.', $this->_p['table'], 2));
@@ -71,7 +76,11 @@ function _get_field_defs()
$res = $this->query('SELECT * FROM information_schema.columns AS t ' . $where);
while ($res && ($field = $this->_fetch_assoc($res)))
+ {
$result[$field['column_name']] = ['Field' => $field['column_name'], 'Type' => $field['data_type'], 'Extra' => it::match('^nextval\(', $field['column_default']) ? 'auto_increment' : '', 'Key' => $keys[$field['column_name']]];
+ if ($field['data_type'] == 'boolean')
+ $result[$field['column_name']] += ['_convertfunc' => 'it_dbi_postgres::_convertbool', '_escapefunc' => 'it_dbi::escape_bool'];
+ }
return $result;
}