Hey,
I have two mysql-related question. I'd love some help 🙂
Firstly, could someone give me a non-complicated explination of this integer-padding lark. Got this from the MySQL website:
Another extension is supported by MySQL for optionally specifying the display width of an integer value in parentheses following the base keyword for the type (for example, INT(4)).
This optional width specification is used to left-pad the display of values whose width is less than the width specified for the column, but does not constrain the range of values that can be stored in the column, nor the number of digits that will be displayed for values whose width exceeds that specified for the column
Sorry if it sounds a little dumb but I can't understand the need for such a feature :rolleyes:
My second question:
I'm a little paranoid about keeping my data types strict in php to prevent for example a string ending up where an integer should be.
It appears when a MySQL field type is an integer, it is still passed back to php as a string.
Would a piece of code like this (see below) ever be needed or is it easier/faster to just pretend the value is an integer and doesn't contain alphanumerical characters:
<?php
$row['my_integer_field'] = (int) $row['my_integer_field'];
?>
Hope I worded my questions right 😃