DbExec: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ {{Server function}} {{New feature|3.0120|1.2| '''Available only in MTA SA 1.1.1 r3341 and onwards''' }} This function executes a database query using the supplied conn...") |
No edit summary |
||
Line 20: | Line 20: | ||
===Returns=== | ===Returns=== | ||
Returns ''true'' unless the connection is incorrect, in which case it | Returns ''true'' unless the connection is incorrect, in which case it returns ''false''. | ||
==Example== | ==Example== |
Revision as of 01:57, 4 November 2011
Available only in MTA SA 1.1.1 r3341 and onwards This function executes a database query using the supplied connection. No result is returned.
Syntax
bool dbExec ( element databaseConnection, string query [, var param1 [, var param2 ...]] )
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 escaped as required
Returns
Returns true unless the connection is incorrect, in which case it returns false.
Example
This example executes an INSERT query:
dbExec( connection, "INSERT INTO table_name VALUES (?,?,?)", "aaa", "bbb", 10 )
Requirements
This template will be deleted.
See Also