Squirrel/Server/Functions/SQLite/sqlite column count
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example) |
|||
Line 29: | Line 29: | ||
{ | { | ||
local query = sqlite_query( pSQDatabase, "SELECT Foo FROM Bar WHERE FooBar='" + szText + "'" ); | local query = sqlite_query( pSQDatabase, "SELECT Foo FROM Bar WHERE FooBar='" + szText + "'" ); | ||
− | if ( query ) print( "Column count - " + | + | if ( query ) print( "Column count - " + sqlite_column_count( query ) ); |
} | } | ||
Latest revision as of 14:34, 27 July 2012
Note: This function requires the external module lu_sqlite.
This function returns the column count in the query result struct.
[edit] Syntax
int sqlite_column_count( UserPointer result )
[edit] Arguments
- result - This is a pointer to a result struct retrieved from sqlite_query or sqlite_next_row
[edit] Example
This will print the column count from the query when '/colcount' is typed into the server console.
function onScriptLoad() { LoadModule( "lu_sqlite" ); pSQDatabase <- sqlite_open( "database.sqlite" ); return 1; } function onConsoleInput( szCommand, szText ) { if ( szCommand == "colcount" ) { local query = sqlite_query( pSQDatabase, "SELECT Foo FROM Bar WHERE FooBar='" + szText + "'" ); if ( query ) print( "Column count - " + sqlite_column_count( query ) ); } return 1; }
[edit] 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.
[edit] Related Functions
These functions are provided by the official module lu_sqlite.
- sqlite_close
- sqlite_column_count
- sqlite_column_data
- sqlite_free
- sqlite_next_row
- sqlite_open
- sqlite_query