[TYPO3-dev] Field type in MM-tables
Jochen Rau
jochen.rau at typoplanet.de
Thu Jul 23 22:46:45 CEST 2009
Hi all.
Steffen Müller wrote:
> Hi.
>
> I code an extension using MM-tables. I decided to use the naming scheme
> of extbase for my tables, keeping a later transition in mind.
> A tablename for example is: tx_myextension_domain_model_mytablename
>
> The MM-table was created by the kickstarter. In my case, the field type
> for tablenames and ident (varchar(30)) were too short:
>
> CREATE TABLE tx_myextension_domain_model_mytablename_relations_mm (
> uid_local int(11) unsigned DEFAULT '0' NOT NULL,
> uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
> sorting int(11) unsigned DEFAULT '0' NOT NULL,
> sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
> tablenames varchar(30) NOT NULL,
> ident varchar(30) NOT NULL,
> KEY uid_local (uid_local),
> KEY uid_foreign (uid_foreign)
> );
>
> My tablename is 39 charcters long, but tablenames only allows 30.
> MySQL itself limits a tablename to 64 characters.
>
> TYPO3 Core API docs also uses 30 characters in its examples.
>
> Is this a neccessary limitation of TCA?
> What sense does it make?
> Or is iot just a misconfiguration in kickstarter and TYPO3 core API
> docs? Otherwise I guess we'll often run into this problem with extbase
> naming scheme.
There is no naming scheme for mm tables in extbase. It is all defined in
$TCA as usual
'tags' => array(
'exclude' => 1,
'label' =>
'LLL:EXT:blog_example/Resources/Private/Language/locallang_db.xml:tx_blogexample_domain_model_post.tags',
'config' => array(
'type' => 'select',
'size' => 10,
'minitems' => 0,
'maxitems' => 9999,
'autoSizeMax' => 30,
'multiple' => 1,
'foreign_class' => 'Tx_BlogExample_Domain_Model_Tag',
'foreign_table' => 'tx_blogexample_domain_model_tag',
'MM' => 'tx_blogexample_post_tag_mm'
)
),
My personal preference is something like
"tx_blogexample_post_tag_mm"
in words:
suffix(erm prefix ;-))
_followed by extension name
_followed by left domain object name
_followed by right domain object name
_followed by "mm"
all in lowercase.
But you can also use: substr(md5('tx_blogexample_post_tag_mm'), 30) ;-)
Regards
Jochen
BTW: Writing a PDO Storage Backend is very easy. It's just for lack of
(my) time.
--
Every nit picked is a bug fixed
More information about the TYPO3-dev
mailing list