Posted by & filed under PHP Development.

When using the mysqli_bind_params() function, you may want to consider listing int parameters as strings if the number may be greater than the maximum allowed value for an int.

For Example:

If you specify type “i” (integer), the maximum value it allows you to have is 2^32-1 or 2147483647. So, if you are using UNSIGNED INTEGER or BIGINT in your database, then you are better off using “s” (string) for this.

Here’s a quick summary:

(un)signed TINYINT: i
(un)signed SMALLINT: i
(un)signed MEDIUMINT: i
signed INT: i
unsigned INT: s
(un)signed BIGINT: s


FLOAT/REAL/DOUBLE (PRECISION) should all be “d”.

So when you call your dbUpdate function, the following is correct for the initial 2billion records, but would lead to problems after that:

dbUpdate( $query, array("i", $bigIntValue) );

This is how it should be done:

dbUpdate( $query, array("s", $bigIntValue) );

This advice is for MySQL Databases.

Share on FacebookTweet about this on TwitterPin on PinterestDigg thisEmail this to someonePrint this page

Leave a Reply

Your email address will not be published. Required fields are marked *