B
B
BonBon Slick2021-04-28 14:22:30
Doctrine ORM
BonBon Slick, 2021-04-28 14:22:30

Difference Types::text vs Types::string per request?

In the request, you can additionally validate the parameters, which is recommended by Marco himself and the dock of doctrine.

$query->andWhere($expr->eq($tableFields['alpha2'], sprintf(':%s', 'alpha2')))
                  ->setParameter('alpha2', $filter->alpha2, Types::STRING)
            ;

This way you can avoid errors at the database level when we try to select from rows, but we pass an array for example.
What difference does it make regarding what type we validate the input parameter, type STRING or TEXT?
Or have I misunderstood how validation happens and it only checks if the parameter type matches the type?

That is, the string parameter is both TEXT and STRING, but in the case of text, the parameter length limit is set by the database and STRING is set by the developer in the mapping.
But if it were really so, then with a TEXT column type and a STRING type parameter, it should throw an error, but it passes as if choosing a universal PDO column type PARAM_STR

By default, the doctrine usesreturn \PDO::PARAM_STR;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question