[TYPO3-dev] DBAL documentation...
ries van Twisk
typo3 at rvt.dds.nl
Sun Sep 9 14:59:55 CEST 2007
On Sep 9, 2007, at 5:20 AM, Ernesto Baschny [cron IT] wrote:
> 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
Hey Ernesto,
it's a clear sign of mine that I am loosing touch with MySQL, I work
with PostgreSQL much more and it doesn't have
these oddities.
You are right...
I did a create table statement and MySQL comes back with an int(11).
And like you said, MySQL does have it's own will and changes stuff
around
just not to throw an error.
Like Masi said, I just need to check my compound keys...
Ries
--
Ries van Twisk
Freelance TYPO3 Developer
email: ries at vantwisk.nl
web: http://www.rvantwisk.nl/
skype: callto://r.vantwisk
Phone: + 1 810-476-4193
More information about the TYPO3-dev
mailing list