Error with Raw SQL with parameter injection query in symfony5

Viewed 21

i use symfony 5 with this code:

$max = 10;
$rawSql = "
    SELECT * FROM groupe_alb
    WHERE publi = 0 AND nouv = 1 
    ORDER BY datepubli DESC, id DESC
    LIMIT 0, :max";

$entityManager = $doctrine->getManager(); 
$conn = $entityManager->getConnection();
$stmt = $conn->prepare($rawSql);
$resultSet = $stmt->executeQuery(['max' => $max]);
$result = $resultSet->fetchAllAssociative();

on my compupteur and sqlite i have not error however with ovh server and mysql i have this error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;

if i change :max for 10 i have not error.

I do not understand

Thank you

0 Answers
Related