lordvader Posted May 14, 2008 Share Posted May 14, 2008 Okay, I got a tinyint unsigned column, which means the highest number you could put in there is 255. Is there a 'mode' that would throw an error on the screen if your php tries to insert a value higher than 255? This thing that I'm writing has a counter which I don't want to able to run up indefinitely. It's not difficult to include the extra code to manually limit the count, but I don't want to if I don't have to, since there is already a built-in sort of limiter by using specific numeric types. I plan on giving my code to a lot of people for their sites, so it'll be too hard to find out what mysql mode everybody's host is set on. thanks Quote Link to comment Share on other sites More sharing options...
fenway Posted May 14, 2008 Share Posted May 14, 2008 Strict mode will complain, but that's not what it's meant for. Quote Link to comment Share on other sites More sharing options...
mezise Posted May 15, 2008 Share Posted May 15, 2008 In my opinion the best way when it comes to checking allowed values of database fields is to use DESCRIBE information before saving data. That lets you do not worry about correctness of data ranges even if your interface validation fails. Additionally when you will need to change values ranges you just alter database structure and your application will follow these changes. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 15, 2008 Share Posted May 15, 2008 You can use MOD/DIV to cheat and limit the number that way... but when it comes down to it, you're going to have to tell the user at some point, which means there has to be application logic, too. Quote Link to comment Share on other sites More sharing options...
lordvader Posted May 15, 2008 Author Share Posted May 15, 2008 My concern is whether or not there is a setting that will halt all rendering and output a mysql error message to the visitor. Because if that's a possiblity, then I'll have to include the code to manually limit the counter from incrementing if it's at 255 already. Quote Link to comment Share on other sites More sharing options...
fenway Posted May 16, 2008 Share Posted May 16, 2008 My concern is whether or not there is a setting that will halt all rendering and output a mysql error message to the visitor. Because if that's a possiblity, then I'll have to include the code to manually limit the counter from incrementing if it's at 255 already. Rendering isn't mysql. You can decide how you want mysql to behave at this stage -- throw an error or not -- but it's up to you (your code) how to handle this. 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.