Scripting/Squirrel/Functions/GetSQLColumnData: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
(Created page with "Get a result row as a string. == Syntax == <pre>GetSQLColumnData( query, columnNumber )</pre> == Arguments == * '''query''' - Name of the previously executed query. * ''...")
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 15: Line 15:
== Example ==
== Example ==


<pre>local c = ConnectSQL("db.db");
<source lang=lua>local db = ConnectSQL( "db.db" );
local d = QuerySQL(c,"SELECT Cash FROM Accounts WHERE Name='KAKAN'"), e = GetSQLColumnData( d, 0 );
local query = QuerySQL( db, "SELECT Cash FROM Accounts WHERE Name='KAKAN'" );
if( e ) print( "KAKAN has " + e + "$" );
if ( query ) {
</pre>
local data = GetSQLColumnData( query, 0 );
if( data ) print( "KAKAN has " + data + "$" );
FreeSQLQuery( query );
}</source>
 
== Related Functions ==
 
{{Scripting/Squirrel/Functions/SQLite Functions}}
[[Category:Scripting/Squirrel/Functions/SQLite _Functions]]

Latest revision as of 08:00, 20 July 2019

Get a result row as a string.

Syntax

GetSQLColumnData( query, columnNumber )

Arguments

  • query - Name of the previously executed query.
  • columnNumber - Number of the column you want to get data of.

Return value

  • The data in the column and/or null on failure

Example

local db = ConnectSQL( "db.db" );
local query = QuerySQL( db, "SELECT Cash FROM Accounts WHERE Name='KAKAN'" );
if ( query ) {
	local data = GetSQLColumnData( query, 0 );
	if( data ) print( "KAKAN has " + data + "$" );
	FreeSQLQuery( query );
}

Related Functions