ZF3 Zend\Db Can not execute query

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

ZF3 Zend\Db Can not execute query

This post has NOT been accepted by the mailing list yet.
Hi guys,
I'm having problems with this code:

            $delete = $this->tableGateway->getSql()->delete();
            $interval = new SqlExpression('NOW() + INTERVAL ?', [sprintf('%d days', (int) $days)]);
            $delete->where->lessThan('some_date', $interval);
            return $this->tableGateway->deleteWith($delete) > 0;

I'm getting error: Statement could not be executed (42601 - 7 - ... near "$1" LINE 1: ..." WHERE "some_date" < NOW() + INTERVAL $1 ^)

Dumped query, copied to pgadmin, is executed perfectly fine.

Profiler shows:
SQL DELETE FROM "schema"."table" WHERE "some_date" < NOW() + INTERVAL :where1subpart1 Params where1subpart1 => '0 days'
Time 207,90 ┬Ás

I've checked Zend\Db\Adapter\Driver\Pdo\Statement->execute() and params binded to object seems to be fine (they are here and treated as PDO::PARAM_STR).