Is this code (in Doctrine2) secured against SQL injection? Or should be $_GET[‘value’]
sanitized?
$ret = $entityManager->getRepository('SomeEntity')->findOneBy(array('ID' => $_GET['value']));
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is secured from SQL-injection. You can find look at the source to find this out, the relevant code is in the
Doctrine\ORM\Persisters-namespace, as well asDoctrine\ORM\EntityRepositoryandDoctrine\ORM\UnitOfWork.Your criteria is converted into placeholders, which is also the recommended way of writing your own queries to protect against SQL-injection.