diff options
author | David M <davidmj@users.sourceforge.net> | 2006-08-06 05:52:41 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2006-08-06 05:52:41 +0000 |
commit | 2f901a520326b4d6941ef18fcfce0a9d5ef9cea5 (patch) | |
tree | 7ef08c7f0bedfed5f6a65278c8dc53194ac16d20 /phpBB/includes/db | |
parent | b4b901b82552e639cae00c4dc38542cf6fe2d873 (diff) | |
download | forums-2f901a520326b4d6941ef18fcfce0a9d5ef9cea5.tar forums-2f901a520326b4d6941ef18fcfce0a9d5ef9cea5.tar.gz forums-2f901a520326b4d6941ef18fcfce0a9d5ef9cea5.tar.bz2 forums-2f901a520326b4d6941ef18fcfce0a9d5ef9cea5.tar.xz forums-2f901a520326b4d6941ef18fcfce0a9d5ef9cea5.zip |
This should end some issues we have been having regarding the proper binary encoding of stuff. :D
Acyd Burn: quit breaking the schema :P
git-svn-id: file:///svn/phpbb/trunk@6238 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/db')
-rw-r--r-- | phpBB/includes/db/dbal.php | 32 | ||||
-rw-r--r-- | phpBB/includes/db/mssql.php | 8 | ||||
-rw-r--r-- | phpBB/includes/db/mssql_odbc.php | 8 | ||||
-rw-r--r-- | phpBB/includes/db/postgres.php | 19 | ||||
-rw-r--r-- | phpBB/includes/db/sqlite.php | 19 |
5 files changed, 81 insertions, 5 deletions
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index 8660c43546..dcf9947ddf 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -199,7 +199,14 @@ class dbal } else if (is_string($var)) { - $values[] = "'" . $this->sql_escape($var) . "'"; + if (strpos($key, 'bitfield') === false) + { + $values[] = "'" . $this->sql_escape($var) . "'"; + } + else + { + $values[] = $this->sql_escape_binary($var); + } } else if (is_array($var) && is_string($var[0])) { @@ -228,7 +235,14 @@ class dbal } else if (is_string($var)) { - $values[] = "'" . $this->sql_escape($var) . "'"; + if (strpos($key, 'bitfield') === false) + { + $values[] = "'" . $this->sql_escape($var) . "'"; + } + else + { + $values[] = $this->sql_escape_binary($var); + } } else { @@ -251,7 +265,14 @@ class dbal } else if (is_string($var)) { - $values[] = "$key = '" . $this->sql_escape($var) . "'"; + if (strpos($key, 'bitfield') === false) + { + $values[] = "$key = '" . $this->sql_escape($var) . "'"; + } + else + { + $values[] = "$key = " . $this->sql_escape_binary($var); + } } else { @@ -264,6 +285,11 @@ class dbal return $query; } + function sql_escape_binary($msg) + { + return "'" . $this->sql_escape($msg) . "'"; + } + /** * Build sql statement from array for select and select distinct statements * diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index 13a6fb8aab..0e8cc318f1 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -370,6 +370,14 @@ class dbal_mssql extends dbal } /** + * Escape string used in sql query + */ + function sql_escape_binary($msg) + { + return "CAST('" . $msg . "' AS varbinary)"; + } + + /** * return sql error array * @access: private */ diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index e1b2675a23..38ed91cd55 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -380,6 +380,14 @@ class dbal_mssql_odbc extends dbal } /** + * Escape string used in sql query + */ + function sql_escape_binary($msg) + { + return "CAST('" . $msg . "' AS varbinary)"; + } + + /** * Build db-specific query data * @access: private */ diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index c928a936d9..03fd5c17ce 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -258,7 +258,16 @@ class dbal_postgres extends dbal return $cache->sql_fetchrow($query_id); } - return ($query_id) ? @pg_fetch_assoc($query_id, NULL) : false; + $row = @pg_fetch_assoc($query_id, null); + if ($row) + { + foreach ($row as $key => $value) + { + $row[$key] = (strpos($key, 'bitfield') === false) ? $value : pg_unescape_bytea($value); + } + } + + return ($query_id) ? $row : false; } /** @@ -379,6 +388,14 @@ class dbal_postgres extends dbal } /** + * Escape string used in sql query + */ + function sql_escape_binary($msg) + { + return "'" . @pg_escape_bytea($msg) . "'"; + } + + /** * return sql error array * @access: private */ diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 8bea1a3198..c203af9f67 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -216,7 +216,16 @@ class dbal_sqlite extends dbal return $cache->sql_fetchrow($query_id); } - return ($query_id) ? @sqlite_fetch_array($query_id, SQLITE_ASSOC) : false; + $row = @sqlite_fetch_array($query_id, SQLITE_ASSOC); + if ($row) + { + foreach ($row as $key => $value) + { + $row[$key] = (strpos($key, 'bitfield') === false) ? $value : sqlite_udf_decode_binary($value); + } + } + + return $row; } /** @@ -308,6 +317,14 @@ class dbal_sqlite extends dbal } /** + * Escape string used in sql query + */ + function sql_escape_binary($msg) + { + return "'" . @sqlite_udf_encode_binary($msg) . "'"; + } + + /** * return sql error array * @access: private */ |