07.10.2013, 12:19
Note: If you're using SQLite Improved, update to the latest version instead of using this include.
This is an include that makes db_query report errors when the server is running on Windows. It patches the db_query function to make this possible (I made sure it's ok to publish this).
Usage
You need amx_assembly. When you've downloaded it, simply put this before you use db_query:
Advanced usage
Warning
If you have filterscripts that use db_query, be sure to include this file in them, too.
Compatibility
This works only on Windows, on Linux it will simply not report errors. I've tested this on a few old SA-MP versions and it works on them, too. Unless the db_* functions are modified, it should work in future versions.
Example
Credits
Lots of credits goes to Zeex for making this all possible with amx_assembly.
Download
https://gist.github.com/oscar-broman/6866913
This is an include that makes db_query report errors when the server is running on Windows. It patches the db_query function to make this possible (I made sure it's ok to publish this).
Usage
You need amx_assembly. When you've downloaded it, simply put this before you use db_query:
pawn Код:
#include <db-errors>
pawn Код:
public OnSQLiteQueryError(error[]) {
printf("db_query error: %s", error);
// if you have crashdetect (and crashdetect.inc), you can see where the error happened:
PrintAmxBacktrace();
}
If you have filterscripts that use db_query, be sure to include this file in them, too.
Compatibility
This works only on Windows, on Linux it will simply not report errors. I've tested this on a few old SA-MP versions and it works on them, too. Unless the db_* functions are modified, it should work in future versions.
Example
pawn Код:
public OnFilterScriptInit() {
new DB:db = db_open("test.db");
// no such table: some_table
db_query(db, "SELECT * FROM some_table;");
// No error (or "table test already exists")
db_query(db, "CREATE TABLE test (a, b, c)");
// no such column name: name
db_query(db, "SELECT name FROM test");
// near "bla": syntax error
db_query(db, "SELECT test FRMO bla");
db_close(db);
}
Lots of credits goes to Zeex for making this all possible with amx_assembly.
Download
https://gist.github.com/oscar-broman/6866913