What does it mean when my variable is always converted to 2147483647......?
I have the following code as my entity:
/**
*
* @Entity
* @Table(name="group")
*
**/
Class Group {
/**
*
* @Column(type="string", nullable=true)
**/
private $phone;
(etc...)
__get( $var ) {
return $this->$var;
}
__set( $var, $val ){
$this->$var = $val;
}
I then try to modify this with a number larger than nine digits. for example,
$group-开发者_JS百科>phone = 5147811326;
$phone is set to 2147483647
. The same occurs with 1111111111
(it is conveted to 2147483647
)
If I try 514781
, it keeps the numbers fine. But over 9 digits it just converts. I originally had the mysql column as an integer but converted it to string...still a problem.
what is happening?!??!!
The number "5147811326" cannot be stored in a 32-bit integer because there are simply not enough bits. The highest binary value of a 32-bit integer is "11111111 11111111 11111111 11111111" (or 2147483647 in the decimal system). Try eiter a 64-bit integer or a string to store the phone number.
This means the data type you are using is 32 bits. 2147483647 is equal to 231 − 1.
精彩评论