• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Best way to load data from db using sscanf
#1
Question 
I'm trying to improve the efficiency of the script when logging in and I have a question.

Is there a better method compared to the example below,?to load the data from the database?





Code:
cache_get_value_name( 0, "Table", result_70 ); format( str_70, sizeof str_70, result_70 );

sscanf( str_70, "p<|>iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii",

playerVariable[ playerid ][ pTable ][ 0 ], playerVariable[ playerid ][ pTable ][ 1 ], playerVariable[ playerid ][ pTable ][ 2 ],

playerVariable[ playerid ][ pTable ][ 3 ], playerVariable[ playerid ][ pTable ][ 4 ], playerVariable[ playerid ][ pTable ][ 5 ],

playerVariable[ playerid ][ pTable ][ 6 ], playerVariable[ playerid ][ pTable ][ 7 ], playerVariable[ playerid ][ pTable ][ 8 ],

playerVariable[ playerid ][ pTable ][ 9 ], playerVariable[ playerid ][ pTable ][ 10 ], playerVariable[ playerid ][ pTable ][ 11 ],

playerVariable[ playerid ][ pTable ][ 12 ], playerVariable[ playerid ][ pTable ][ 13 ], playerVariable[ playerid ][ pTable ][ 14 ],

playerVariable[ playerid ][ pTable ][ 15 ], playerVariable[ playerid ][ pTable ][ 16 ], playerVariable[ playerid ][ pTable ][ 17 ],

playerVariable[ playerid ][ pTable ][ 18 ], playerVariable[ playerid ][ pTable ][ 19 ], playerVariable[ playerid ][ pTable ][ 20 ],

playerVariable[ playerid ][ pTable ][ 21 ], playerVariable[ playerid ][ pTable ][ 22 ], playerVariable[ playerid ][ pTable ][ 23 ],

playerVariable[ playerid ][ pTable ][ 24 ], playerVariable[ playerid ][ pTable ][ 25 ], playerVariable[ playerid ][ pTable ][ 26 ],

playerVariable[ playerid ][ pTable ][ 27 ], playerVariable[ playerid ][ pTable ][ 28 ], playerVariable[ playerid ][ pTable ][ 29 ],

playerVariable[ playerid ][ pTable ][ 30 ], playerVariable[ playerid ][ pTable ][ 31 ], playerVariable[ playerid ][ pTable ][ 32 ],

playerVariable[ playerid ][ pTable ][ 33 ], playerVariable[ playerid ][ pTable ][ 34 ], playerVariable[ playerid ][ pTable ][ 35 ],

playerVariable[ playerid ][ pTable ][ 36 ], playerVariable[ playerid ][ pTable ][ 37 ], playerVariable[ playerid ][ pTable ][ 38 ],

playerVariable[ playerid ][ pTable ][ 39 ], playerVariable[ playerid ][ pTable ][ 40 ], playerVariable[ playerid ][ pTable ][ 41 ],

playerVariable[ playerid ][ pTable ][ 42 ], playerVariable[ playerid ][ pTable ][ 43 ], playerVariable[ playerid ][ pTable ][ 44 ],

playerVariable[ playerid ][ pTable ][ 45 ], playerVariable[ playerid ][ pTable ][ 46 ], playerVariable[ playerid ][ pTable ][ 47 ],

playerVariable[ playerid ][ pTable ][ 48 ], playerVariable[ playerid ][ pTable ][ 49 ] );



In database: Varchar, Lenght 70, As defined 0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
  Reply
#2
The better version of this is database normalization which implies you make for every value you need a column. Does the data is duplicate(eg: weapon1 weapon2 etc) then make a dedicated table for it with at least 2 column (ownerid and weapon) and every row will mean that x owner has y weapon which will mean you need join and forgein keys

But anyway, red about database normalization: https://en.m.wikipedia.org/wiki/Database_normalization
Away
  Reply


Forum Jump: