sqlite_exec
Executes a result-less SQL query.
Syntax
$sqlite_exec ( conn, query [, bind_value [, ... ] ] ) [ .file ]
/sqlite_exec conn query $sqlite_exec ( statement [, bind_value [, ... ] ] ) /sqlite_exec statement [ bind_value [ ... ] ] |
Parameters
conn
The connection identifier.
query
The query to execute.
statement
A prepared statement to execute.
bind_value
Optional. One or more values to bind to the query.
Properties
file
Optional. If specified the query parameter is treated as a filename instead, and that file will be executed as SQL.
Return Value
1 on success, or $null if there was an error.
Remarks
To execute a prepared statement, first prepare it with $sqlite_prepare.To learn about prepared statements and binding values, see Prepared Statements.
If $null is returned you can determine the exact reason for the error by checking the value of %sqlite_errstr.
For more information about error handling, see Handling Errors
Note that if you want to bind a text value with more than one word, you must use the identifier form of syntax. If you don't care about the return value, you can use the built-in mIRC command /noop
Starting from mSQLite version 1.2.0 you can bind values even for non-prepared statements, but this only works when calling $sqlite_exec as an identifier.
$sqlite_exec can execute multiple queries seperated by semicolons.
To see guidelines for writing SQL queries with mIRC SQLite, see Writing Queries.
Example
; Inserts data to a table, assumes that a db connection is already established
var %sql = INSERT INTO table (key, value) VALUES ('version', '1.0.0') if ($sqlite_exec(%db, %sql)) { echo -a Query executed succesfully. } else { echo -a Error executing query: %sqlite_errstr } |