MySQL Question
#1

Am I doing this right, and could someone give me some advice as to what I could be doing better? I'm brand new to using MySQL in PAWN, so I'm having a pretty hard time adjusting.

pawn Код:
new
    connectionHandle;

public OnGameModeInit()
{
    mysql_debug( true );
   
    connectionHandle = mysql_connect("localhost", "sky", "samp", "lol");
   
    mysql_function_query( connectionHandle, "SELECT * FROM `mine`", true, "OnPlayerSelected", "");
   
    SetGameModeText("Anarchy");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

forward OnPlayerSelected( );
public OnPlayerSelected( )
{
    mysql_function_query( connectionHandle, "UPDATE `mine` SET `lol` = 1 WHERE `lol` = 16", false, "", "" );
    return true;
}
From what I can understand, this query thing basically works like SetTimerEx, you pass the parameters then your callback picks them up and you do the rest of your things in there.. If someone could explain it in lamens terms, that'd be like.. perfect.
Reply
#2

PHP код:
new var[2];
forward OnPlayerSelected( );
public 
OnPlayerSelected( )
{
    new 
rowsfields;
    
cache_get_datarowsfields ); // fetch how many results, and fields the query returned.
    
    
if( rows ) { // if there are rows
        
new content20 ]; // new string to hold the values from the database
        
        
for( new row 0row rowsrow++ ) { // loop through all the rows, like looping through a file almost
            
            
cache_get_field_contentrow"Field1"content );  // get Field1 and store it into content
            
var[ ] = strvalcontent ); // self explanatory
            
            
cache_get_field_content(row"Field2"content); // get Field2 and store it into content
            
var[ ] = strvalcontent ); // same thing
        
}
    }
    return 
true;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)