[TYPO3-dev] DBAL documentation...

Ernesto Baschny [cron IT] ernst at cron-it.de
Sun Sep 9 12:20:46 CEST 2007


ries van Twisk wrote: on 09.09.2007 01:22:

> when I create extensions I often create my tables by hand.
> (...)
> Now in the BE when I want to install my extension and the table does
> exists I get loads of changes,
> here are a couple of examples:
> 
> ALTER TABLE tbl_press_releases CHANGE pid pid integer NOT NULL default 0;
>      Current value: int(11) default '0'
> 
> Why does TYPO3 create int(11) in the databases while I specify integer.
> I found using int(11) highly confusing since it does suggest an integer
> with length 11 character
> while in fact it's not and only does something with space padding.

This is what MySQL will create when you say "integer". "11" is the
display width and is the maximum needed to full display of the "longest"
integer (-2147483648). See:

mysql> create table test ( uid integer ) ;
Query OK, 0 rows affected (0.00 sec)

mysql> describe test;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| uid   | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

In your CREATE statement you have to specify exactly what later MySQL
will return to TYPO3 about the tables. TYPO3 will only compare current
MySQL situation with your ext_tables.sql definition.

There are some caveats about "NULL" statements, since many are silenly
ignored by MySQL. And then also there are some tweaks you might want to
do with varchar vs char, since MySQL will auto-convert a char to a
varchar if there is at least another varchar in the table.

So the easiest way would be:

Create the table as you think is ok. Then check in MySQL what it did to
your table:

SHOW CREATE TABLE tt_content;

and correct your statement accordingly. How this will behave on a
non-mysql and DBAL installation, I have no idea. :(

Cheers,
Ernesto




More information about the TYPO3-dev mailing list