Squirrel/Server/Functions/SQLite/sqlite free

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
 
Line 38: Line 38:
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Server/Functions/Scripts/LoadModule|LoadModule]] and [[Squirrel/Server/Functions/SQLite/sqlite_open|sqlite_open]] and and event [[Squirrel/Server/Events/Misc/onScriptLoad|onScriptLoad]] and [[Squirrel/Server/Events/Misc/onConsoleInput|onConsoleInput]] were used in this example. More info about them in the corresponding pages.
+
The function [[Squirrel/Server/Functions/Scripts/LoadModule|LoadModule]] and [[Squirrel/Server/Functions/SQLite/sqlite_open|sqlite_open]] and [[Squirrel/Server/Functions/SQLite/sqlite_open|sqlite_query]] and event [[Squirrel/Server/Events/Misc/onScriptLoad|onScriptLoad]] and [[Squirrel/Server/Events/Misc/onConsoleInput|onConsoleInput]] were used in this example. More info about them in the corresponding pages.
  
 
For a larger example, check the [[Squirrel/Examples/SQLite|SQLite database example]] from the wiki tutorials.
 
For a larger example, check the [[Squirrel/Examples/SQLite|SQLite database example]] from the wiki tutorials.

Latest revision as of 17:04, 25 October 2010

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
Note: This function requires the external module lu_sqlite.

This function frees a previously used query struct. This function should always be used after the query result has been processed to avoid any memory leaks.

[edit] Syntax

  1. bool sqlite_free( UserPointer result )

[edit] Arguments

[edit] Example

This will free the carried out query from the memory when 'free' is type into the server console.

  1.  
  2. function onScriptLoad()
  3. {
  4. LoadModule( "lu_sqlite" );
  5. pSQDatabase <- sqlite_open( "database.sqlite" );
  6. return 1;
  7. }
  8.  
  9. function onConsoleInput( szCommand, szText )
  10. {
  11. if ( szCommand == "free" )
  12. {
  13. local query = sqlite_query( pSQDatabase, "SELECT Foo FROM Bar WHERE FooBar='" + szText + "'" );
  14. sqlite_free( query );
  15. }
  16. return 1;
  17. }
  18.  

[edit] Notes

The function LoadModule and sqlite_open and sqlite_query and event onScriptLoad and onConsoleInput were used in this example. More info about them in the corresponding pages.

For a larger example, check the SQLite database example from the wiki tutorials.

[edit] Related Functions

These functions are provided by the official module lu_sqlite.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox