Get SQLColumn Data

Started by MaTaDeToR, Nov 15, 2017, 07:41 AM

Previous topic - Next topic

MaTaDeToR

Hey, Everyone! Well, I do know It's quite of an off topic, but I really apologize for breaking the terms, and condition, but honestly, I require your urgent help. "GetSQLColumnData" is a common function found in VCMP, but is there anyway that we can construct a function of It with fully SQL coding? If anyone would tell me how to do It or particularly perform It over here, I'd really appreciate It.
like  function GetSQLColumnData( DB, number ) { ....Whole code over here... }

!

Might be these links helps
MySQL
SQL

Quote_SQUIRRELDEF( GetSQLColumnData )
{
SQInteger argc = sq->gettop( v );
if( argc == 3 && sq->gettype( v, 2 ) == OT_USERPOINTER )
{
// Obtain pointer
SQUserPointer pData;
sq->getuserpointer( v, 2, &pData );

if( pData != NULL )
{
// Cast to sqlite3_stmt**
sqlite3_stmt ** pStmt = (sqlite3_stmt **)(pData);
if( pStmt != NULL && *pStmt != NULL )
{
// Get the column index
SQInteger colIdx;
sq->getinteger( v, 3, &colIdx );

// Get the type of column
if( colIdx >= 0 )
{
switch( sqlite3_column_type( *pStmt, colIdx ) )
{
case SQLITE_INTEGER:
sq->pushinteger( v, sqlite3_column_int( *pStmt, colIdx ) );
return 1;

case SQLITE_FLOAT:
sq->pushfloat( v, sqlite3_column_double( *pStmt, colIdx ) );
return 1;

case SQLITE_TEXT:
case SQLITE_BLOB:
sq->pushstring( v, (char *)sqlite3_column_text( *pStmt, colIdx ), -1 );
return 1;

// Thanks to coincidental program flow, if we just break here,
// the program will treat SQLITE_NULL the same as an error and
// push a null value for us anyway.
case SQLITE_NULL:
default:
break;
}
}
}
}
}

sq->pushnull( v );
return 1;
}

Discord: zeus#5155

KAKAN

I don't see how you call that code as "written for squirrel compiler"
oh no

MaTaDeToR

Particularly, the code that I want is shared by zeus, but Its taken from a module. Now the thing I really want is that the code should be scripted in a .nut file( I.e function GetSQLColumnData( DB_Number ).....I dont want a module code. ( Actually I want GetSQLColumnData for Gta IV multuplayer as Its very limited and I dont know how to construct the GetSQLColumnData over there, or in a module ) if creating a module with this code is a possibility( the one zeus shared ) to make It work with Gta IV Multiplayer, It would be appreciated if you tell me how to do so?