From 4f95899d2eb62e00569dca27eb6d244c555a322a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 10 Sep 2006 03:46:35 +0000 Subject: [PATCH] Added request am44580 (simple query w/ formatting) --- plugins/include/sqlx.inc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugins/include/sqlx.inc b/plugins/include/sqlx.inc index 1cac5cfd..e348320a 100644 --- a/plugins/include/sqlx.inc +++ b/plugins/include/sqlx.inc @@ -251,6 +251,31 @@ stock SQL_SimpleQuery(Handle:db, const query[], error[]="", maxlength=0, &rows=0 return 1 } +/** + * Use this for executing a query where you don't care about the result. + * Returns 0 on failure, 1 on success + */ +stock SQL_SimpleQueryFmt(Handle:db, error[]="", maxlength=0, &rows=0, const fmt[], ...) +{ + static query_buf[2048]; + vformat(query_buf, 2047, fmt, 6) + + new Handle:hQuery = SQL_PrepareQuery(db, "%s", query_buf); + + if (!SQL_Execute(hQuery)) + { + SQL_QueryError(hQuery, error, maxlength); + SQL_FreeHandle(hQuery) + return 0; + } + + rows = SQL_NumResults(hQuery) + + SQL_FreeHandle(hQuery); + + return 1 +} + /** * Use this for executing a query and not caring about the error. * Returns -1 on error, >=0 on success (with number of affected rows)