You can optimize this code?
#1

I wonder if this code can be optimized?

PHP код:
    new componentes[70]; 
    
cache_get_field_content(0"vComponentes"componentesmysqlsizeof(componentes)); 
    
sscanf(componentes"p<|>iiiiiiiiiiiiii"
    
VehInfo[i][vComponentes][0], VehInfo[i][vComponentes][1], VehInfo[i][vComponentes][2], VehInfo[i][vComponentes][3], VehInfo[i][vComponentes][4], 
    
VehInfo[i][vComponentes][5], VehInfo[i][vComponentes][6], VehInfo[i][vComponentes][7], VehInfo[i][vComponentes][8], VehInfo[i][vComponentes][9], 
    
VehInfo[i][vComponentes][10], VehInfo[i][vComponentes][11], VehInfo[i][vComponentes][12], VehInfo[i][vComponentes][13]); 
Reply
#2

Harder, better option: Use normalized tables for components - do not store them in a single field!

Dirty, quick option:
https://sampforum.blast.hk/showthread.php?tid=602923

pawn Код:
sscanf(componentes, "p<|>a<i>[13]", VehInfo[i][vComponentes]);
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Harder, better option: Use normalized tables for components - do not store them in a single field!

Dirty, quick option:
https://sampforum.blast.hk/showthread.php?tid=602923

pawn Код:
sscanf(componentes, "p<|>a<i>[13]", VehInfo[i][vComponentes]);
So I have to create 14 columns?
Reply
#4

Basic normalization guidelines state that you shouldn't store more than one natural value in a single field. But no, you don't have to create 14 columns. You should create 14 rows in a new table. Check this out: https://sampforum.blast.hk/showthread.php?tid=420363
Reply
#5

https://sampforum.blast.hk/showthread.php?tid=420363

EDIT: Damn it, didn't reload the page.. Sorry.
Reply
#6

I help with this is to save?

PHP код:
    new componentes[128];
    
format(componentessizeof(componentes), "%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d",
    
VehInfo[id][vComponentes][0], VehInfo[id][vComponentes][1], VehInfo[id][vComponentes][2], VehInfo[id][vComponentes][3], VehInfo[id][vComponentes][4],
    
VehInfo[id][vComponentes][5], VehInfo[id][vComponentes][6], VehInfo[id][vComponentes][7], VehInfo[id][vComponentes][8], VehInfo[id][vComponentes][9],
    
VehInfo[id][vComponentes][10], VehInfo[id][vComponentes][11], VehInfo[id][vComponentes][12], VehInfo[id][vComponentes][13]); 
PHP код:
    mysql_format(mysqlquerysizeof(query), "UPDATE vehiculos SET vComponentes = '%s' WHERE vID = '%d'"componentesVehInfo[id][vID]);
    
mysql_tquery(mysqlquery); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)