SA-MP Forums Archive
Mysql query dies on me - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Mysql query dies on me (/showthread.php?tid=419169)



Mysql query dies on me - Misiur - 27.02.2013

pawn Код:
forward This();
public This() {
    new rows, fields, tmp[32];
    cache_get_data(rows, fields, dbhandle);
    Debug("Rows %d, fields %d", rows, fields);
   
    for(new i = 0; i < rows; ++i) {
        cache_get_row(i, 0, tmp);
        Debug("Id %d i %d", strval(tmp), i);
    }
}
//(...)
mysql_function_query(dbhandle, "SELECT * FROM vehicles WHERE uid = 1", true, "This", "");
Output:

Quote:

[20:02:33] Rows 2, fields 10
[20:02:33] Id 1 i 0
[20:02:33] Id 0 i 1



Mysql plugin version r15. Field type bigint 20, sting is big enough.
I don't know, maybe I'm tired, but I can't understand why this happens. Any ideas?


Re: Mysql query dies on me - InfiniTy. - 27.02.2013

pawn Код:
cache_get_row(0, i, tmp);
Also.. what are you trying to do ? If you are trying to fetch all data then do it without a loop.. do it manually.. it's easier.. also when fetching a float you should use floatstr.. if you didn't know.. wich i kinda doubt

cache_get_row(row, idx, dest[], connectionHandle = 1)


Re: Mysql query dies on me - ryansheilds - 27.02.2013

Try:

pawn Код:
forward This();
public This() {
    new rows, fields, tmp[32];
    cache_get_data(rows, fields, dbhandle);
    Debug("Rows %d, fields %d", rows, fields);
   
    for(new i = 0; i < rows; ++i) {
        cache_get_row(i, 0, tmp, dbhandle, sizeof(tmp));
        Debug("Id %d i %d", strval(tmp), i);
    }
}



Re: Mysql query dies on me - Misiur - 27.02.2013

pawn Код:
cache_get_row(row, idx, dest[], connectionHandle = 1);
@Adytza. I'd get id and uid from first row
@ryansheilds there is no buffer length argument


Re: Mysql query dies on me - InfiniTy. - 27.02.2013

Quote:
Originally Posted by Misiur
Посмотреть сообщение
pawn Код:
cache_get_row(row, idx, dest[], connectionHandle = 1);
@Adytza. I'd get id and uid from first row
@ryansheilds there is no buffer length argument
Oh.. so you want ID of all rows .. or what ?


Re: Mysql query dies on me - Misiur - 27.02.2013

I want what I've coded. First field from each row, in this case id - expected result is (1, 2) not (1, 0)


Re: Mysql query dies on me - ryansheilds - 27.02.2013

There's a buffer length argument in the MySQL version you stated? I'm sure there is, otherwise it returns a empty string - based on personal experience, when I don't state it, it doesn't load anything.


Re: Mysql query dies on me - Djole1337 - 27.02.2013

Have you tested that code with R7 ?
If not, do it.


Re: Mysql query dies on me - Misiur - 27.02.2013

@ryansheilds: My apologies - you've pointed out the real problem - I didn't update include (after running into few errors with R7 i updated the dll, but forgot about it). Works now even without specifying the length.

On a sidenote:
pawn Код:
native cache_get_row(row, idx, destination[], connectionHandle = 1, max_len=sizeof(destination));
By default the last argument is the sizeof of destination, when I might need to provide the length myself?

#e:

cache_get_row_int - awesome!