[Include] j_mysql Easiest utilization of MySQL [R7]
#1

j_mysql

I'im going to present my include that I realised the other day. The idea of this include is to simplify some functions of MySQL to develop better codes. Also the function's are like dini for example MySQL_Float is like Dini_Float.
So, let's continue


Function's:
  • MySQL_ConnectTo
  • MySQL_Switch_Table
  • Change_Row
  • Table_Rename
  • Drop_Table
  • Drop_Column
  • MySQL_Insert
  • MySQL_String
  • MySQL_Float
  • MySQL_Int
  • MySQL_Close_All


As you can see the functions are very simple.

Explanation of each function:
  • MySQL_ConnectTo
Parameters:
Код:
(MySQL_Host[], MySQL_User[], MySQL_Database[], MySQL_Password[], Table[])
The idea of this function is to connect to the database and the table. As you can see it has one more parameter that is 'Table', with this parameter you specify the table you wanna use.
Example:
pawn Код:
public OnGameModeInit()
{
MySQL_ConnectTo("localhost","root", "db", "", "Hello");
return 1;
}
  • MySQL_Switch_Table
Parameters:
Код:
(table[])
The idea of this function is to switch the table you are working so you can work with lot's of tables.

Example:
pawn Код:
zcmd(ctable, playerid ,params[])
{
if(!sscanf(params, "s[30]", params[0]))
{
MySQL_Switch_Table(params[0]);
new s[64]; format(s, sizeof(s), "You switched to the table: %s", params[0]);
SendClientMessage(playerid, -1, s);
}
return 1;
}
  • Change_Row
Parameters:
Код:
(row[], torow[], type[], lenght)
row = The name of the row that you want to change.
torow = The name that the row will have.
type = The type of context that the row will have (FLOAT, VARCHAR etc...)
lenght = The lenght that the row will have.

Example:

pawn Код:
SwitchToRow()
{
Change_Row("row1", "row2", "VARCHAR", 30);
mysql_function_query(MySQLInfo[MySQL_Table], "UPDATE `table` SET `fila2` = 'Hi'", false, "OnQueryResponse", "ii", playerid);
return 1;
}
  • Table_Rename
Parameters:
Код:
(name[], newname[])
Name =The name of the table
newname = The new name of the table.

Example:
pawn Код:
stock SwitchName()
{
Table_Rename("table", "table2");
SetTimer("SwitchName", 60000*30, false);
return 1;
}
  • Drop_Table
Parameters:
Код:
(tablename[])
tablename = The name of the table that we want to destroy.

Explanation: The idea of this function is to destroy any table that is useful.

Example:
pawn Код:
zcmd(droptable, playerid, params[])
{
if(sscanf(params, "s[64]", params[0])) return SendClientMessage(playerid, -1, "/droptable <name>");
{
Drop_Table(params[0]);
}
return 1;
}
  • Drop_Column
Parameters:

Код:
(column[])
column = The name of the column.

The idea of this function is to drop any column that is useful.
  • MySQL_Insert
Parameters:

Код:
(field[],field1[],field2[], field3[], value[],value1[],value2[],value3[])
field = The first field to insert.
field1 = The second one
field2 = The third one
field3 = The last one.

-
value = The first value
value1 = The second value
value2 = The third value
value3 = The forth value.

Nota: All the values in the function are with the formatstring.

Explanation:

The idea of this function is to insert lot's of values. Is very useful for register sistems.
  • MySQL_String
Parameters:
Код:
(field[], string[])
field = The field where you will insert the string.
string = The text to insert.

The idea of this function is to insert a string in a row.
  • MySQL_Float
Parameters:
Код:
(field[], Float:float)
field = Where will insert the float.
Float:float = The float to insert.
  • MySQL_Int
Parameters:

Код:
(field, int)
Field = Where you will insert the integrer.
int = The integrer to input.
  • MySQL_Close_All
Parameters:

Код:
(N/A)
This function closes all the MySQL connection's. (DB and the console)

Bugs:
N/A

Descarga:

This include uses the R7 MySQL Plugin of BlueG (post) also the a_mysql.inc that comes with the include.
Reply
#2

Is there any checking in MYSQL_switch_table? If the table to be switched, even exists?
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
There is not a single check for anything anywhere.
Damn, your MYSQL will seriously be damned to hell if there's, say, a typo. Is this something like...
pawn Код:
my_easier_to_read_function( params )
{
       return mysql_query( params );
}
Reply
#4

Haah! Also, I noticed there are limited arguments in MYSQL_INSERT. Try using getarg and numarg!
Reply
#5

Ok, i have realised that im very stupid. Or that i shoudnt work during night so i will take off the mediafire link fix the bug's and then post it again. While i was testing those bug's missed up, so thank's for the comments to show me my errors so i can improve.
I will put this in spanish, because it's difficult to me to say it in english.
Tampoco para tanto descanso flaco, fuera de joda. Esta bien, vos sos el terrible programador pero corte tampoco para cagarse en los demбs porque tipo yo ando aprendiendo. Recuerden que nadie nace sabiendo.
Reply
#6

Truly disappointed at Rajat_Pawar and ******. This guy put his effort on creating something to help other people and what you do? Make fun of him - such a nice attitude from a 1896 repped guy! It's because of people like you that many talents will never be found. Nice work, really nice work...

Look at the spanish version of this script: https://sampforum.blast.hk/showthread.php?tid=435894 - maybe they are all noob scripters, but at least there's respect.
Reply
#7

Which is it? Are my posts bad or good?

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
Truly disappointed at [...] Y_Less.
Bad.

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
what you do? Make fun of him
Bad. Also, criticism and pointing out security holes is not the same as making fun.

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
such a nice attitude from a 1896 repped guy
Good. Thanks btw.

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
It's because of people like you that many talents will never be found.
Bad. Either people can take criticism and improve (which I'm pleased to say is how JustBored seemed to take the posts), in which case I've actually helped to improve a talent; or they don't and quit, in which case I've helped to weed out the people that don't really care. Either way, that's a good thing (and I've been on the other side of this treatment too, so I know what I'm on about).

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
Nice work, really nice work...
Good. Again, thanks.
Reply
#8

Nice rhetoric. But I don't need to give you explanations, just look at his answer.
Reply
#9

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
Nice rhetoric.
Thanks.

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
But I don't need to give you explanations,
Neither did I!

Quote:
Originally Posted by richardcor91
Посмотреть сообщение
just look at his answer.
OK, how about this bit:

Quote:
Originally Posted by JustBored
Посмотреть сообщение
thank's for the comments to show me my errors so i can improve.
? Seems like exactly what I said to me...
Reply
#10

He is being ironical, don't you see that? Just like you were in some comments...
Look at the rest of the message, look at his spanish topic and stop separately quoting what I say because that's a really fallacious type of answer.
I think there's no need to keep discussing on this, I just think you guys could be more tolerant on him.
Reply
#11

Not one of my posts in this topic was ironic. Posting ironically only causes confusion, and if you're right that he was posting ironically that only proves that it causes confusion. As for the Spanish topic, I don't speak Spanish so can't look at it unfortunately.
Reply
#12

All right man, I won't push the issue anymore.
Reply
#13

Quote:
Originally Posted by JustBored
Посмотреть сообщение
Tampoco para tanto descanso flaco, fuera de joda. Esta bien, vos sos el terrible programador pero corte tampoco para cagarse en los demбs porque tipo yo ando aprendiendo. Recuerden que nadie nace sabiendo.
Translated:

Код:
Nor to break both, fuck off. Okay, you're a terrible programmer but not cut to shit on others because I'm learning type. Remember that no one is born knowing.
Why are you telling ****** to fuck off? It's constructive criticism! Cool include though, you should add an optional row ID parameter to the functions
Reply
#14

1) If you cannot take constructive criticism, you can't be a better programmer.
2) I was not making fun of anyone.
3) You said no one's born knowing and stuff - if you aren't, then you should start with something small. If you decide to release something, you better be prepared to be pointed out the loopholes in it.
4) Your swearing in spanish really shows how mature you are.
5) [OFF - TOPIC] If reputation being higher meant that the guy is well mannered, take a look at king_hual. (:P)
Reply
#15

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
Translated:

Код:
Nor to break both, fuck off. Okay, you're a terrible programmer but not cut to shit on others because I'm learning type. Remember that no one is born knowing.
Why are you telling ****** to fuck off? It's constructive criticism! Cool include though, you should add an optional row ID parameter to the functions
This usually happens when you use the ****** Translator. I'm Argentinian so we speak like that.
Ok in english would be:

Quote:

Why are you botheing dude?, okay you are the best scripter ever but that doesn't give you the right to bother everyone. Remember that anyone born knowing everything.

Ah, and i wasn't being ironic, so. Otherwise, usually the ****** Translator cause confusion.
Reply
#16

****** translate won't change everything what you wrote.
I believe "terrible programador" means terrible programmer.
Reply
#17

Quote:
Originally Posted by newbienoob
Посмотреть сообщение
****** translate won't change everything what you wrote.
I believe "terrible programador" means terrible programmer.
I honestly laughed out loud when he tried to evade by saying "****** usually translates like that, I meant the best programmer". I mean... that's low, man, that's low.
Reply
#18

I think this is starting to get seriously off topic. Could people please stick to discussing the contents of the include - merits and issues thereof!

Edit: When I said "Could people please" I meant "Do this or get an infraction for staying off topic".
Reply
#19

<removed - see my previous post, Y_Less>

ON T: I won't use this script. If I use it, I will not learn anything about mysql.
Reply
#20

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
I did expect a better attitude from someone with 13,000 posts and 1800+ rep.
Thought we had some good people in this community with appropriate attitude's, yet people like Rajat Pawar and Y_Less never fail to prove me wrong.

I see nothing but 2 people trying to push down someone who's trying. Is that how you teach or promote scripting?

'Nuff said, your posts speak enough about your attitude.

You may be the first place in SA-MP, but in the last place in life.
JustBorred should first test his include, then release it.

I don't see any reason why he should not get infraction.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)