pike.git
/
lib
/
modules
/
Sql.pmod
/
sql_util.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Sql.pmod/sql_util.pmod:1:
/*
-
* $Id: sql_util.pmod,v 1.
12
2003
/
08
/
22
14
:
24
:
06
nilsson Exp $
+
* $Id: sql_util.pmod,v 1.
13
2005
/
04
/
10
03
:
38
:
54
nilsson Exp $
* * Some SQL utility functions. * They are kept here to avoid circular references. * * Henrik Grubbström 1999-07-01 */ #pike __REAL_VERSION__ //! Some SQL utility functions
pike.git/lib/modules/Sql.pmod/sql_util.pmod:40:
//! Optional mapping containing the variable bindings. Make sure that //! no confusion is possible in the query. If necessary, change the //! variables' names. string emulate_bindings(string query, mapping(string|int:mixed)|void bindings, void|object driver) { array(string)k, v; if (!bindings) return query; function my_quote=(driver&&driver->quote?driver->quote:quote);
-
v=
Array.
map(values(bindings),
+
v=map(values(bindings),
lambda(mixed m) { if(multisetp(m)) m = indices(m)[0]; return (stringp(m)? "'"+my_quote(m)+"'" : (string)m); }); // Throws if mapping key is empty string.
-
k=
Array.
map(indices(bindings),lambda(string s){
+
k=map(indices(bindings),lambda(string s){
return ( (stringp(s)&&s[0]==':') ? s : ":"+s); }); return replace(query,k,v); }