SA-MP Forums Archive
Mysql Number of rows? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql Number of rows? (/showthread.php?tid=142224)



Mysql Number of rows? - DarrenReeder - 17.04.2010

hello..

I program in PHP and i thought pawno would be roughly the same...However i am trying to get the number of rows of a query i have done..although "samp_mysql_num_rows" function doesnt take any parameteres?

this is the functions:

native samp_mysql_num_rows();
native samp_mysql_query(query[]);


Re: Mysql Number of rows? - woot - 17.04.2010

You need to store the result, then samp_mysql_num_rows will return the amount of rows.


Re: Mysql Number of rows? - DarrenReeder - 17.04.2010

so how would i store the rows with tese functions?

Код:
native samp_mysql_connect(server[], user[], password[]);
native samp_mysql_select_db(db[]);
native samp_mysql_query(query[]);
native samp_mysql_store_result();
native samp_mysql_fetch_row(line[]);
native samp_mysql_get_field(field[], value[]);
native samp_mysql_num_rows();
native samp_mysql_num_fields();
native samp_mysql_ping();
native samp_mysql_real_escape_string(src[], dest[]);
native samp_mysql_free_result();
native samp_mysql_strtok(dest[], separator[], src[]);
native samp_mysql_close();



Re: Mysql Number of rows? - FUNExtreme - 17.04.2010

pawn Код:
new function;
function = samp_mysql_num_rows();



Re: Mysql Number of rows? - DarrenReeder - 17.04.2010

But i how do i put the

new query

into a variable for the num rows? (from using new function)


Re: Mysql Number of rows? - FUNExtreme - 17.04.2010

I don't really understand what you are trying to do


Re: Mysql Number of rows? - DarrenReeder - 17.04.2010

Well im trying to test the number of rows to see if a account exist..

so ive done:

Код:
	format(result,sizeof(result),"SELECT * FROM accounts WHERE user=%s",sqlPlayerName); // Format my query
	samp_mysql_query(result);
I want to store that query into a variable of number of rows.. like

Код:
row = samp_mysql_num_rows(query);

if(row == 0){
blah
}
that sort of idea..


Re: Mysql Number of rows? - FUNExtreme - 17.04.2010

pawn Код:
format(result,sizeof(result),"SELECT * FROM accounts WHERE user=%s",sqlPlayerName);
samp_mysql_query(result);
samp_mysql_store_result();
if(samp_mysql_num_rows() > 0)
{ blah }



Re: Mysql Number of rows? - DarrenReeder - 17.04.2010

so when i use samp_mysql_store_result(); it automaticly gets the last query and lets me use samp_mysql_num_rows to refer to that query?


Re: Mysql Number of rows? - FUNExtreme - 17.04.2010

Last query indeed.