Scripting/Squirrel/Functions/QuerySQL: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "{{Scripting/Needs_Text}} == Syntax == To query a database you need to use something like <source lang=javascript>QuerySQL( database, SQLstring );</source> {{Scripting/Needs_...")
 
(Add an example and description)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Scripting/Needs_Text}}
This function will send a query to the database.
== Syntax ==
<source lang=squirrel>QuerySQL(database, queryString);</source>


== Syntax ==
== Arguments ==
To query a database you need to use something like
* ''SQLiteDB'' '''database''' - The database to query
<source lang=javascript>QuerySQL( database, SQLstring );</source>
* ''string'' '''queryString''' - The SQL query to send
 
 
== Example ==
<source lang=squirrel>
function onScriptLoad() {
  db <- ConnectSQL("scripts/keybinds.db");
  if (!db) {
    print("ERROR: SQLite database file could not be opened");
  }
  QuerySQL(db, "CREATE TABLE IF NOT EXISTS players(name TEXT, password TEXT, " +
          "level INTEGER, PRIMARY KEY(name,password));");
}
</source>
=== Notes ===
Calls [[onScriptLoad]], [[ConnectSQL]] and [[print]] were used in this example. More info about them in the corresponding pages.
 
== Related Functions ==


{{Scripting/Needs_Example}}
{{Scripting/Squirrel/Functions/SQLite Functions}}
[[Category:Scripting/Squirrel/Functions/SQLite _Functions]]

Latest revision as of 10:24, 26 April 2019

This function will send a query to the database.

Syntax

QuerySQL(database, queryString);

Arguments

  • SQLiteDB database - The database to query
  • string queryString - The SQL query to send


Example

function onScriptLoad() {
  db <- ConnectSQL("scripts/keybinds.db");
  if (!db) {
    print("ERROR: SQLite database file could not be opened");
  }
  QuerySQL(db, "CREATE TABLE IF NOT EXISTS players(name TEXT, password TEXT, " +
           "level INTEGER, PRIMARY KEY(name,password));");
}

Notes

Calls onScriptLoad, ConnectSQL and print were used in this example. More info about them in the corresponding pages.

Related Functions