DbPrepareString: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (bump revision)
No edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{Server function}}
{{Server function}}
{{New items|3.0160|1.6|
{{New items|3.0152|1.5.2|
This function "prepares" an SQL query string, returning a string that can be used in other SQL functions. This is useful if you need to reuse queries multiple times, but also need arguments to be escaped. This is helpful in preventing (one class of) SQL injection.
This function "prepares" an SQL query string, returning a string that can be used in other SQL functions. This is useful if you need to reuse queries multiple times, but also need arguments to be escaped. This is helpful in preventing (one class of) SQL injection.
|7745}}
}}


==Syntax==  
==Syntax==  

Revision as of 16:52, 14 January 2016

This function "prepares" an SQL query string, returning a string that can be used in other SQL functions. This is useful if you need to reuse queries multiple times, but also need arguments to be escaped. This is helpful in preventing (one class of) SQL injection.

Syntax

string dbPrepareString ( element databaseConnection, string query [, var param1 [, var param2 ...]] )

OOP Syntax Help! I don't understand this!

Method: connection:prepareString(...)


Required Arguments

  • databaseConnection: A database connection element previously returned from dbConnect
  • query: An SQL query. Positions where parameter values will be inserted are marked with a ?

Optional Arguments

  • paramX: A variable number of parameters. These must be strings or numbers - it is important to make sure they are of the correct type. Also, the number of parameters passed must be equal to the number of ? characters in the query string.

String parameters are automatically quoted and escaped as required. (If you do not want a string quoted, use ??)

Returns

Returns a prepare SQL query string, or false if an error occurred.

Example

Accessories-text-editor.png Script Example Missing Function DbPrepareString needs a script example, help out by writing one.

Before submitting check out Editing Guidelines Script Examples.
-- TODO


See Also