Jump to content

Need SQL help


seal

Recommended Posts

Posted

Hi, im new in lua programming and need some help in executesql using.

Ok, i can create tables and rows but i cant put in values, so how can i put values into the database?

E.G: playerposition, charactername.

And when an account is already in the table how can is update its data?

Thank you for your answers :)

Posted (edited)
addEventHandler("onPlayerJoin", getRootElement(), 
function () 
zombie_db = connectToDB() 
x, y, z = getElementPosition(source) 
dbExec( zombie_db, "INSERT INTO characters (nume, model, health, posx, posy, posz) VALUES (?,?,?,?,?,?)", getPlayerName(source), getElementModel(source), getElementHealth(source), x, y, z ) 
end) 

take an example

Edited by Guest

XajVsWV.png

168_zps269f1907.gif[Dev]BloWnRPG - We BloW the World [1%]168_zps269f1907.gif

Posted

You can execute INSERT queries to add rows with values, and also UPDATE queries to update rows.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

thanks your comments, but how do the sql knows in which line should it update?

e.g:

id name money

1 John 123

2 Max 50

i call update function but how can i update max's values, instead e.g john's values?

Posted
If you want to use UPDATE You can use WHERE statement

WHERE name = 'John'

WHERE id = 1

dbExec(connection,"UPDATE character SET name = ? WHERE id = ?", getPlayerName(source), accountID) 

accountID is the account, which you want to update

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