Squirrel/Server/Functions/SQLite/sqlite close

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
m
 
Line 13: Line 13:
 
== Example ==
 
== Example ==
  
Explanation here.
+
When the scripts unload, it will close the previously opened database.
{{Squirrel/NeedsExample}}
+
  
 
<code lang="squirrel">
 
<code lang="squirrel">
-- Todo
+
function onScriptLoad()
 +
{
 +
LoadModule( "lu_sqlite" );
 +
pSQDatabase <- sqlite_open( "database.sqlite" );
 +
 +
return 1;
 +
}
 +
 
 +
function onScriptUnload()
 +
{
 +
sqlite_close( pSQDatabase );
 +
 +
return 1;
 +
}
 
</code>
 
</code>
  
 
=== Notes ===
 
=== Notes ===
  
-- List of used functions and other notes here.
+
The function [[Squirrel/Server/Functions/Scripts/LoadModule|LoadModule]] and [[Squirrel/Server/Functions/SQLite/sqlite_open|sqlite_open]] and event [[Squirrel/Server/Events/Misc/onScriptLoad|onScriptLoad]] and [[Squirrel/Server/Events/Misc/onScriptUnload|onScriptUnload]] 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 16:45, 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 closes a previously opened SQLite database.

[edit] Syntax

  1. bool sqlite_close( UserPointer database )

[edit] Arguments

  • database - This is a pointer to a previously opened database

[edit] Example

When the scripts unload, it will close the previously opened database.

  1.  
  2. function onScriptLoad()
  3. {
  4. LoadModule( "lu_sqlite" );
  5. pSQDatabase <- sqlite_open( "database.sqlite" );
  6. return 1;
  7. }
  8.  
  9. function onScriptUnload()
  10. {
  11. sqlite_close( pSQDatabase );
  12. return 1;
  13. }
  14.  

[edit] Notes

The function LoadModule and sqlite_open and event onScriptLoad and onScriptUnload 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