SA-MP Forums Archive
SAMP MySQL Help - 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: SAMP MySQL Help (/showthread.php?tid=655384)



SAMP MySQL Help - Miguelch1312 - 20.06.2018

Hi eveyone,
Im here to know if someone could tell me the equals for "db_next_row" in the pBlueG MySQL version R39-5 or the way to do something like that.

Thanks and greetings.


Re: SAMP MySQL Help - div - 20.06.2018

what exactly do you want?
like fetch a data from a field data or something?


Re: SAMP MySQL Help - Miguelch1312 - 20.06.2018

Fetch the row info, And use strcat to add it to a "format", next get the other row info and use strcat to add, this with all rows

To make something like
Row 1 NAME: Pepe | Lastname: White
Row 2 NAME: Pipe | Lastname: Andres

And wanna to show that on a dialog like

_______________________
|++Name++|++Lastname++|
|_________ |____________ |
|+Pepe++++|+White+++++|
|+Pipe++++|+Andres+++++|
|_________ |_____________|


Re: SAMP MySQL Help - div - 20.06.2018

i can give u an idea.. dont want to write code for now ;3


When he connects, showplayerdialog(2 dialogs TYPE_MSGBOX)


OnPlayerDialogResponse


then

INSERT * INTO `playerdata` WHERE `firstname` = '%s', inputtext)


same we doing with lastname



then the command u want to make this dialogbox for
new fName[24], lName[24];
cache_get_field_content(connectionhandle, "firstname", fName);

same with second name..


then
new string[128];
format(string, sizeof(string), "Name\tLastname\n%s\t%s, fName, lName);
ShowPlayerDialogBox


or if ur making a /credits dialogbox of smth


simply ShowPlayerDialog.. easy.


Re: SAMP MySQL Help - Miguelch1312 - 20.06.2018

No i mean getting the diferrent rows from the MySQL Table and showing it, look, like

--SELECT `NAME`,`LASTNAME`,`ID`, `VIP` FROM `PLAYERS`WHERE `VIP` >= 1 ORDER BY `ID`--

This will do a MySQL query with all the rows with the players that have his vip level more than 1, so then i make a loop to reach all the rows.

Код:
new dialog[128 * 15];
format(dialog, sizeof dialog, "Name\tLastname\tID\tVIP\t");

for(new i; i < cache_get_row_count(Result); i++ )
{
	new name[24], lastname[24], ID, VIP;

	cache_get_field_content(Result, "NAME", name, 24);
	cache_get_field_content(Result, "LASTNAME", lastname, 24);
	connected = cache_get_row_int(Result, "ID");
	rank = cache_get_row_int(Result, "VIP");

	new dline[128];
	format(dline, sizeof dline, "%s\t%s\t%d\t%d", name, lastname, ID, VIP);

	strcat(dialog, dline);
	listitem ++;

	db_next_row(Result);// THIS IS FROM SQLite I NEED THIS IN MYSQL R39-5
}
cache_delete(Result);
ShowPlayerDialog(playerid, VIP_LIST, DIALOG_STYLE_TABLIST_HEADERS, dialog, "OK", "");
db_next_row(Result);This line is from SQLite, i need to update it to MySQL and i dont know what's the statement or the way, its to catch the information from the next row


Re: SAMP MySQL Help - div - 20.06.2018

u mean u wanna check if row exists or not??
Код:
        new rows = 0;
	rows = cache_get_row_count();

	if(!rows)

        {
          CODE HERE
          }



Re: SAMP MySQL Help - Calisthenics - 20.06.2018

There is not equivalent.

SQLite stores only on row and can move to the next but not to previous.
MySQL on the other hand can access any row anytime.

You shouldn't create variables inside loops, move them outside and you call cache_get_row_count multiple times. The optional parameter is also connection handle not the cache id as well as retrieving data require a row id, not the cache id.

pawn Код:
new dialog[128 * 15], name[24], lastname[24], ID, VIP;
dialog = "Name\tLastname\tID\tVIP\t";

for(new i, j = cache_get_row_count(); i < j; i++ )
{
    cache_get_field_content(i, "NAME", name, 24);
    cache_get_field_content(i, "LASTNAME", lastname, 24);
    connected = cache_get_row_int(i, "ID");
    rank = cache_get_row_int(i, "VIP");

    format(dialog, sizeof dialog, "%s%s\t%s\t%d\t%d", dialog, name, lastname, ID, VIP);
}

cache_delete(Result);
ShowPlayerDialog(playerid, VIP_LIST, DIALOG_STYLE_TABLIST_HEADERS, dialog, "OK", "");
It is also always suggested to use threaded queries.