Jump to content

write to database


sjizzle

Recommended Posts

Hello,

How to write a vallue like this to the database?

time_t currenttime = sWorld.GetGameTime()

I used:

CharacterDatabase.PExecuteLog("UPDATE Character_current_time SET time_current = '%u' WHERE guid = '%u'", currenttime, pPlayer->GetGUID());

though this fails, value in the database is still ZERO.

My database field has the following specs:

- Datatype : bigint

- Len : 40

- Default : 0

- Not NULL: checked

- Unsigned : checked

Link to comment
Share on other sites

You would also need a column for the guid.

So then you would have the following columns:

1. guid (unique key)

- Datatype : int

- Len : 11

2. time_current

- Datatype : bigint

- Len : 40

- Default : 0

- Not NULL: checked

- Unsigned : checked

Then you could use the following statement to insert the time for a specific guid.

CharacterDatabase.PExecuteLog("REPLACE INTO Character_current_time (`guid`, `time_current`) VALUES

(%u, %u)", pPlayer->GetGUID(), currenttime);

On a side note: GetGUID isn't used/available any more, you could use GetObjectGuid with GetRawValue (don't know exact funtion name) to get the guid.

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