F. Tomas
F. Tomas

Reputation: 198

How to type NULL or string in Doctrine Database Abstraction Layer (DBAL)

I'm using Symfony 7.4.1

...
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ParameterType;
...

    public function setImages(int $post_id, ?string $images_str): void
    {
        $this->connection->executeStatement("UPDATE `blog_posts` SET `images` = ? WHERE `id` = ?", [$images_str, $post_id], [ParameterType::STRING||ParameterType::NULL, ParameterType::INTEGER]);
    }

Parameter $images_str may be string or NULL. How I must specify multiple ParameterType:

ParameterType::STRING||ParameterType::NULL

Is that right?

Upvotes: 0

Views: 32

Answers (0)

Related Questions