Is there any issue which could happen if my query uses a value which was a result of intval() and in the DB the field has the zerofill attribute?
So far everything seems to work properly when the query uses 1 or 2 and the actual value in the DB is 0000000001 and 0000000002. But just checking to make sure.
Basically I used zerofill to make the numbers look better on the screen. But if I use intval() to make sure it's a number before querying then it strips the zeroes. If I do NOT use intval() then it may not be a number... I don't know if that could cause problems or not. I assume it would simply change the value to 0 and still not error out if I don't use intval() and it's not a number?
Zerofill In MySQL
Started by BASHERS33, May 19 2010 11:54 PM
2 replies to this topic
#1
Posted 19 May 2010 - 11:54 PM
|
|
|
#2
Posted 19 May 2010 - 11:57 PM
I ams till curious about this, but I solved my problem by using is_numeric() to be sure it's a number since a zerofill fails is_int().
So I'm having all the zeroes still in the number. But I'm curious either way I guess.
So I'm having all the zeroes still in the number. But I'm curious either way I guess.
#3
Posted 20 May 2010 - 04:17 PM
//Get value from the database as a string.
$valuestring = "".mysql_query("select value from table where conditions")
if ((int)$valuestring > 0) // Check if it's greater than 0 as an integer, but not change the actual value because it changes to an int as a temporary for the IF, then is a string still.
{
//Do what you want to the string in here, it has all leading zeros still attached.
}


Sign In
Create Account


Back to top









