Jump to content

Varchar can be used like a Int field?


MasterACE14

Recommended Posts

As far as storing numbers, yes. Make sure to set the field size to hold the largest of your expected number. When actually processing, use intval()

 

 <?php 
$n1= "100"; // assume it came from a vchar field
$n2 = "25";
$n3 = intval($n1)+ intval($n2);
echo $n3;
?>

The max unsigned integer size is about 4,000,000,000 (10 digits). To store as varchar is 11 bytes. To store as int is 4 bytes. So why bother with varchar for integers?

 

ok, I think i'll stick with integers.

 

Thanks guys.

 

ACE

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.