- Added query_logsql script command to perform sql commands using the log db connection.
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11892 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
4adcab437f
commit
9d353fba9b
@ -3,6 +3,9 @@ Date Added
|
|||||||
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
|
AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
|
||||||
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
|
||||||
|
|
||||||
|
2007/12/11
|
||||||
|
* Added query_logsql script command to perform sql commands using the log
|
||||||
|
db connection.
|
||||||
2007/12/10
|
2007/12/10
|
||||||
* Cleaned up clif_setdisguise and fixed it for PACKETVER>=9.
|
* Cleaned up clif_setdisguise and fixed it for PACKETVER>=9.
|
||||||
* Added missing range/skill-mask info to reflected damage (fixes autospells
|
* Added missing range/skill-mask info to reflected damage (fixes autospells
|
||||||
|
@ -92,6 +92,8 @@
|
|||||||
//= Added script function 'strnpcinfo' [ultramage]
|
//= Added script function 'strnpcinfo' [ultramage]
|
||||||
//= 3.10.20071122
|
//= 3.10.20071122
|
||||||
//= Added setnpcdisplay. [FlavioJS]
|
//= Added setnpcdisplay. [FlavioJS]
|
||||||
|
//= 3.10.20071211
|
||||||
|
//= Added query_logsql. [Skotlex]
|
||||||
//===== Description =======================================
|
//===== Description =======================================
|
||||||
//= A reference manual for the eAthena scripting language,
|
//= A reference manual for the eAthena scripting language,
|
||||||
//= sorted out depending on their functionality.
|
//= sorted out depending on their functionality.
|
||||||
@ -5953,6 +5955,7 @@ set @i, distance(100,200,101,202);
|
|||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
*query_sql "your MySQL query", <array variable> {,<array variable>, ...};
|
*query_sql "your MySQL query", <array variable> {,<array variable>, ...};
|
||||||
|
*query_logsql "your MySQL query", <array variable> {,<array variable>, ...};
|
||||||
|
|
||||||
Puts up to 128 rows of values into the arrays and returns the number of rows.
|
Puts up to 128 rows of values into the arrays and returns the number of rows.
|
||||||
|
|
||||||
@ -5967,6 +5970,9 @@ mes "5."+@name$[4]+"("+@fame[4]+")";
|
|||||||
|
|
||||||
Note: In the TXT version it doesn't fill the array and always return -1.
|
Note: In the TXT version it doesn't fill the array and always return -1.
|
||||||
Note: Use $ as suffix in the array to receive all data as text.
|
Note: Use $ as suffix in the array to receive all data as text.
|
||||||
|
Note: The difference between query_sql and query_logsql is that the latter
|
||||||
|
uses the sql connection to the log database, and should be used when you want
|
||||||
|
to query the server log tables.
|
||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
@ -11651,9 +11651,9 @@ BUILDIN_FUNC(setd)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BUILDIN_FUNC(query_sql)
|
|
||||||
{
|
|
||||||
#ifndef TXT_ONLY
|
#ifndef TXT_ONLY
|
||||||
|
int buildin_query_sql_sub(struct script_state* st, Sql* handle)
|
||||||
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
TBL_PC* sd = NULL;
|
TBL_PC* sd = NULL;
|
||||||
const char* query;
|
const char* query;
|
||||||
@ -11695,22 +11695,22 @@ BUILDIN_FUNC(query_sql)
|
|||||||
|
|
||||||
// Execute the query
|
// Execute the query
|
||||||
query = script_getstr(st,2);
|
query = script_getstr(st,2);
|
||||||
if( SQL_ERROR == Sql_QueryStr(mmysql_handle, query) )
|
if( SQL_ERROR == Sql_QueryStr(handle, query) )
|
||||||
{
|
{
|
||||||
Sql_ShowDebug(mmysql_handle);
|
Sql_ShowDebug(handle);
|
||||||
script_pushint(st, 0);
|
script_pushint(st, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Sql_NumRows(mmysql_handle) == 0 )
|
if( Sql_NumRows(handle) == 0 )
|
||||||
{// No data received
|
{// No data received
|
||||||
Sql_FreeResult(mmysql_handle);
|
Sql_FreeResult(handle);
|
||||||
script_pushint(st, 0);
|
script_pushint(st, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of columns to store
|
// Count the number of columns to store
|
||||||
num_cols = Sql_NumColumns(mmysql_handle);
|
num_cols = Sql_NumColumns(handle);
|
||||||
if( num_vars < num_cols )
|
if( num_vars < num_cols )
|
||||||
{
|
{
|
||||||
ShowWarning("script:query_sql: Too many columns, discarding last %u columns.\n", (unsigned int)(num_cols-num_vars));
|
ShowWarning("script:query_sql: Too many columns, discarding last %u columns.\n", (unsigned int)(num_cols-num_vars));
|
||||||
@ -11723,14 +11723,14 @@ BUILDIN_FUNC(query_sql)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store data
|
// Store data
|
||||||
for( i = 0; i < max_rows && SQL_SUCCESS == Sql_NextRow(mmysql_handle); ++i )
|
for( i = 0; i < max_rows && SQL_SUCCESS == Sql_NextRow(handle); ++i )
|
||||||
{
|
{
|
||||||
for( j = 0; j < num_vars; ++j )
|
for( j = 0; j < num_vars; ++j )
|
||||||
{
|
{
|
||||||
char* str = NULL;
|
char* str = NULL;
|
||||||
|
|
||||||
if( j < num_cols )
|
if( j < num_cols )
|
||||||
Sql_GetData(mmysql_handle, j, &str, NULL);
|
Sql_GetData(handle, j, &str, NULL);
|
||||||
|
|
||||||
data = script_getdata(st, j+3);
|
data = script_getdata(st, j+3);
|
||||||
name = reference_getname(data);
|
name = reference_getname(data);
|
||||||
@ -11740,21 +11740,39 @@ BUILDIN_FUNC(query_sql)
|
|||||||
setd_sub(st, sd, name, i, (void *)(str?atoi(str):0), reference_getref(data));
|
setd_sub(st, sd, name, i, (void *)(str?atoi(str):0), reference_getref(data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( i == max_rows && max_rows < Sql_NumRows(mmysql_handle) )
|
if( i == max_rows && max_rows < Sql_NumRows(handle) )
|
||||||
{
|
{
|
||||||
ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (unsigned int)Sql_NumRows(mmysql_handle));
|
ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (unsigned int)Sql_NumRows(handle));
|
||||||
script_reportsrc(st);
|
script_reportsrc(st);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free data
|
// Free data
|
||||||
Sql_FreeResult(mmysql_handle);
|
Sql_FreeResult(handle);
|
||||||
script_pushint(st, i);
|
script_pushint(st, i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
BUILDIN_FUNC(query_sql)
|
||||||
|
{
|
||||||
|
#ifndef TXT_ONLY
|
||||||
|
return buildin_query_sql_sub(st, mmysql_handle);
|
||||||
#else
|
#else
|
||||||
//for TXT version, we always return -1
|
//for TXT version, we always return -1
|
||||||
script_pushint(st,-1);
|
script_pushint(st,-1);
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
BUILDIN_FUNC(query_logsql)
|
||||||
|
{
|
||||||
|
#ifndef TXT_ONLY
|
||||||
|
return buildin_query_sql_sub(st, logmysql_handle);
|
||||||
|
#else
|
||||||
|
//for TXT version, we always return -1
|
||||||
|
script_pushint(st,-1);
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//Allows escaping of a given string.
|
//Allows escaping of a given string.
|
||||||
@ -13226,6 +13244,7 @@ struct script_function buildin_func[] = {
|
|||||||
BUILDIN_DEF(getmonsterinfo,"ii"), //Lupus
|
BUILDIN_DEF(getmonsterinfo,"ii"), //Lupus
|
||||||
BUILDIN_DEF(axtoi,"s"),
|
BUILDIN_DEF(axtoi,"s"),
|
||||||
BUILDIN_DEF(query_sql,"s*"),
|
BUILDIN_DEF(query_sql,"s*"),
|
||||||
|
BUILDIN_DEF(query_logsql,"s*"),
|
||||||
BUILDIN_DEF(escape_sql,"s"),
|
BUILDIN_DEF(escape_sql,"s"),
|
||||||
BUILDIN_DEF(atoi,"s"),
|
BUILDIN_DEF(atoi,"s"),
|
||||||
// [zBuffer] List of player cont commands --->
|
// [zBuffer] List of player cont commands --->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user