10.11.2012, 16:16
Well, I just gave you an example of how to do it. It depends on if you are using it as a table or field.
pawn Код:
// An example of how I used it
// Deleting..
format( Query, sizeof( Query ), "DROP TABLE `CONTACT%d`", contact_id ); // It is supposed by a command or dialog (read it from there)
db_free_result( db_query( Database, Query ) );
for( new x = 0; x < Loaded_Contacts; x++ )
{
if( Loaded_Contacts == 1 ) break;
if( Loaded_Contacts == Is_Last_Contact ) break; // Is_Last_Contact = number of rows from a db_query or what MySQL uses
// Renaming `CONTACTS`
format( Query, sizeof( Query ), "SELECT * FROM `MOBILES` WHERE `CONTACT` = '%d'", x );
Result = db_query( Database, Query );
if( db_num_rows( Result ) )
{
print( "Results were found for loading contacts from database! Skipping.." );
continue;
}
else
{
print( "No results were found from database! Updating.." );
format( Query, sizeof( Query ), "UPDATE `MOBILES` SET CONTACT = '%d' WHERE `CONTACT` = '%d'", x, x + 1 );
db_free_result( db_query( Database, Query ) );
format( Query, sizeof( Query ), "ALTER TABLE `CONTACT%d` RENAME TO `CONTACT%d`", x + 1, x );
db_free_result( db_query( Database, Query ) );
}
}