[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


Messages In This Thread
j_mysql Easiest utilization of MySQL [R7] - by JustBored - 12.05.2013, 14:50
Re: j_mysql Easiest utilization of MySQL [R7] - by RajatPawar - 12.05.2013, 16:23
Re: j_mysql Easiest utilization of MySQL [R7] - by RajatPawar - 12.05.2013, 16:27
Re: j_mysql Easiest utilization of MySQL [R7] - by RajatPawar - 12.05.2013, 16:32
Respuesta: j_mysql Easiest utilization of MySQL [R7] - by JustBored - 12.05.2013, 17:12
Re: j_mysql Easiest utilization of MySQL [R7] - by richardcor91 - 13.05.2013, 00:26
Re: j_mysql Easiest utilization of MySQL [R7] - by Y_Less - 13.05.2013, 00:38
Re: j_mysql Easiest utilization of MySQL [R7] - by richardcor91 - 13.05.2013, 00:47
Re: Respuesta: j_mysql Easiest utilization of MySQL [R7] - by Y_Less - 13.05.2013, 00:59
Re: Respuesta: j_mysql Easiest utilization of MySQL [R7] - by richardcor91 - 13.05.2013, 01:19
Re: j_mysql Easiest utilization of MySQL [R7] - by Y_Less - 13.05.2013, 01:22
Re: j_mysql Easiest utilization of MySQL [R7] - by richardcor91 - 13.05.2013, 01:26
Re: Respuesta: j_mysql Easiest utilization of MySQL [R7] - by Emmet_ - 13.05.2013, 03:47
Re: j_mysql Easiest utilization of MySQL [R7] - by RajatPawar - 13.05.2013, 05:54
Respuesta: Re: Respuesta: j_mysql Easiest utilization of MySQL [R7] - by JustBored - 13.05.2013, 06:16
Re: j_mysql Easiest utilization of MySQL [R7] - by newbienoob - 13.05.2013, 07:40
Re: j_mysql Easiest utilization of MySQL [R7] - by KingHual - 13.05.2013, 07:52
Re: j_mysql Easiest utilization of MySQL [R7] - by Y_Less - 13.05.2013, 08:22
Re: j_mysql Easiest utilization of MySQL [R7] - by newbienoob - 13.05.2013, 11:25
Re: j_mysql Easiest utilization of MySQL [R7] - by Yiin - 13.05.2013, 11:26
Re: j_mysql Easiest utilization of MySQL [R7] - by CreativityLacker - 13.05.2013, 11:28
Re: j_mysql Easiest utilization of MySQL [R7] - by Y_Less - 13.05.2013, 14:06
Respuesta: Re: j_mysql Easiest utilization of MySQL [R7] - by JustBored - 13.05.2013, 16:17
Re: j_mysql Easiest utilization of MySQL [R7] - by nGen.SoNNy - 13.05.2013, 18:57
Respuesta: j_mysql Easiest utilization of MySQL [R7] - by JustBored - 13.05.2013, 20:09
Re: j_mysql Easiest utilization of MySQL [R7] - by Riddy - 13.05.2013, 20:35
Respuesta: j_mysql Easiest utilization of MySQL [R7] - by JustBored - 13.05.2013, 20:40

Forum Jump:


Users browsing this thread: 1 Guest(s)