dombg
dombg

Reputation: 331

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

In my typo3 8.7 extension I'm trying to get the typo3 standard column crdate of the logged in user from my database. My problem now is that my db query returns null or 0 depending on which datatype I use for the crdate. Obviously the column exists and is filled with int values.

As suggested in other questions here and on other plattforms I

1. added the crdate to the related TCA Configuration and
2. to the Model to make it accessible.

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'
        ),
    )

Model

/**
 * 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;
}

Controller

$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)

Upvotes: 0

Views: 684

Answers (1)

Rudy Gnodde
Rudy Gnodde

Reputation: 4565

I am currently working on a project which does the same for tstamp and that works fine. Can you check if your TCA is loaded correctly? You can do this in the backend under "System" > "Configuration" and selecting "$GLOBALS['TCA']" in the top select box.

Unrelated to this problem, you only need 'type' => 'passthrough' in your TCA config for crdate. size and eval are only needed if the user can input data for the field.

Upvotes: 3

Related Questions