Skip to content
Snippets Groups Projects
Commit d8fca4d4 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Added support for bindings in the query functions.

Rev: lib/modules/Sql.pmod/sql.pike:1.20
parent 7faf3caa
Branches
Tags
No related merge requests found
/* /*
* $Id: sql.pike,v 1.19 1998/03/20 21:55:14 grubba Exp $ * $Id: sql.pike,v 1.20 1998/06/17 12:41:37 grubba Exp $
* *
* Implements the generic parts of the SQL-interface * Implements the generic parts of the SQL-interface
* *
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
//. //.
//. File: sql.pike //. File: sql.pike
//. RCSID: $Id: sql.pike,v 1.19 1998/03/20 21:55:14 grubba Exp $ //. RCSID: $Id: sql.pike,v 1.20 1998/06/17 12:41:37 grubba Exp $
//. Author: Henrik Grubbström (grubba@idonex.se) //. Author: Henrik Grubbström (grubba@idonex.se)
//. //.
//. Synopsis: Implements the generic parts of the SQL-interface. //. Synopsis: Implements the generic parts of the SQL-interface.
...@@ -273,15 +273,24 @@ string|object compile_query(string q) ...@@ -273,15 +273,24 @@ string|object compile_query(string q)
//. > q //. > q
//. Query to send to the SQL-server. This can either be a string with the //. Query to send to the SQL-server. This can either be a string with the
//. query, or a previously compiled query (see compile_query()). //. query, or a previously compiled query (see compile_query()).
array(mapping(string:mixed)) query(object|string q) array(mapping(string:mixed)) query(object|string q,
mapping(string|int:mixed)|void bindings)
{ {
object res_obj; object res_obj;
if (functionp(master_sql->query)) { if (functionp(master_sql->query)) {
if (bindings) {
return(master_sql->query(q, bindings));
} else {
return(master_sql->query(q)); return(master_sql->query(q));
} }
}
if (bindings) {
return(res_obj_to_array(master_sql->big_query(q, bindings)));
} else {
return(res_obj_to_array(master_sql->big_query(q))); return(res_obj_to_array(master_sql->big_query(q)));
} }
}
//. - big_query //. - big_query
//. Send an SQL query to the underlying SQL-server. The result is returned //. Send an SQL query to the underlying SQL-server. The result is returned
...@@ -291,13 +300,21 @@ array(mapping(string:mixed)) query(object|string q) ...@@ -291,13 +300,21 @@ array(mapping(string:mixed)) query(object|string q)
//. > q //. > q
//. Query to send to the SQL-server. This can either be a string with the //. Query to send to the SQL-server. This can either be a string with the
//. query, or a previously compiled query (see compile_query()). //. query, or a previously compiled query (see compile_query()).
object big_query(object|string q) object big_query(object|string q, mapping(string|int:mixed)|void bindings)
{ {
if (functionp(master_sql->big_query)) { if (functionp(master_sql->big_query)) {
if (bindings) {
return(Sql.sql_result(master_sql->big_query(q, bindings)));
} else {
return(Sql.sql_result(master_sql->big_query(q))); return(Sql.sql_result(master_sql->big_query(q)));
} }
}
if (bindings) {
return(Sql.sql_result(master_sql->query(q, bindings)));
} else {
return(Sql.sql_result(master_sql->query(q))); return(Sql.sql_result(master_sql->query(q)));
} }
}
//. - create_db //. - create_db
//. Create a new database. //. Create a new database.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment