Passing array to MySQL callback
#1

I've been stuck with this for a while and it's bugging me. I'm unable to figure out the correct way to pass an array to a MySQL callback after the query is complete.
This is my attempt:

Query:
pawn Код:
new array[5] = {0,1,2,3,4};
mysql_function_query(1, "SELECT * FROM `table` WHERE `id` = 1", false, "Test", "s", array);
Callback:
pawn Код:
forward Test(array[]);
public Test(array[])
{
    for(new i = 0; i != 5; i++)
        printf("array[%d] = %d", i, array[i]);
}
Output:
pawn Код:
array[0] = 0
array[1] = 0
array[2] = 0
array[3] = 0
array[4] = 0
The output will be correct if I change the array to (remove '0'):
pawn Код:
new array[5] = {1,1,2,3,4};
However, it will wrap back to 0 if I use a value higher than 255.

Hope someone can see what I'm doing wrong and help me out, thanks!

- Using BlueG's MySQL plugin (R7)
Reply
#2

Bump
Reply
#3

Would really appreciate any help with this.
Reply
#4

Quote:

g_mysql_handle = mysql_connect(MYSQL_HOST,MYSQL_USER,MYSQL_DATABASE ,MYSQL_PASSWORD);

mysql_function_query(g_mysql_handle, "SELECT * FROM `table` WHERE `id` = 1", false, "Test", "s", array);

first connect your sql and store the information in "g_mysql_handle" then use this in "mysql_function_query"
This is the corrent way to perform a query
Reply
#5

Quote:
Originally Posted by Fred1993
Посмотреть сообщение
first connect your sql and store the information in "g_mysql_handle" then use this in "mysql_function_query"
This is the corrent way to perform a query
I think you may have misunderstood the problem...I didn't bother to post the irrelevant code.
I'm not having problems with performing a query or connecting to the database; I'm unaware of how I am able to pass an array from a threaded query to the function which it calls.
Reply
#6

Bump
Reply
#7

Quote:
Originally Posted by Catalyst-
Посмотреть сообщение
Would really appreciate any help with this.
Bump
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
"s" is "string", arrays are USUALLY "a" but I don't know if the plugin supports them in callbacks. However, there are several work-arounds: use inline functions or copy the data to a global arary and pass an index instead.
I've already tried 'a' and didn't work, so if there's no other alternative it looks like arrays are not supported by the plugin. I'll likely just use a global array.

Thanks for your help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)