Typo3 8.7:试图从 db table returns 获取 crdate null

Typo3 8.7: trying to get crdate from db table returns null

在我的 typo3 8.7 扩展中,我试图从我的数据库中获取已登录用户的 typo3 标准列 crdate。我现在的问题是我的数据库查询 returns null 或 0 取决于我用于 crdate 的数据类型。显然该列存在并且填充了 int 值。

正如我在此处和其他平台上的其他问题中所建议的那样

1. 将 crdate 添加到相关的 TCA Configuration
2. Model 使其可访问。

TCA

'columns' => array(.....
  'crdate' => array(
        'exclude' => 0,
        'label' => 'LLL:EXT:someExt/Resources/Private/Language/locallang_db.xlf:tx_someExt_domain_model_someModelName.crdate',
        'config' => array(
            'type' => 'passthrough',
            'size' => 30,
            'eval' => 'trim'
        ),
    )

型号

/**
 * crdate
 *
 * @var integer
 */
protected $crdate = 0;

/**
 * @return int $crdate
 */
public function getCrdate()
{
    return $this->crdate;
}

/**
 * @param int $crdate
 */
public function setCrdate($crdate)
{
    $this->crdate = $crdate;
}

控制器

$currentUser = $this->relatedRepository->findByEmail($currentUserEmail);

//Now the $currentUser object has all attributes of the table, but as my 
//title 
//states the crdate value still is 0. ( If I use datatype date it returns 
//null)

我目前正在做一个项目,它对 tstamp 做同样的事情并且工作正常。你能检查一下你的 TCA 是否加载正确吗?您可以在 "System" > "Configuration" 下的后端执行此操作,并在顶部 select 框中 selecting "$GLOBALS['TCA']"。

与此问题无关,您只需要 'type' => 'passthrough' 在您的 crdate 的 TCA 配置中。 sizeeval 仅在用户可以为该字段输入数据时才需要。