Jump to content

Save table on sqlite db?


Recommended Posts

Posted

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

Posted

Any variables type?

String, Text or VARCHAR:

[mysql]

  1. UPDATE table SET TIME='1111'
[/mysql]

Int:

[mysql]

  1. UPDATE table SET TIME=1111
[/mysql]

Ingame nick: Cadu12

Posted

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.

-

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...