MySQL problem
#1

Hello i have mysql error.

Quote:

[19:23:45] [WARNING] cache_get_row_count - no active cache
[19:23:45] [WARNING] cache_get_field_count - no active cache

In mysql log it shows when i use this command

Код:
CMD:darbuotojai(playerid, params[])
{
	if(sInfo[playerid][TaxDirektorius] == 1 || sInfo[playerid][TaxPavaduotojas] == 1)
	{
		mysql_query(manomysql, "SELECT vardas, dispejimai, TaxRangas, pradirbtas_laikas FROM `user` WHERE `TaxiDarbas` = '1'", false);
		mysql_store_result();
		new name[MAX_PLAYER_NAME], ispejimai, rang, pradirbo, x, resultline[40], str[170], fstr[3500];
		while(mysql_fetch_row_format(resultline))
		{
			sscanf(resultline,"p<|>s[24]ddd",name, ispejimai, rang, pradirbo);
			x++;
			format(str, sizeof(str),"%d. {00A5FF}%s\t {FAFAFA}Įspėjimai {FF0019}%d/3\t {FAFAFA}Rangas {FFDC00}%d\t {FAFAFA}Љiandien pradirbo {00D7FF}%d minučių\n", x, name, ispejimai, rang, pradirbo);
			strcat(fstr, str);
		}
		ShowPlayerDialog(playerid,DIALOG_DARBUOTOJAI,DIALOG_STYLE_MSGBOX,"Darbuotojai",fstr,"Gerai","");
		mysql_free_result();
	}
	return 1;
}
Any ideas how to fix it?

I using MySQL r34 plugin
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
You need a callback to trigger when the query completes. They aren't instant.
Like this?
Код:
forward OnJobInfoLoad(playerid);

public OnJobInfoLoad(playerid)
{
	new name[MAX_PLAYER_NAME], ispejimai, rang, pradirbo, x, resultline[40], str[170], fstr[3500];
	while(mysql_fetch_row_format(resultline))
	{
		sscanf(resultline,"p<|>s[24]ddd",name, ispejimai, rang, pradirbo);
		x++;
		format(str, sizeof(str),"%d. {00A5FF}%s\t {FAFAFA}Įspėjimai {FF0019}%d/3\t {FAFAFA}Rangas {FFDC00}%d\t {FAFAFA}Љiandien pradirbo {00D7FF}%d minučių\n", x, name, ispejimai, rang, pradirbo);
		strcat(fstr, str);
	}
	ShowPlayerDialog(playerid,DIALOG_DARBUOTOJAI,DIALOG_STYLE_MSGBOX,"Darbuotojai",fstr,"Gerai","");
	mysql_free_result();
}



CMD:darbuotojai(playerid, params[])
{
	if(sInfo[playerid][TaxDirektorius] == 1 || sInfo[playerid][TaxPavaduotojas] == 1)
	{
	    new query[128];
	    format(query, sizeof(query), "SELECT vardas, dispejimai, TaxRangas, pradirbtas_laikas FROM `user` WHERE `TaxiDarbas` = '1'");
		mysql_function_query(manomysql, query, true, "OnJobInfoLoad", "i", playerid);
		mysql_store_result();
	}
	return 1;
}
Reply
#3

Then i use this command:

Код:
CMD:darbuotojai(playerid, params[])
{
	if(sInfo[playerid][TaxDirektorius] == 1 || sInfo[playerid][TaxPavaduotojas] == 1)
	{
	    new query[128];
	    format(query, sizeof(query), "SELECT vardas, dispejimai, TaxRangas, pradirbtas_laikas FROM `user` WHERE `TaxiDarbas` = '1'");
		mysql_function_query(manomysql, query, true, "OnJobInfoLoad", "i", playerid);
	}
	return 1;
}
Код:
public OnJobInfoLoad(playerid)
{
    mysql_store_result();
	new name[MAX_PLAYER_NAME], ispejimai, rang, pradirbo, x, resultline[40], str[170], fstr[3500];
	while(mysql_fetch_row_format(resultline))
	{
		sscanf(resultline,"p<|>s[24]ddd",name, ispejimai, rang, pradirbo);
		x++;
		format(str, sizeof(str),"%d. {00A5FF}%s\t\t {FAFAFA}Įspėjimai {FF0019}%d/3\t\t {FAFAFA}Rangas {FFDC00}%d\t\t {FAFAFA}Љiandien pradirbo {00D7FF}%d minučių{FAFAFA}\n", x, name, ispejimai, rang, pradirbo);
		strcat(fstr, str);
	}
	ShowPlayerDialog(playerid,DIALOG_DARBUOTOJAI,DIALOG_STYLE_MSGBOX,"Darbuotojai",fstr,"Gerai","");
	mysql_free_result();
}
I got errors in MySQL log, but command is working
Quote:

[20:48:28] [WARNING] CMySQLResult::GetRowData - invalid row ('2') or field index ('0')
[20:48:28] [WARNING] CMySQLResult::GetRowData - invalid row ('2') or field index ('1')
[20:48:28] [WARNING] CMySQLResult::GetRowData - invalid row ('2') or field index ('2')
[20:48:28] [WARNING] CMySQLResult::GetRowData - invalid row ('2') or field index ('3')

Maybe someone know how to fix?
Reply
#4

BUMP

Still have this problem
Reply
#5

You say you are using R34 and you use functions from R6 which have been removed. Function `mysql_function_query` was added in R7 and removed after a few releases as well so what is the real include version? If `mysql_fetch_row_format` is just a macro or custom function, the mistake is it loops <= to rows returned instead of < rows.
Reply
#6

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
You say you are using R34 and you use functions from R6 which have been removed. Function `mysql_function_query` was added in R7 and removed after a few releases as well so what is the real include version? If `mysql_fetch_row_format` is just a macro or custom function, the mistake is it loops <= to rows returned instead of < rows.
no it's not custom function. So which version is the best? r41-4 ?
Reply
#7

Being up-to-date is a good choice.
Reply
#8

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Being up-to-date is a good choice.
OK i updated to r39-6. Why not r40 because in r40 a lot of functions is rennamed and some corrected, so i dont want to rewrite a lot of lines in my code.
Now i have errors:
Quote:

error 017: undefined symbol "mysql_store_result"
error 017: undefined symbol "mysql_fetch_row_format"
error 017: undefined symbol "mysql_free_result"

How i would change my code?

Код:
public OnJobInfoLoad(playerid)
{
    mysql_store_result();
	new name[MAX_PLAYER_NAME], ispejimai, rang, pradirbo, x, resultline[40], str[170], fstr[3500];
	while(mysql_fetch_row_format(resultline))
	{
		sscanf(resultline,"p<|>s[24]ddd",name, ispejimai, rang, pradirbo);
		x++;
		format(str, sizeof(str),"%d. {00A5FF}%s\t\t {FAFAFA}Įspėjimai {FF0019}%d/3\t\t {FAFAFA}Rangas {FFDC00}%d\t\t {FAFAFA}Љiandien pradirbo {00D7FF}%d minučių{FAFAFA}\n", x, name, ispejimai, rang, pradirbo);
		strcat(fstr, str);
	}
	ShowPlayerDialog(playerid,DIALOG_DARBUOTOJAI,DIALOG_STYLE_MSGBOX,"Darbuotojai",fstr,"Gerai","");
	mysql_free_result();
}
Reply
#9

There are code-breaking changes. Only renaming the functions does not do justice. Storing the cache from function `mysql_query` is equivalent to `mysql_store_result` but if you are going to update the script, do it correctly. Use threaded queries which requires a public function (callback) but it does not wait in main PAWN thread. The plugin does not return the whole result anymore, you can access any (valid) row and index with the cache functions to retrieve data. Function `cache_delete` is equivalent to function `mysql_free_result` but only used when non-threaded queries are used.

Check example script from mysql github repository to get a basic idea.
Reply
#10

You saying what
Quote:

Storing the cache from function `mysql_query` is equivalent to `mysql_store_result`

So i delete `mysql_store_result` and `mysql_free_result`from the code.

Can i use mysql_function_query in r39-6 version?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)