diff options
author | Nathan Gass | 2025-02-18 16:20:51 +0100 |
---|---|---|
committer | Nathan Gass | 2025-02-18 16:20:51 +0100 |
commit | 2a4e493468d5337e7cfd2b3d04f9bb0943b56775 (patch) | |
tree | 08a02e8521ff8d54679f4c97e06f592e18bd7bcd /it_dbi_postgres.class | |
parent | 9e66b8954deb4e2d43cbfd45530430272a128796 (diff) | |
download | itools-2a4e493468d5337e7cfd2b3d04f9bb0943b56775.tar.gz itools-2a4e493468d5337e7cfd2b3d04f9bb0943b56775.tar.bz2 itools-2a4e493468d5337e7cfd2b3d04f9bb0943b56775.zip |
check for actual error result (-1) and handle mariadb default encoding
Diffstat (limited to 'it_dbi_postgres.class')
-rw-r--r-- | it_dbi_postgres.class | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class index e96a46d..6b60fb4 100644 --- a/it_dbi_postgres.class +++ b/it_dbi_postgres.class @@ -100,10 +100,12 @@ function _connect_db($p) { if ($result) { - # set charset used for this connection - if ($p['charset']) - if (!pg_set_client_encoding($result, $p['charset'])) - $this->_fatal("_connect(): can't set charset \"{$p['charset']}\""); + # set charset used for this connection (also change mariadb specific default utf8mb4 to utf8) + if ($p['charset']) { + $charset = $p['charset'] == 'utf8mb4' ? 'UNICODE' : $p['charset']; + if (pg_set_client_encoding($result, $charset) < 0) + $this->_fatal("_connect(): can't set charset \"$charset\""); + } } return [$result, $result ? '' : 'Could not connect']; |