【发布时间】:2012-02-12 17:39:37
【问题描述】:
我愿意:
$text = '%'.addslashes($text).'%';
$images = $this->getDoctrine()->getEntityManager()
->createQuery("SELECT img, cat, u
FROM AcmeMainBundle:Image img
JOIN img.category cat
JOIN img.user u
WHERE img.title LIKE '$text' OR img.description LIKE '$text'
ORDER BY img.id DESC")
->getResult();
当 $text 包含一些 ' 时,它会抛出错误
[语法错误] line 0, col 150: Error: Expected end of string, got 'T' 500 内部服务器错误 - QueryException
如何解决?
【问题讨论】:
标签: symfony doctrine-orm dql addslashes