DbPrepareString

From Multi Theft Auto: Wiki
Revision as of 22:45, 4 January 2016 by Qaisjp (talk | contribs) (add page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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