Pulling a date from MySQL DB
#10

Quote:
Originally Posted by Jing_Chan
Посмотреть сообщение
Do I run this query within the stats command? Then how do I pull the result into the string? That's what I'm asking. Thanks for any pointers.
https://sampforum.blast.hk/showthread.php?tid=627520

Look at this for an example (different purpose but everything you need to know is in there). It uses a threaded query, which means the query will be executed seperately and the result returned when it is done.

You execute the query using mysql_tquery and specify a callback.

When the callback is called, the result will be in the cache and you can use the cache_* functions.

The result will be one row (if you only select one player) and one column, except you also get other data.
Column 0 will be the date in this case.

Код:
new date[20];
cache_get_value_index(0, 0, date, sizeof(date)); // row 0, column 0
So you can add a callback for the stats command and show the stats there, after extracting all the data from the cache.
You can also do this instantly without a threaded query by using mysql_query, which returns a cache ID from which you can get the data exactly like a threaded query (same cache functions).
Reply


Messages In This Thread
Pulling a date from MySQL DB - by Jing_Chan - 06.08.2018, 13:11
Re: Pulling a date from MySQL DB - by Jing_Chan - 06.08.2018, 21:55
Re: Pulling a date from MySQL DB - by NeXTGoD - 06.08.2018, 22:39
Re: Pulling a date from MySQL DB - by Banditul18 - 06.08.2018, 23:00
Re: Pulling a date from MySQL DB - by Calisthenics - 07.08.2018, 08:35
Re: Pulling a date from MySQL DB - by Jing_Chan - 07.08.2018, 11:10
Re: Pulling a date from MySQL DB - by NaS - 07.08.2018, 12:32
Re: Pulling a date from MySQL DB - by Calisthenics - 07.08.2018, 13:19
Re: Pulling a date from MySQL DB - by Jing_Chan - 07.08.2018, 13:22
Re: Pulling a date from MySQL DB - by NaS - 07.08.2018, 14:13

Forum Jump:


Users browsing this thread: 1 Guest(s)