Jump to content

MySQL Queries

Guest geminidog

Recommended Posts


I am running code which does this:

1) inserts a row into a table on the database

2) calls function, this function runs a SELECT statement which gathers info from row inserted in (1)

3) deletes the row that was inserted at (1)

My problem is that the program does not seem to be running in order. With the above order, the row never shows up in the database and (2) fails. I believe it must be going in the order of (1), (3), (2) because if I comment out (3), everything works fine.

I also believe that the PQuery, PExecute, Execute, etc., functions have something to do with this problem because I am not sure which I should use. I am using that %u variable stuff so I believe that I need to use one of the ones that starts with a 'P', but I am really not sure......does anyone know what these functions do specifically?

Thank you very much for your help,


Link to comment
Share on other sites

Thank you very much...

What I am trying to do is this:

1) Where the KillPlayer() function in Player.cpp is, I added a KickPlayer() function.

2)Then, I do a mysql query to add the guid into a database with a field 'deletenow' that equals 'delete'.

3) Then I do a Player::DeleteFromDB().

(all the above was where the state is 'just died'....where the KillPlayer() function is in Player.cpp)

4)Then I go into the Player::SaveToDB() function because I know it is called when the player is logged out, in the KickPlayer() function. I add an If statement which uses a mysql query to check to see if that player's GUID has a 'delete' in the field i said above.

5) If it does have the delete, then the mysql query to save the player is not executed and another mysql query deletes it from that 'deletenow' database. If it does not have delete, it is.

My problem is, I cannot figure out which type of query to use. I can only get one of these to happen, and I'm not sure how I'm doing that..:

1) The INSERT query executes and the character is deleted, but the second DELETE query does not execute, so the GUID for that player stays in the 'delete' database


2) The GUID never shows up in the database, because, I believe, the SELECT statement the checks to see if the character is to be deleted happens after the DELETE statement is executed, therefore the character is not deleted.

Which types of queries should I use for the INSERT, SELECT, and DELETE queries? Remember, INSERT is called when character dies, SELECT in the 'SaveToDB' function, and DELETE at the end of the SaveToDB function.

Thank you very much,


Link to comment
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use