TYPO3 扩展:“字段列表中的未知列"错误 [英] TYPO3 Extension: 'Unknown column in field list' error

查看:21
本文介绍了TYPO3 扩展:“字段列表中的未知列"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上:每次我使用 extension_builder 添加一个新类/模型,然后想要创建该类的记录时,我都会收到以下错误消息:

Basically: Every time I add a new class/model with the extension_builder and then want to create a record of that class I get the following error message:

2:SQL 错误:'字段列表'中的'未知列'已编辑''(tx_icingaconfgen_domain_model_checkperiod:NEW5a27f9da8a41d636846075)

2: SQL error: 'Unknown column 'edited' in 'field list'' (tx_icingaconfgen_domain_model_checkperiod:NEW5a27f9da8a41d636846075)

有趣的是:edited"不是该类的属性,而是该扩展中其他类的属性.我已经搜索了抛出错误的类的 TCA 以及 MySql 表本身,但编辑"字段确实不是该类的一部分.这是怎么回事?

The interesting thing is: "edited" is NOT a property of that class, but the property of other classes in that extension. I've searched through the TCA of the class that throws the error and also the MySql table itself, but the field "edited" is indeed not part of that class. What's going on here?

我觉得有趣的是,当我手动将编辑"列添加到 MySql 表时,可以创建记录.但是我绝不会在我的模型中使用这个属性.为什么它需要一个该名称的 MySql 列呢?

What I find interesting is the fact that when I add a column "edited" to MySql table manually, the record can be created. But in no way I'm using this property in my Model. Why does it require a MySql column of that name then?

推荐答案

事实证明,罪魁祸首实际上是 ext_localconf.php 中的这行代码:

As it turned out the culprit was actually this line of code in the ext_localconf.php:

$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['extkey'] = 'Cjk\\Icingaconfgen\\Hook\\EvalHook';
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass']['extkey'] = 'Cjk\\Icingaconfgen\\Hook\\EvalHook';

这是我在扩展程序中实现的一个钩子,它只是标记一条记录是否在 BE 中被编辑过.我实际上使用这个钩子,每当编辑记录时,将编辑的属性从 0 更改为 1.这当然是有意的,但类 checkperiod 没有属性已编辑".但是由于 Datamapper 的钩子适用于每条更改或创建的记录,因此它还会尝试更改没有此属性的类中的已编辑".如果 $fieldArray 的键 'edited' 为 NULL,则 Hook 本身中的一个简单 if 条件解决了我的问题.

It's a hook that I've implemented into my extension that just marks if a record has been edited in the BE or not. I actually use this Hook that whenever a record is edited changes the propety edited from 0 to 1. This is intended of course, but the class checkperiod doesn't have the property 'edited'. But since the hook for the Datamapper works with every record that is changed or created it also tries to change 'edited' in classes that don't have this property. A simple if condition in the Hook itself, if the key 'edited' of the $fieldArray is NULL solved my problem.

class EvalHook {
    function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$pObj) {


            if($status == "update" && $table != 'tx_icingaconfgen_domain_model_checkperiod'){
            $fieldArray[edited] = 1;
            }
            elseif($status != "update" && $table != 'tx_icingaconfgen_domain_model_checkperiod){
                $fieldArray[edited] = 0;
            }


            }


}

这篇关于TYPO3 扩展:“字段列表中的未知列"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆