Project

General

Profile

Actions

Bug #90107

closed

QueryBuilder Bug in add Clause with append

Added by varioous OG almost 5 years ago. Updated almost 5 years ago.

Status:
Rejected
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2020-01-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
Complexity:
easy
Is Regression:
Sprint Focus:

Description

Hello,

i have the query:

$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows("uid", "tx_vayoga_domain_model_login", "user_id = " . intval($PA['row']['uid']) . " and FROM_UNIXTIME(crdate) > (NOW() - INTERVAL 30 DAY) ");

Our first try was:

$count = $queryBuilder->count('uid')
        ->from('tx_vayoga_domain_model_login')
        ->where(
            $queryBuilder->expr()->eq('user_id', $queryBuilder->createNamedParameter(intval($this->data['databaseRow']['uid']), \PDO::PARAM_INT))
        )
        ->add('where', 'FROM_UNIXTIME(crdate) > (NOW() - INTERVAL 30 DAY)', true)
        ->execute()->fetchColumn(0);

But the append of the Querybuilder is not working, the whole where is always overwritten.

Then we changed it to:

  $count = $queryBuilder->count('uid')
            ->from('tx_vayoga_domain_model_login')
            ->add('where', 'FROM_UNIXTIME(crdate) > (NOW() - INTERVAL 3000 DAY)', true)
            ->andWhere(
                $queryBuilder->expr()->eq('user_id', $queryBuilder->createNamedParameter(intval($this->data['databaseRow']['uid']), \PDO::PARAM_INT))
            )
            ->execute()->fetchColumn(0);

The last statement is working correct. I guess there is a Bug somewhere in the add method.

Thanks and kind regards,
Harald

Actions

Also available in: Atom PDF