• 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Data loading
#1
Hi,



I am using a saving system by MySQL. The problem is, that I have multiple tables, in to which data are being saved. Everything works perfectly fine, until I want to load them.



When players connects and enters a correct password, I select all the data from all tables and pass them further into spawning. The problem is, that even that all of these tables and fields, columns are created properly both in the database and stated in the script, the data are not loaded and SQL throws out this error:



Field X does not exist



It is however properly created in the database. Funny part is, that this is only happening to the 2nd and 3rd table. The fields from the first table are being loaded just fine, and so when I move certain fields to the first table, they are excluded from the SQL error and everything works just fine. I am using a MULTI_STATEMENT when selecting these fields from the tables.



For any help, I will be thankful in advance.
  Reply
#2
Sorry for doubleposting, but I am using this script:

https://github.com/pBlueG/SA-MP-MySQL/bl...-cache.pwn



It is shame, but I copied it, so everything is exactly the same (all the proceses), except the MULTI_STATEMENT tunning. Basically the query in OnPlayerConnect looks somewhat like this:



Code:
mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `first` WHERE `username` = '%e' LIMIT 1 ; SELECT * FROM `second` WHERE `username` = '%e' LIMIT 1 ; SELECT * FROM `third` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name], Player[playerid][Name], Player[playerid][Name]);



The fields in table "first" are loaded just perfectly. But the fields in 2nd and 3rd seem to not exist (according to mysql.txt) in error logs.
  Reply
#3
You can only execute one query at a time in the mysql_tquery.


Code:
mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `first` WHERE ` username` = '%e' LIMIT 1", Player[playerid][Name]);
mysql_tquery(g_SQL, query, "LoadPlayerData_1", "d", playerid);

mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `second` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
mysql_tquery(g_SQL, query, "LoadPlayerData_2", "d", playerid);

mysql_format(g_SQL, query, sizeof query, "SELECT * FROM `third` WHERE `username` = '%e' LIMIT 1", Player[playerid][Name]);
mysql_tquery(g_SQL, query, "LoadPlayerData_3", "d", playerid);
  Reply
#4
Or he could JOIN the tables ????
Using Pawn.CMD?

If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
  Reply
#5
(2020-12-25, 07:51 PM)Pinch Wrote: Or he could JOIN the tables ????



Could you please show some example of this? Because I have found some stuff on internet, but there are like four types saying "if the result is the same", well the results are never same with this, because all the data in the tables are different.



It is funny thing though, that this multistatement feature works when saving the data "INSERT INTO". That shows absolutely no errors, even though I am using a tquery.



// To confess, I am really sorry, that I created another account to make this topic, but I could not get into this one and I really needed help. In the sake of Christmass, please moderators, I am really sorry - surely did not do it for harming purposes. I am from Romania, not Russia.
  Reply


Forum Jump: