SQLite help
by Howard Dortch · in Torque 3D Professional · 06/01/2011 (12:41 pm) · 5 replies
I have a game crash on this query:
%query = "SELECT * FROM PlayerTable WHERE Name = '"@ $pref::player::name @"'" ;
If the name does not exist in the table the game crashes. I added the function below to try to trap the failure but game still crashes.
function playerdb::onQueryFailed(%this, %error)
{
echo ("SQLite Query Error: " @ %error);
}
Any help?
%query = "SELECT * FROM PlayerTable WHERE Name = '"@ $pref::player::name @"'" ;
If the name does not exist in the table the game crashes. I added the function below to try to trap the failure but game still crashes.
function playerdb::onQueryFailed(%this, %error)
{
echo ("SQLite Query Error: " @ %error);
}
Any help?
#2
06/01/2011 (4:17 pm)
Noting. I put an echo statement before and after. The one before hits, the one after does not. Even put echo just before the actual query and it hits and crashes.
#3
Since then I've moved all the sql code out of my game and just make web service calls, leaving the sql on the server side which is also more secure.
06/01/2011 (5:58 pm)
Which resource are you using? I used the ODBC resource and found that there were a number of returned types that it didn't handle properly. It would also return garbage instead of nulls. After mucking about with the source I was able to add the missing types but didn't have time to deal with the null issue.Since then I've moved all the sql code out of my game and just make web service calls, leaving the sql on the server side which is also more secure.
#4
I was able to get around this as follows:
idea is to check to see if the name is present and if so go get the username.
06/03/2011 (7:22 pm)
I've run into this same problem with MySQL. In MySQL when the value you are searching isn't in the table it returns nothing. I suspect SQLite does the same thing. It appears this is the problem.I was able to get around this as follows:
// Verify username exists in database, returning an empty result set will crash the engine
%mysql.Query ("SELECT IFNULL(count(usrname), 0) as Result FROM player WHERE usrname='"@%username@"'");
%result= %mysql.StoreResult();
%mysql.FetchRow (%result);
%usrcnt = %mysql.GetRowCell(%result, "Result");
%mysql.FreeResult (%result);
// Now look up password
if(%usrcnt)
{
%mysql.Query ("SELECT password FROM player WHERE usrname='"@%username@"'");idea is to check to see if the name is present and if so go get the username.
#5
This is what I have:
"SELECT * IFNULL(Name, 0) as Result FROM PlayerTable WHERE Name = '"@ $pref::player::name @"'" ;
06/10/2011 (11:37 am)
I keep getting SQLite Query Error: near "IFNULL": syntax errorThis is what I have:
"SELECT * IFNULL(Name, 0) as Result FROM PlayerTable WHERE Name = '"@ $pref::player::name @"'" ;
Torque 3D Owner Lunacy