About Mysql
#1

Is there any way to inset long queries? I mean if we have a long sentence then pawno return with long sentence error as we all know. So any way to insert long queries? Currently im using like this
PHP код:
 format(Query,sizeof(Query),"INSERT INTO `Users` (`Name`, `RegisteredOn`, `RegisteredIP`, `LastLoggedIP`, `Password`, `Level`, `Banned`) VALUES(`%s`,`%s`, `%s`, `%s`, `%s`, `%d`, `%d`)",PN(playerid), string,pIP,pIP,buf,0,0);
              
format(Query2,sizeof(Query2),"INSERT INTO `Users` (`Donator`, `Score`, `Cash`, `Kills`, `Deaths`, `Skin`, `Muted`, `Autologin`, `TotalSeconds`,`TotalSpentTime`,`LastSeen`) VALUES(`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%d`,`%s`,`%s`)",0,1,1500,0,0,0,0,0,seconds,ConvertTime(seconds,mins,hour,day),str);
              
mysql_query(Query);
              
mysql_query(Query2); 
Reply
#2

Anyone?
Reply
#3

1) Splitting.
pawn Код:
format(Query2,sizeof(Query2),
"INSERT INTO ...",
PN(playerid), string, ...);
2) strcat
pawn Код:
Query = "INSERT INTO `Users` (`Name`, ...)";
strcat(Query, " VALUES ('%s', ...)");

format(Query, sizeof(Query), Query, PN(playerid), string, ...);
3) Zeex's compiler exceeds the line limit to 4095 characters:
https://github.com/Zeex/pawn
https://sampforum.blast.hk/showthread.php?pid=2768123#pid2768123

---

Notes:
- Consider updating to the latest versions of mysql plugin.
- Escape strings when needed.
- Use default values to reduce the query.
- Values' specifiers (only strings) need an apostrophe and not grave accent character. It will result in error in syntax.
Reply
#4

You could write the queries into a file and then store them in a string on pawn.
Reply
#5

It is giving me tag mismatch error on mysql_query(Query); and i tried inserting the connecthandle in it but still it gave me tag mismatch error. EDIT: and if i use it like this?
PHP код:
format(Query,sizeof(Query),"SELECT `Level`, `Donator`, `Banned`, `Kills`, `Deaths`, `Muted`, `PoliceScore`, `RobberScore`, `Cash`, `Skin`, `WantedLevel`, `LastLoggedIp`, `TotalSeconds`");
    
format(Query,sizeof(Query),"%s, `VW`, `Int`, `Xpos`, `Ypos`, `Zpos`, `House`, `House2`, `HouseLim`, `Team`, `VehLim`, `VehLim2`, `FLevel`, `FRank`, `FacNo`, `Fix`, `FName`, `Tag`, `PName` WHERE `Name` = `%s`",Query,PN(playerid));
    
mysql_query(Query); 
This code is for loading data
Reply
#6

R40+ version has a MySQL: tag for the connection handle. For more here: https://sampwiki.blast.hk/wiki/MySQL/R40
Reply
#7

Hm.. but i already made functions with the mysql version im using currently. So i can't use that mysql_query?
Reply
#8

The syntax in the first post is for R5/R6/R6-2 but giving tag mismatch for the first argument indicates that you are trying to compile with R40+ version.

Unless you post more details about the version, I can't really say much.
Reply
#9

How can i fetch data from a row which is stored in Float type?
Reply
#10

Aight i installed mysql 40 but its functions are new to me what should i use in it instead of
PHP код:
mysql_fetch_field_row 
?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)