extbase mapping to an existing table doesn't work
Asked Answered
J

7

5

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?

Johnnie answered 28/10, 2010 at 12:23 Comment(1)
Have you tried deleting the line recordType = Tx_myextension_Domain_Model_Tag?Bobettebobina
B
3

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.

Barris answered 22/2, 2011 at 7:21 Comment(0)
P
3

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.

Pottle answered 25/1, 2012 at 16:27 Comment(0)
S
2

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.

Saturation answered 13/12, 2010 at 15:12 Comment(1)
Does not work for me. In my extension I have a Domain Model Tx_Extname_Domain_Model_Member wich extends Tx_Extbase_Domain_Model_FrontendUser. I map my Model to fe_users by config.tx_extbase.persistence.classesTx_Extname_Domain_Model_Member.mapping.tableName=fe_users but when I try to save a record in BE, I get the error SQL error: 'Table 'usrdb_typo3.tx_extname_domain_model_member' doesn't exist'. Thus I assume the mapping does not work properly. However it is shown im my TS object browser.Blindworm
N
0

Tx_myextension_Domain_Model_Tag is the name of your object right ? But I guess this is not the name of the table you are trying to access. So my guess is that the name you are providing into the value "tableName" is wrong. What does "pages" contain ?

Napper answered 5/11, 2010 at 15:40 Comment(3)
This is the name of the class, you're right. The table "pages" is the typo3-pages table, so it contains all pages of typo3 (plus the columns I've added for the extension as [..]tag_name)Johnnie
I don't see how you specify the mapping in the sample you're providing. It just says that your persistence model is aware that the class Tx_myextension_Domain_Model_Tag is mapped, but do you specify explicitly that this class is mapped to the table you want ? If not, your error is normal because it would take the name of the class as the name of the table (which, as you said, doesn't exist).Napper
But in the mapping I specified the name of the table (tableName=pages). Maybe I'm wrong with the syntax, but I thought my piece of code should do what I expect: Map the Domain class to the pages-table and prevent extbase from trying to access a table named like the domain class.Johnnie
W
0

Have you specified the individual pages as recordtype Tx_myextension_Domain_Model_Tag ? It's supposed to go into the doctype field of the pages table (therefore you'll need to change the mysql datatype of that field. Otherwise Extbase doesn't know that this specific page is an extbase record and not a regular page. See more about single table inheritance (STI) in Extbase: http://pascal-jungblut.com/blog/blog-post/2010/11/06/single-table-inheritance-in-extbase.html

Warren answered 6/3, 2011 at 20:22 Comment(0)
H
0

do you do this in a typo3 call with eID? here some configuration is not loaded ..

if yes, try if loading all configuration solves the problem:

    ...
    $GLOBALS['TSFE'] = \t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, $_GET["id"], 0, true);
    //$GLOBALS['TSFE'] = new $temp_TSFEclassName();
    $GLOBALS['TSFE']->connectToDB();
    $GLOBALS['TSFE']->initFEuser();
    $GLOBALS['TSFE']->determineId();
    $GLOBALS['TSFE']->getCompressedTCarray();
    $GLOBALS['TSFE']->initTemplate();
    $GLOBALS['TSFE']->getConfigArray();
    ...
Hershelhershell answered 4/2, 2013 at 20:44 Comment(0)
N
0

Take care of the proper naming convention regarding FE-Plugins:

plugin.tx_myextension
Nephritis answered 23/7, 2013 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.