Mysql function doubt
#1

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

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

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

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

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

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



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

I use sscanf to split it.
Reply
#8

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

thanks @ dusk it did work, repped!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)