12.05.2013, 14:50
(
Последний раз редактировалось JustBored; 12.05.2013 в 17:14.
)
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
Код:
(MySQL_Host[], MySQL_User[], MySQL_Database[], MySQL_Password[], Table[])
Example:
pawn Код:
public OnGameModeInit()
{
MySQL_ConnectTo("localhost","root", "db", "", "Hello");
return 1;
}
- MySQL_Switch_Table
Код:
(table[])
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
Код:
(row[], torow[], type[], lenght)
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
Код:
(name[], newname[])
newname = The new name of the table.
Example:
pawn Код:
stock SwitchName()
{
Table_Rename("table", "table2");
SetTimer("SwitchName", 60000*30, false);
return 1;
}
- Drop_Table
Код:
(tablename[])
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
Код:
(column[])
The idea of this function is to drop any column that is useful.
- MySQL_Insert
Код:
(field[],field1[],field2[], field3[], value[],value1[],value2[],value3[])
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
Код:
(field[], string[])
string = The text to insert.
The idea of this function is to insert a string in a row.
- MySQL_Float
Код:
(field[], Float:float)
Float:float = The float to insert.
- MySQL_Int
Код:
(field, int)
int = The integrer to input.
- MySQL_Close_All
Код:
(N/A)
Bugs:
N/A
Descarga:
This include uses the R7 MySQL Plugin of BlueG (post) also the a_mysql.inc that comes with the include.