dbal - TYPO3 with external database throws error when deleting pages - Stack Overflow

admin2025-04-22  0

TYPO3 v11

There is an external database configured:

'DB' => [
    'Connections' => [
        'MyDatabase' => [
            'charset' => 'utf8',
            'dbname' => 'mydatabase',
            'driver' => 'mysqli',
            'host' => '127.0.0.1',
            'password' => 'xxx',
            'port' => 3336,
            'user' => 'myuser',
        ],
        'Default' => [
            'charset' => 'utf8',
            'dbname' => 'typo3database',
            'driver' => 'mysqli',
            'host' => '127.0.0.1',
            'password' => 'xxx',
            'port' => 3306,
            'user' => 'typo3user',
        ],
    ],
    'TableMapping' => [
        'initiatives' => 'MyDatabase',
        'municipalities' => 'MyDatabase',
    ],
]

Extbase table mapping is configured in Configuration/Extbase/Persistence/Classes.php:

return [
    \MyVendor\MyExt\Domain\Model\Initiative::class => [
        'tableName' => 'initiatives',
        'properties' => [
            'uid' => [
                'fieldName' => 'id'
            ]
        ]
    ],
    \MyVendor\MyExt\Domain\Model\Municipality::class => [
        'tableName' => 'municipalities',
        'properties' => [
            'uid' => [
                'fieldName' => 'id'
            ]
        ]
    ]   
]; 

A plugin is configured in ext_localconf.php:

use MyVendor\MyExt\Controller\InitiativeController;

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyExt',
    'List',
    array(
        InitiativeController::class => 'list,show',
    ),
    // non-cacheable actions
    array(
        InitiativeController::class => 'list,show',
    )
);

Everything works fine for the plugin, but: When I try to delete a page I get an error message:


(1/3) Doctrine\DBAL\Exception\InvalidFieldNameException

An exception occurred while executing 'SELECT `uid` FROM `initiatives` 
WHERE `pid` = ? ORDER BY `uid` ASC' with params [14535]: 
Unknown column 'uid' in 'field list'

The external database doesn't use uid but id instead. DBAL cannot map this. That is why this error occurs. But why the external table is queried at all? It is just a simple TYPO3 page which should be deleted!

Is there a misconfiguration somewehre, or is something missing one my side?

TYPO3 v11

There is an external database configured:

'DB' => [
    'Connections' => [
        'MyDatabase' => [
            'charset' => 'utf8',
            'dbname' => 'mydatabase',
            'driver' => 'mysqli',
            'host' => '127.0.0.1',
            'password' => 'xxx',
            'port' => 3336,
            'user' => 'myuser',
        ],
        'Default' => [
            'charset' => 'utf8',
            'dbname' => 'typo3database',
            'driver' => 'mysqli',
            'host' => '127.0.0.1',
            'password' => 'xxx',
            'port' => 3306,
            'user' => 'typo3user',
        ],
    ],
    'TableMapping' => [
        'initiatives' => 'MyDatabase',
        'municipalities' => 'MyDatabase',
    ],
]

Extbase table mapping is configured in Configuration/Extbase/Persistence/Classes.php:

return [
    \MyVendor\MyExt\Domain\Model\Initiative::class => [
        'tableName' => 'initiatives',
        'properties' => [
            'uid' => [
                'fieldName' => 'id'
            ]
        ]
    ],
    \MyVendor\MyExt\Domain\Model\Municipality::class => [
        'tableName' => 'municipalities',
        'properties' => [
            'uid' => [
                'fieldName' => 'id'
            ]
        ]
    ]   
]; 

A plugin is configured in ext_localconf.php:

use MyVendor\MyExt\Controller\InitiativeController;

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
    'MyExt',
    'List',
    array(
        InitiativeController::class => 'list,show',
    ),
    // non-cacheable actions
    array(
        InitiativeController::class => 'list,show',
    )
);

Everything works fine for the plugin, but: When I try to delete a page I get an error message:


(1/3) Doctrine\DBAL\Exception\InvalidFieldNameException

An exception occurred while executing 'SELECT `uid` FROM `initiatives` 
WHERE `pid` = ? ORDER BY `uid` ASC' with params [14535]: 
Unknown column 'uid' in 'field list'

The external database doesn't use uid but id instead. DBAL cannot map this. That is why this error occurs. But why the external table is queried at all? It is just a simple TYPO3 page which should be deleted!

Is there a misconfiguration somewehre, or is something missing one my side?

Share Improve this question asked Jan 29 at 16:37 Stefan PadbergStefan Padberg 5272 silver badges20 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I gave up the idea of mapping the external database into the TYPO3 system. As the external database does not work with 'uid' the DBAL data mapping is not functioning properly. There seems to be no way as the 'uid' column is absolutely needed. All other columns can be mapped, but this one not.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745289808a294615.html

最新回复(0)