Jump to content

Save table on sqlite db?


Recommended Posts

I have this:

  
-- Client 
local x, y, z = getElementPosition(veh) 
local rx, ry, rz = getElementRotation(veh) 
if getDistanceBetweenPoints3D(x, y, z, lx, ly, lz) > 2 then 
    table.insert(recordData, {x = x, y = y, z = z, lx = lx, ly = ly, lz = lz} ) 
    lx = x ly = y lz = z 
end 
-- Server 
dbExec("UPDATE recordings SET time = " ..time.. ", recording = " ..data.. " WHERE account = '" ..account.. "'") -- This line gives me the error 

But I get an error saying that I attempt to conectate a table data value, is there any way? thanks

Link to comment

Correct me if I'm wrong, but there's no data type "storage" in SQL. As for table, of course can't simply concatenate it into the string. This is not a good way to organize your database structure, anyway. But if you still want to make it like that, you can convert the table to a string and vice-versa using these functions:

toJSON 
fromJSON 

And the last thing to say, do not concatenate the values directly into the query string. Pass them as separate arguments into dbExec to avoid code injection.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...