mariadb prepare: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{Notice|This function is provided by the official MariaDB plugin.}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|mariadb_prepare(handle_id,..."
 
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 2: Line 2:
{{Notice|This function is provided by the official [[MariaDB]] plugin.}}
{{Notice|This function is provided by the official [[MariaDB]] plugin.}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Prepares a SQL statement with SQL-injection safe query.}}


{{FuncSyntax|mariadb_prepare(handle_id, format_str)}}
{{FuncSyntax|mariadb_prepare(handle_id, format_str)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|handle_id|__EDIT_ME__}}
{{FuncParam|handle_id|The databse handle identifier}}
{{FuncParam|format_str|__EDIT_ME__}}
{{FuncParam|format_str|The query to prepare}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|String with sql-injection safe query, or '''false''' if there's an error in query.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
local query = mariadb_prepare(db, "SELECT * FROM accounts WHERE steamid = ? LIMIT 1;",
    tostring(GetPlayerSteamId(player))
)
mariadb_async_query(db, query, OnAccountLoad, player)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
{{Template:MariaDBFunctions}}

Latest revision as of 09:13, 2 September 2020

mariadb prepare

Type: Function
Context: Server
Introduced: v1.0

NOTICE

This function is provided by the official MariaDB plugin.

Description

Prepares a SQL statement with SQL-injection safe query.

Syntax

mariadb_prepare(handle_id, format_str)

Parameters

  • handle_id
    The databse handle identifier
  • format_str
    The query to prepare

Return Value

  • String with sql-injection safe query, or false if there's an error in query.

Example

local query = mariadb_prepare(db, "SELECT * FROM accounts WHERE steamid = ? LIMIT 1;",
    tostring(GetPlayerSteamId(player))
)
mariadb_async_query(db, query, OnAccountLoad, player)

See also