caevv
caevv

Reputation: 170

Extbase looking for wrong table

I'm using TYPO3 7.4.0 and I'm learning to build extensions in extbase & fluid. I have a vendor prefix in my table names. I create three tables for my extensions. When I go in the backend and add entities in the list view on the resource folder I created, it works without any problems. When I go to the Frontend to view the index action of my entity it looks for a table without the vendor prefix in it's name. Does anyone know what that means? I create the tables in the "ext_tables.sql". I have no table mapping defined. I don't know where to change which tables extbase is looking for.

Upvotes: 0

Views: 1101

Answers (1)

biesior
biesior

Reputation: 55798

By default Extbase looks for table using schema tx_extkey_domain_model_modelname, so for Animal model in zoo ext it will be tx_zoo_domain_model_animal. (extkey without underscore if any!)

If you used other schema (like vendor name within table name) you need to use mapping. I.e. create file ext_typoscript_setup.txt in main folder of your ext and use this:

config.tx_extbase{
    persistence{
        classes{
            Vendor\Zoo\Domain\Model\Animal {
                mapping {
                    tableName = tx_your_own_name
                }
            }

        }
    }
}

BTW: it's best idea to keep the original naming schema. Other thing is that creating extensions manually can be tricky - at least for beginners, install Extension Builder ext to fast kickstart new extensions just with click-click way.

Upvotes: 2

Related Questions