How to escape LIKE %$var% with Doctrine?

后端 未结 2 371
一个人的身影
一个人的身影 2020-12-15 21:56

I am making a Doctrine query and I have to do a wildcard match in the where clause. How should I escape the variable that I want to insert?

The query I want to get:

2条回答
  •  爱一瞬间的悲伤
    2020-12-15 22:05

    Something bad happened to Doctrine's documentation so here's the Google copy (check Like Expressions section)

    ...
    ->where('u.name LIKE ?', array("%$name%"));
    

提交回复
热议问题