2006-08-09
2006-08-09 14:59:43 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
16efb486118b8507ac18eb6cbdb07804dbcfe1c6
(32 lines)
(+28/-4)
[
Show
| Annotate
]
Branch: 7.9
Added support for operation in unicode mode.
Rev: lib/modules/Sql.pmod/mysql.pike:1.22
1:
/*
- * $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: Inside #if constant(Mysql.mysql)
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: Inside #if constant(Mysql.mysql)
//!
int|object big_query(string q, mapping(string|int:mixed)|void bindings)
{
- if (!bindings)
+ 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);
- return ::big_query(.sql_util.emulate_bindings(q,bindings,this));
+
}
197: Inside #if constant(Mysql.mysql)
>)[ 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) */