Threaded query isn't being called.
#1

When loading some data with threaded queries, the loop won't go past the first iteration.
pawn Код:
public OnOriginQueryFinish(query[], resultid, extraid, connectionHandle)
{
    new rows, fields, content[128], field[20];
    cache_get_data(rows, fields, gConnection);
   
    switch(resultid) {
        case THREAD_LOAD_ORIGINS: {
            printf("Table ORIGINS returned %d rows", rows);
            for(new row=0; row<rows; row++) {
                printf("Loop call %d", row);
                cache_get_field_content(row, "id", field, gConnection);                     OriginInfo[row][oSQLid] = strval(content);
                cache_get_field_content(row, "Name", OriginInfo[row][oName], gConnection);
                cache_get_field_content(row, "X", content, gConnection);                    OriginInfo[row][oPos][0] = floatstr(content);
                cache_get_field_content(row, "Y", content, gConnection);                    OriginInfo[row][oPos][1] = floatstr(content);
                cache_get_field_content(row, "Z", content, gConnection);                    OriginInfo[row][oPos][2] = floatstr(content);
                cache_get_field_content(row, "rotZ", content, gConnection);                 OriginInfo[row][oPos][3] = floatstr(content);
                cache_get_field_content(row, "Interior", content, gConnection);             OriginInfo[row][oInt] = strval(content);
                cache_get_field_content(row, "VW", content, gConnection);                   OriginInfo[row][oVW] = strval(content);
                printf("Test");
               
                for(new f=0; f<4; f++) {
                    printf("Loop call %d for skins.", f);
                    format(field, sizeof(field), "male%d", f+1);
                    cache_get_field_content(row, field, content, gConnection);      OriginInfo[row][oMaleSkins][f] = strval(content);
                    format(field, sizeof(field), "female%d", f+1);
                    cache_get_field_content(row, field, content, gConnection);      OriginInfo[row][oFemaleSkins][f] = strval(content);
                }
               
                printf("ID %d, Name %s, X %f, Y %f, Z %f, RotZ %f, Interior %d, VW %d", OriginInfo[row][oSQLid], OriginInfo[row][oName], OriginInfo[row][oPos][0], OriginInfo[row][oPos][1], OriginInfo[row][oPos][2], OriginInfo[row][oPos][3], OriginInfo[row][oInt], OriginInfo[row][oVW]);
            }
        }
    }  
    return 1;
}
Server printed out
Код:
[13:53:12] Table ORIGINS returned 3 rows
[13:53:12] Loop call 0
[13:53:12] Test
[13:53:12] Loop call 0 for skins.
[13:53:12] Loop call 1 for skins.
[13:53:12] Loop call 2 for skins.
[13:53:12] Loop call 3 for skins.
I have no idea why the loop isn't reaching past the first iteration.
Reply
#2

Add more debugs between "returned %d rows" and "ID %d, Name %s, X %f, Y %f, Z %f, RotZ %f, Interior %d, VW %d" .
Reply
#3

Everything seems fine in the logs, I'll try as an unthreaded query next.

@costel_nistor
Here is what I added
pawn Код:
public OnOriginQueryFinish(query[], resultid, extraid, connectionHandle)
{
    new rows, fields, content[128], field[20];
    cache_get_data(rows, fields, gConnection);
   
    switch(resultid) {
        case THREAD_LOAD_ORIGINS: {
            printf("Table ORIGINS returned %d rows", rows);
            for(new row=0; row<rows; row++) {
                printf("Loop call %d", row);
                cache_get_field_content(row, "id", field, gConnection);                     OriginInfo[row][oSQLid] = strval(content);
                cache_get_field_content(row, "Name", OriginInfo[row][oName], gConnection);
                cache_get_field_content(row, "X", content, gConnection);                    OriginInfo[row][oPos][0] = floatstr(content);
                cache_get_field_content(row, "Y", content, gConnection);                    OriginInfo[row][oPos][1] = floatstr(content);
                cache_get_field_content(row, "Z", content, gConnection);                    OriginInfo[row][oPos][2] = floatstr(content);
                cache_get_field_content(row, "rotZ", content, gConnection);                 OriginInfo[row][oPos][3] = floatstr(content);
                cache_get_field_content(row, "Interior", content, gConnection);             OriginInfo[row][oInt] = strval(content);
                cache_get_field_content(row, "VW", content, gConnection);                   OriginInfo[row][oVW] = strval(content);
                printf("Test");
               
                for(new f=0; f<4; f++) {
                    printf("Loop call %d for skins.", f);
                    format(field, sizeof(field), "male%d", f+1);
                    cache_get_field_content(row, field, content, gConnection);      OriginInfo[row][oMaleSkins][f] = strval(content);
                    format(field, sizeof(field), "female%d", f+1);
                    cache_get_field_content(row, field, content, gConnection);      OriginInfo[row][oFemaleSkins][f] = strval(content);
                }
               
                printf("ID %d, Name %s, X %f, Y %f, Z %f, RotZ %f, Interior %d, VW %d", OriginInfo[row][oSQLid], OriginInfo[row][oName], OriginInfo[row][oPos][0], OriginInfo[row][oPos][1], OriginInfo[row][oPos][2], OriginInfo[row][oPos][3], OriginInfo[row][oInt], OriginInfo[row][oVW]);
            }
        }
    }  
    return 1;
}
Server printed out
Код:
[13:53:12] Table ORIGINS returned 3 rows
[13:53:12] Loop call 0
[13:53:12] Test
[13:53:12] Loop call 0 for skins.
[13:53:12] Loop call 1 for skins.
[13:53:12] Loop call 2 for skins.
[13:53:12] Loop call 3 for skins.
I have no idea why the loop isn't reaching past the first iteration.
Reply
#4

Reply
#5

Bump
Reply
#6

I don't see anything wrong in the code, literally.

Humour me and increase the buffer sizes and try again? (field and content).
Reply
#7

EDIT:

Solved.

The second condition in the loop was supposed to be f<3 not f<4
Reply
#8

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
I've finally narrowed it down to this block of code.
pawn Код:
for(new f=0; f<4; f++) {
    format(field, sizeof(field), "male%d", f+1); printf("%s", field);
    cache_get_field_content(row, field, content, gConnection);      OriginInfo[row][oMaleSkins][f] = strval(content);
    format(field, sizeof(field), "female%d", f+1); printf("%s", field);
    cache_get_field_content(row, field, content, gConnection);      OriginInfo[row][oFemaleSkins][f] = strval(content);
}
Would you have any idea why that is printing out
Код:
[02:39:34] male1
[02:39:34] female1
[02:39:34] male2
[02:39:34] female2
[02:39:34] male3
[02:39:34] female3
[02:39:34] male4
The last line ("male4") is not supposed to be there according to my code.
Well, here's your loop:

pawn Код:
for(new f=0; f<4; f++)
It iterates from 0 to 3 and since you do f+1, the loop will equal:

0 = 1
1 = 2
2 = 3
3 = 4

That's why there is a four.
Reply
#9

I can now sleep tonight, thanks Extremo.
Reply
#10

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
I can now sleep tonight, thanks Extremo.
I still don't grasp what the error was but I am glad I could help?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)