AnonymousUser Posted September 20, 2012 Share Posted September 20, 2012 ohh lol forgot to tell you i did change the sql for that code just because my money one is using the original sql just change chance to tchance CREATE TABLE `tchance` ( `logID` int( 20 ) NOT NULL AUTO_INCREMENT , `userID` int( 11 ) NOT NULL default '0', `amount` int( 11 ) NOT NULL default '0', `active` tinyint( 1 ) NOT NULL default '0', PRIMARY KEY ( `logID` ) ) ENGINE = MYISAM DEFAULT CHARSET = latin1; Quote Link to comment Share on other sites More sharing options...
Octarine Posted September 20, 2012 Share Posted September 20, 2012 logID - int(20) - seems rather wasteful userID - int(11) - expecting negative user ID's ? amount - int(10) - expecting negative values ? active - tinyint(1) - best idea so far Quote Link to comment Share on other sites More sharing options...
AnonymousUser Posted September 20, 2012 Share Posted September 20, 2012 lol i just used whatever was already there, thanks for the constructive criticism :D Quote Link to comment Share on other sites More sharing options...
Octarine Posted September 20, 2012 Share Posted September 20, 2012 You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Changes: * Made fields unsigned (signed auto_inc is the spawn of the devil, and signed amount is illogical) * Removed defaults (unnecessary) * Removed CHARSET definition (unnecessary) * Removed number sizes (irrelevant) * Retained field widths (record should align nicely to 128 bit boundary) Notes: logID is a simple 32-bit number (in fact 2^32-1). userID is now an unsigned 32 bit number (though tbf, you will not hit 2^31 users) amount is again unsigned allowing up to 4,294,967,295 though in practice you'd probably limit this at PHP level active is an 8 bit number, but presumable acts like a boolean (0 or 1) defaults widths are 10 for (unsigned) INT and 3 for (unsigned) TINYINT which is ample default charset of the DB will be used, (though as it's all integers ... pretty much irrelevant) Quote Link to comment Share on other sites More sharing options...
AnonymousUser Posted September 21, 2012 Share Posted September 21, 2012 thanks Octarine ;) Quote Link to comment Share on other sites More sharing options...
Spudinski Posted September 21, 2012 Share Posted September 21, 2012 I wish my bank used unsigned integers. :P Anyway, I'd suggest you change `amount` to SIGNED. You may want negative values there, as it's an absolute. And again, I'd suggest the usage of actual fix-length integers. Because, it's like using the capacity of a T1 link to do the work of a cross-over LAN cable. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted September 21, 2012 Share Posted September 21, 2012 Anyway, I'd suggest you change `amount` to SIGNED. You may want negative values there, as it's an absolute. In this situation, no you wouldn't. You cannot gamble with negative values, just doesn't make a lick of sense. Quote Link to comment Share on other sites More sharing options...
Octarine Posted September 21, 2012 Share Posted September 21, 2012 Not to mention, the code itself only allows for positive amounts making a signed field illogical. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.