diff --git a/lib/modules/Sql.pmod/mysql.pike b/lib/modules/Sql.pmod/mysql.pike index 4ce93a3a44df87ca567bdf5e4018a3f037558126..a21d6a2ed915785f227ee781b413c04df3d5514e 100644 --- a/lib/modules/Sql.pmod/mysql.pike +++ b/lib/modules/Sql.pmod/mysql.pike @@ -1,5 +1,5 @@ /* - * $Id: mysql.pike,v 1.21 2004/04/16 12:12:46 grubba Exp $ + * $Id: mysql.pike,v 1.22 2006/08/09 14:59:43 grubba Exp $ * * Glue for the Mysql-module */ @@ -13,6 +13,9 @@ inherit Mysql.mysql; +//! Set to 1 if the connection is in utf8-mode. +static int unicode_mode; + #if constant( Mysql.mysql.MYSQL_NO_ADD_DROP_DB ) // Documented in the C-file. void create_db( string db ) @@ -147,9 +150,14 @@ int decode_datetime (string timestr) //! int|object big_query(string q, mapping(string|int:mixed)|void bindings) { - if (!bindings) - return ::big_query(q); - return ::big_query(.sql_util.emulate_bindings(q,bindings,this)); + if (bindings) + q = .sql_util.emulate_bindings(q,bindings,this); + if (unicode_mode) { + int|object res = ::big_query(string_to_utf8(q)); + if (!objectp(res)) return res; + return .sql_util.UnicodeWrapper(res); + } + return ::big_query(q); } @@ -197,6 +205,21 @@ int(0..1) is_keyword( string name ) >)[ lower_case(name) ]; } +static void create(string|void host, string|void database, + string|void user, string|void password, + mapping(string:string|int)|void options) +{ + if (options) { + ::create(host||"", database||"", user||"", password||"", options); + } else { + ::create(host||"", database||"", user||"", password||""); + } + catch { + big_query("SET NAMES 'utf8'"); + unicode_mode = 1; + }; +} + #else constant this_program_does_not_exist=1; #endif /* constant(Mysql.mysql) */