There are no converter in Pomm because the money type is being discouraged and should not be used in new developments, see this thread for more explanations. Its support in Postgres is left for backward compatibility reasons. Numeric or integer (in cents if possible) should be used instead.
If you have no choice because using an existing database with this type, you can write your own converter (see ConverterInterface
) Be aware this type output depends on the lc_monetary
environment variable. This could be set the same way date format is set in your project’s session builder.
This being said, you should avoid using uppercase letters in your column & table names, this ruins the mapping with PHP classes.
You have to use a projection in the model manager so the hydration system knows how to convert values back.
function getMinPriceFor(array $families): CollectionIterator
{
$sql = <<<SQL
SELECT {projection}
FROM "Article" a
INNER JOIN "Tarif" t ON t."ID" = a."Tarif"
WHERE {condition}
GROUP BY a."SousFamille"
ORDER BY a."SousFamille" ASC
SQL;
$projection = $this->createProjection()
->setField('prix', 'min(t."MontantTTC")', 'numeric');
$condition = Where::createWhereIn('a."SousFamille"', $families);
$sql = strtr(
$sql,
[
'{projection}' => $projection->formatFieldsWithFieldAlias('a'),
'{condition}' => $condition,
]);
return $this->query($sql, $condition->getValues(), $projection);
}