forked from Limework/skript-db
Add experimental support for SkriptDoclet
This commit is contained in:
@@ -31,6 +31,23 @@ import ch.njol.skript.lang.VariableString;
|
||||
import ch.njol.skript.variables.Variables;
|
||||
import ch.njol.util.Kleenean;
|
||||
|
||||
/**
|
||||
* Executes a statement on a database and optionally stores the result in a variable. Expressions
|
||||
* embedded in the query will be escaped to avoid SQL injection.
|
||||
*
|
||||
* If a single variable, such as `{test}`, is passed, the variable will be set to the number of
|
||||
* affected rows.
|
||||
*
|
||||
* If a list variable, such as `{test::*}`, is passed, the query result will be mapped to the list
|
||||
* variable in the form `{test::<column name>::<row number>}`
|
||||
*
|
||||
* @name Execute Statement
|
||||
* @pattern execute %string% (in|on) %datasource% [and store [[the] (output|result)[s]] (to|in)
|
||||
* [the] [var[iable]] %-objects%]
|
||||
* @example execute "select * from table" in {sql} and store the result in {output::*}
|
||||
* @example execute "select * from %{table variable}%" in {sql} and store the result in {output::*}
|
||||
* @since 0.1.0
|
||||
*/
|
||||
public class EffExecuteStatement extends Delay {
|
||||
static {
|
||||
Skript.registerEffect(EffExecuteStatement.class,
|
||||
@@ -169,7 +186,7 @@ public class EffExecuteStatement extends Delay {
|
||||
while (crs.next()) {
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
setVariable(e, baseVariable + meta.getColumnLabel(i).toLowerCase(Locale.ENGLISH)
|
||||
+ Variable.SEPARATOR + rowNumber, crs.getObject(i));
|
||||
+ Variable.SEPARATOR + rowNumber, crs.getObject(i));
|
||||
}
|
||||
rowNumber++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user