Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: MaTaDeToR on Nov 15, 2017, 07:41 AM

Title: Get SQLColumn Data
Post by: MaTaDeToR on Nov 15, 2017, 07:41 AM
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... }
Title: Re: Get SQLColumn Data
Post by: ! on Nov 16, 2017, 08:28 AM
Might be these links helps
MySQL (https://bitbucket.org/stormeus/0.4-mysql/src/e59bbcdf740924619639afdb7af73dd509510248?at=master)
SQL (https://bitbucket.org/stormeus/0.4-sqlite/src)

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;
}
Title: Re: Get SQLColumn Data
Post by: KAKAN on Nov 16, 2017, 08:29 AM
I don't see how you call that code as "written for squirrel compiler"
Title: Re: Get SQLColumn Data
Post by: MaTaDeToR on Nov 17, 2017, 08:37 PM
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?