Mysql query dies on me
#1

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?
Reply
#2

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)
Reply
#3

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);
    }
}
Reply
#4

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
Reply
#5

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 ?
Reply
#6

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

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.
Reply
#8

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

@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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)