sqlite_next_row

From Liberty Unleashed Wiki
Jump to: navigation, search
Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events
Note: This function requires the external module lu_sqlite.

This function returns the next result row of the query result struct. If the query has no more result rows the function will return null, otherwise it will return a pointer to the next row.

Syntax

  1. UserPointer sqlite_next_row( UserPointer result )

Arguments

  • result - This is a pointer to a result struct retrieved from sqlite_query or another iteration of sqlite_next_row

Example

This will see if anymore data is in the results when 'nextrow' is typed 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 == "nextrow" )
  12. {
  13. local query = sqlite_query( pSQDatabase, "SELECT Foo FROM Bar WHERE FooBar='" + szText + "'" );
  14. if ( query )
  15. {
  16. local data = sqlite_column_data( query, 0 );
  17. if ( data )
  18. {
  19. print( "Result: " + data );
  20. local data2 = sqlite_next_row( data );
  21. if ( data2 ) print( "Result 2: " + data2 );
  22. else print( "No moar data found!" );
  23. }
  24. else print( "No data found!" );
  25. }
  26. }
  27. return 1;
  28. }
  29.  

Notes

The function LoadModule and sqlite_open and sqlite_query and print 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.

Related Functions

These functions are provided by the official module lu_sqlite.

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox