a_mysql inc problems
#1

Hey, I just started to script a new mode that running with MySQL, alright its connect to the MySQL and the regular commands of mysql are working fine but the new commands are not working.
For example: the mysql_Get doesn't work.
So I need help with this, I don't understand why that's not working !
thank you helpers
the Include:
Код:
/**
*
*			MySQL Native Functions
*	More information about the function usage at mysql.com
*
**/

#if defined mysql_included
	#endinput
#endif
#define mysql_included

//Definitions
new bool:SQL_Connection = false;
new F = false;
#if defined Query
#else
	#define Query(%1,%2) do { new formatStr[256]; format(formatStr,sizeof(formatStr),%1,%2); if(SQL_Connection) mysql_query(formatStr); mysql_store_result(); } while(F)
#endif
#pragma unused F
#define mysql_fetch_row(%1) mysql_fetch_row_format(%1,"|")
#define mysql_get_field(%1,%2) mysql_fetch_field_row(%2,%1)
//Native functions

native mysql_affected_rows(connectionHandle = 1);
native mysql_close(connectionHandle = 1);
native mysql_connect(const host[],const user[],const database[],const password[]);
native mysql_debug(enable = 1);
native mysql_errno(connectionHandle = 1);
native mysql_fetch_int(connectionHandle = 1);
native mysql_fetch_field(number,dest[],connectionHandle = 1);
native mysql_fetch_field_row(string[],const fieldname[],connectionHandle = 1);
native mysql_fetch_float(&Float:result,connectionHandle = 1);
native mysql_fetch_row_format(string[],const delimiter[] = "|",connectionHandle = 1);
native mysql_field_count(connectionHandle = 1);
native mysql_free_result(connectionHandle = 1);
native mysql_get_charset(destination[],connectionHandle = 1);
native mysql_insert_id(connectionHandle = 1);
native mysql_num_rows(connectionHandle = 1);
native mysql_num_fields(connectionHandle = 1);
native mysql_ping(connectionHandle = 1);
native mysql_query(query[],resultid = (-1),extraid = (-1),connectionHandle = 1);
native mysql_real_escape_string(const source[],destination[],connectionHandle = 1);
native mysql_reconnect(connectionHandle = 1);
native mysql_reload(connectionHandle = 1) = mysql_reconnect;
native mysql_retrieve_row(connectionHandle = 1);
native mysql_set_charset(charset[],connectionHandle = 1);
native mysql_stat(const destination[],connectionHandle = 1);
native mysql_store_result(connectionHandle = 1);
native mysql_warning_count(connectionHandle = 1);
/*
native GetID(table[],key[],value[]);
native mysql_Set(table[],id,key[],value[]);
native mysql_SetInt(table[],id,key[],value);
native mysql_SetFloat(table[],id,key[],Float:value);
native mysql_SetBool(table[],id,key[],bool:value);
native mysql_Get(table[],id,key[]);
native mysql_Float(table[],id,key[]);
native mysql_Bool(table[],id,key[]);
native mysql_Int(table[],id,key[]);
native mysql_Isset(table[],id);
native mysql_IssetVal(table[],key[]);
native mysql_CreateByInt(table[],key[],value);
native mysql_CreateByString(table[],key[],value[]);
native mysql_GetHighestID(table[]);
*/
//Callback

forward OnQueryFinish(query[], resultid, extraid, connectionHandle);

stock mysql_Set(table[],id,key[],value[])
{
	Query("UPDATE `%s` SET `%s` = '%s' WHERE `ID` = '%d'",table,key,value,id);
}
stock mysql_SetInt(table[],id,key[],value)
{
	new string[256];
	format(string,256,"%d",value);
	mysql_Set(table,id,key,string);
	return 1;
}
stock mysql_SetFloat(table[],id,key[],Float:value)
{
	new string[256];
	format(string,256,"%f",value);
	mysql_Set(table,id,key,string);
	return 1;
}
stock mysql_Get(table[],id,key[])
{
	Query("SELECT `%s` FROM `%s` WHERE `ID` = '%d'",key,table,id);
	new Result[128];
	mysql_fetch_row(Result);
	return Result;
}
stock mysql_GetHighestID(table[])
{
	Query("SELECT `ID` FROM `%s` ORDER BY `ID` DESC LIMIT 1",table);
	new Result[128];
	mysql_fetch_row(Result);
	return strval(Result);
}
stock Float:mysql_Float(table[],id,key[])
{
    return floatstr(mysql_Get(table,id,key));
}
stock mysql_Int(table[],id,key[])
{
	return strval(mysql_Get(table,id,key));
}
stock mysql_Isset(table[],id)
{
    Query("SELECT * FROM `%s` WHERE `ID` = '%d'",table,id);
    return mysql_num_rows() == 0? (0):(1);
}
stock mysql_IssetVal(table[],key[])
{
	Query("SELECT `%s` FROM `%s`",key,table);
	return mysql_field_count();
}
stock mysql_CreateByInt(table[],key[],value)
{
	Query("INSERT INTO `%s` (`%s`) VALUES ('%d')",table,key,value);
}
stock mysql_CreateByString(table[],key[],value[])
{
	Query("INSERT INTO `%s` (`%s`) VALUES ('%s')",table,key,value);
}
stock GetID(table[],key[],value[])
{
	Query("SELECT `ID` FROM `%s` WHERE `%s` = '%s'",table,key,value);
	return mysql_fetch_int();
}


stock mysql_Bool(table[],id,key[])
{
   return strval(mysql_Get(table,id,key));
}

stock mysql_SetBool(table[],id,key[],bool:value) 
{
	if (value) 
		return mysql_Set(table,id,key,"1");
	else
		return mysql_Set(table,id,key,"0");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)