PDA

View Full Version : Mysql query dies on me


Misiur
27/02/2013, 05:45 PM
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:

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

http://i.imm.io/XAlI.jpeg

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?

InfiniTy.
27/02/2013, 05:56 PM
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)

ryansheilds
27/02/2013, 05:56 PM
Try:


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);
}
}

Misiur
27/02/2013, 06:03 PM
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

InfiniTy.
27/02/2013, 06:04 PM
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 ?

Misiur
27/02/2013, 06:05 PM
I want what I've coded. First field from each row, in this case id - expected result is (1, 2) not (1, 0)

ryansheilds
27/02/2013, 06:11 PM
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.

Djole1337
27/02/2013, 06:13 PM
Have you tested that code with R7 ?
If not, do it.

Misiur
27/02/2013, 06:27 PM
@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:
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!