sqlite_unbuffered_query

mIRC SQLite

sqlite_unbuffered_query
Executes a SQL query and returns data returned by it.
Syntax
$sqlite_unbuffered_query ( conn, query [, bind_value [, ... ] ] ) [ .file ]
/sqlite_unbuffered_query conn query
$sqlite_unbuffered_query ( statement [, bind_value [, ... ] ] )
/sqlite_unbuffered_query 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
A positive, numeric result identifier or 0 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.

Unbuffered queries work like regular queries, except that they produce a result set that isn't buffered in memory. Since the rows aren't buffered in memory, unbuffered queries are the optimal way to handle large set of sequental data because they're more efficient and the memory footprint is much smaller.
The trade off is that you can't random-access the unbuffered result set, like you can with buffered result sets. The following functions aren't supported on unbuffered results: sqlite_num_rows, sqlite_current, sqlite_current_bound, sqlite_result, sqlite_next, sqlite_prev, sqlite_has_more, sqlite_has_prev, sqlite_seek, sqlite_rewind and sqlite_key.

Remember to free the result with sqlite_free when done with the result set. If there's unfetched rows in the result set, and it isn't freed it might block other queries from executing.

In case of 0 is returned, it means that $sqlite_unbuffered_query was used to execute a query that doesn't return any data, such as INSERT or UPDATE.
A SELECT query always returns a result identifier on success, even if the query selected no rows. You can use $sqlite_num_rows to determine how many rows were returned.

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_unbuffered_query as an identifier.

$sqlite_unbuffered_query can execute multiple queries seperated by semicolons. The returned result is the data returned by the last SQL query.
To see guidelines for writing SQL queries with mIRC SQLite, see Writing Queries.

For an example, see $sqlite_query.