Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extbase mapping to an existing table doesn't work

I've extended the pages table and now I want to use some of the data in a domain object called "Tags".
So I tried the following in the /Configuration/TypoScript/setup.txt:

plugin.myextension.persistence.classes.Tx_myextension_Domain_Model_Tag {
    mapping {
        tableName = pages
        recordType = Tx_myextension_Domain_Model_Tag
        columns {
            tx_myextension_tag_name.mapOnProperty = name
            uid.mapOnProperty = id
        }
    }
}

But It seems that the extension tries to access the table Tx_myextension_Domain_Model_Tag (which doesn't exist)

This is the error I receive:

Tx_Extbase_Persistence_Storage_Exception_SqlError`

Table 'tx_myextension_domain_model_tag' doesn't exist: SELECT tx_myextension_domain_model_tag.* FROM tx_myextension_domain_model_tag WHERE tx_myextension_domain_model_tag.id = '24' LIMIT 1

What have I done wrong?

like image 510
hering Avatar asked Oct 28 '10 12:10

hering


3 Answers

Don't forget to include your extension typoscript template into your template ( template > edit whole template > include static templates ), otherwise your setup.txt is not evaluated.

like image 130
pdu Avatar answered Nov 15 '22 06:11

pdu


To check which recordType(s) are acceptable use Configuration module in BE, in $TCA section find your table ([pages] in this case) and check type column (...[ctrl][type] - for pages it's 'doktype', which decides if page record is standard page or sysfolder etc.).

This column is tinyint(3) in database, so you can not write value 'Tx_myextension_Domain_Model_Tag' to it. Create in your ext new doktype identified by number and set recordType to it.

Optionaly you can just remove recordType from mapping config if page's type doesn't matter to you.

like image 21
biesior Avatar answered Nov 15 '22 07:11

biesior


did you try "config.tx_extbase" instead of "plugin.myextension"?

Something like

config.tx_extbase.persistence.classes.Tx_MyExtension_Domain_Model_Tag.mapping.tableName = pages

works for me.

like image 28
debagel Avatar answered Nov 15 '22 05:11

debagel