Jump to content

DB (help, please!)


Hugos

Recommended Posts

  • Moderators
Posted (edited)
1 hour ago, Hugos said:

How do I add data from a database? (I use the plugin mta_mysql)

 

Add data to a database?

INSERT INTO table_name (column1, column2 ) VALUES (?, ?)

 

OR

 

Get data from a database?

SELECT * FROM table_name

 

OR

 

Import data to a database from another database.

 

Edited by IIYAMA

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
50 minutes ago, IIYAMA said:

 

Add data to a database?


INSERT INTO table_name (column1, column2 ) VALUES (?, ?)

 

OR

 

Get data from a database?


SELECT * FROM table_name

 

OR

 

Import data to a database from another database.

 

I get the player 's serial number at the moment, and if it 's not already recorded in the DB - I add.

local username = getPlayerName(source)
local serial = tostring(result_account.serial)
local u_serial = getPlayerSerial(source)

if (serial == u_serial) then --We check the serial number
else
	if (serial == "") then --number will stop. Assign a new
		INSERT INTO accounts (,  ) VALUES (?, ?)
	else
	end
end

How it is correct to make it?

Edited by Hugos

Говорю на русском. Sorry for bad english.
 

  • Moderators
Posted
3 minutes ago, Hugos said:

How it is correct to make it?

Does that player already has an account?

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted (edited)
2 minutes ago, IIYAMA said:

Does that player already has an account?

Yes.  It is already registered (nikneim in recorded in "username")

Edited by Hugos

Говорю на русском. Sorry for bad english.
 

  • Moderators
Posted
5 minutes ago, Hugos said:

Yes.  It is already registered (nikneim in recorded in "username")

 

Something like that:

dbExec (db, "UPDATE accounts SET serial = ? WHERE username = ?", u_serial, username)

 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   ?

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
9 minutes ago, IIYAMA said:

 

Something like that:


dbExec (db, "UPDATE accounts SET serial = ? WHERE username = ?", u_serial, username)

 

THANKS!!!! ???

Говорю на русском. Sorry for bad english.
 

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