icedsun

executeSQLQuery()

Recommended Posts

The function executeSQLQuery() often sends bad data (odd symbols) and errors.

Here is a function that will allow you to reproduce the errors:

function serverLoadCustomObjects() 
    --executeSQLDropTable("worldObjects")   --(doesn't work!!!) 
    executeSQLQuery("DROP TABLE IF EXISTS worldObjects") 
    executeSQLCreateTable("worldObjects", "objtype TEXT, weight INT, properties TEXT, taste TEXT") 
    executeSQLInsert("worldObjects", "'food', '5', 'gay', 'sweet'") 
    executeSQLInsert("worldObjects", "'drink', '2', 'stupid', 'sweet'") 
    executeSQLInsert("worldObjects", "'drink', '1', 'weird', 'sour'") 
    executeSQLInsert("worldObjects", "'drink', '6', 'hot', 'good'") 
    executeSQLInsert("worldObjects", "'trash', '3', 'cold', 'bad'") 
     
    result = executeSQLSelect("worldObjects","taste,properties","objtype = 'drink'" ) 
    outputServerLog( "Your drink is " .. result[1][1] .. " and " .. result[1][2] ) 
    outputServerLog( "Your drink is " .. result[2][1] .. " and " .. result[2][2] )  
    outputServerLog( "Your drink is " .. result[3][1] .. " and " .. result[3][2] )  
    resultB = executeSQLQuery("SELECT taste FROM worldObjects WHERE objtype = 'drink'")  --This line will often cause errors 
    outputServerLog("Query: "..resultB[1].taste) 
  
end 
addCommandHandler("table",serverLoadCustomObjects)  

To get the error to happen, type: "table" into the server console several times

Share this post


Link to post

  • Recently Browsing   0 members

    No registered users viewing this page.