Reputation: 797
I'm using Doctrine 2 for my DB and I'm currently trying to set a length for one of my column that has an "integer" type but it just doesn't seem to be taken.
/** @Column(type="integer", length=255) */
protected $number;
When I check my database it still says "int(11)" instead of "int(255)". I haven't found anyone experiencing that problem on google or maybe my keywords ain't working so good. I've seen a few example of people using length=XXX and not complaining about it so I thought it would be the way to go but so far no good...
I'm always dropping/rebuilding the whole DB and proxies etc so I doubt it comes from there.
Upvotes: 1
Views: 3386
Reputation: 806
Seen this misunderstanding very often. So, to clarify @meze (see the comments above).
The size
of any MySQL integer type is about the display width
which comes into play with ZEROFILL
.
A select on a ZEROFILL
column leads to a value at least left padded with 0
up to the size
/ display width
of the column.
A simple example to explain it fully. Look at the returned output.
CREATE TABLE `foo`
(
`col_1` INT(1),
`col_1_Z` INT(1) ZEROFILL,
`col_11` INT(11),
`col_11_Z` INT(11) ZEROFILL
);
INSERT INTO `foo`
VALUES
(42, 42, 42, 42);
SELECT
col_1,
col_1_Z,
col_11,
col_11_Z
FROM
`foo`;
/* returned output */
| col_1 | col_1_Z | col_11 | col_11_Z |
|-------------|-------------|-------------|-------------|
| 42 | 42 | 42 | 00000000042 |
Upvotes: 0
Reputation: 4439
It is because you cannot have such a big INT
in MySQL.
Try using the type BIGINT
instead, it goes from -9223372036854775808 to 9223372036854775807 (signed) or from 0 to 18446744073709551615 (unsigned).
Doctrine version:
/** @Column(type="bigint") */
protected $number;
Upvotes: 3