From b2eb9df89425d0d2b9650df55b4371df5e6e27fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bergstr=C3=B6m?= Date: Tue, 15 Feb 2005 20:50:15 +0000 Subject: [PATCH] Updated dbi_type() (added "sqlite") and added stock sqlite_table_exists(). --- plugins/include/dbi.inc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/plugins/include/dbi.inc b/plugins/include/dbi.inc index bbf9eaf9..21fd0079 100755 --- a/plugins/include/dbi.inc +++ b/plugins/include/dbi.inc @@ -87,7 +87,26 @@ native dbi_close(&Sql:_sql); native dbi_error(Sql:_sql, _error[], _len); /* Returns the type of database being used. So far: - * "mysql", "pgsql", "mssql" + * "mysql", "pgsql", "mssql", "sqlite" */ native dbi_type(_type[], _len); +/* This function can be used to found out if a table in a Sqlite database exists. + */ +stock bool:sqlite_table_exists(Sql:sql, table[]) { + new bool:exists + new query[128] + format(query, 127, "SELECT name FROM sqlite_master WHERE type='table' AND name='%s' LIMIT 1;", table) + + new Result:result = dbi_query(sql, query) + + if (dbi_nextrow(result)) + exists = true + else + exists = false + + if (result > RESULT_NONE) + dbi_free_result(result) + + return exists +} \ No newline at end of file