SA-MP Forums Archive
Mysql function doubt - 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 function doubt (/showthread.php?tid=580785)



Mysql function doubt - DetoNater - 08.07.2015

Actually, the old function of fetching both field(column) and row is done by mysql_fetch_field_row ? which retrives both fiekd and row, but in new plugin which equivalent cmd would do so?

My code
Код:
if(cache_num_rows(mysql) > 0)
   	{
	    //while(mysql_fetch_field_row(string,"|"))
            cache_get_row(10,"|",string);// argument type mismatch, i know the param entered is wrong!
	    {
	        sscanf(string,"p<|>s[7]i",Clan,score);
	        format(content,sizeof(content),"%s%s\t\t%d Score\n",content,Clan,score);
            }
	}



Re: Mysql function doubt - dusk - 08.07.2015

There is no function to get the full line in newer plugin versions.

This code is equivalent to yours.
pawn Код:
for(new i = 0; i < cache_get_row_count(); i++)
{
      // The 2nd parameter is field index, which I do not know in your query.
      cache_get_row(i, 0, Clan);
      score = cache_get_row_int(i, 1);

      format(content,sizeof(content),"%s%s\t\t%d Score\n",content,Clan,score);
}



Re: Mysql function doubt - DetoNater - 08.07.2015

actually i want an whole coumn to be retrieved from mysql, @dusk your code was good, but expecting some other ways!


Re: Mysql function doubt - dusk - 08.07.2015

Whole column? Don't you mean a row?

You want something like
Quote:

col1value|col2value|col3value|col4value

If so, that is impossible with new mysql functions.



http://forum.sa-mp.com/showpost.php?...postcount=5658


Re: Mysql function doubt - DetoNater - 08.07.2015

Yeah row I mean @dusk, for eg, I have a column name 'Clans' and I have 3 clans in the rows [X],[Y],[Z] I want to retrieve the column 'Clans' displaying the [X],[Y],[Z] clans....


Re: Mysql function doubt - Stanford - 08.07.2015

I doubt that you need sscanf to get the job done in this situation, you do not need to split in my opinion. You should ask yourself "Am I having the clanNames in same row (string) and '|' between each name; I think then you should use sscanf!


Re: Mysql function doubt - DetoNater - 08.07.2015



See I have a column called clan, i want to get retrived both the [BS][iBon] clan

I use sscanf to split it.


Re: Mysql function doubt - dusk - 08.07.2015

The code I gave you, will do what you need.

pawn Код:
for(new i = 0; i < cache_get_row_count(); i++)
{
      cache_get_field_content(i, "clan", Clan);
      score = cache_get_field_content_int(i, "Clanscore");

      format(content,sizeof(content),"%s%s\t\t%d Score\n",content,Clan,score);
}



Re: Mysql function doubt - DetoNater - 08.07.2015

thanks @ dusk it did work, repped!