Symfony2 and Doctrine: how to use findOneBy method

2019-09-09 09:59发布

Using Symfony2, Doctrine and MySQL, I am using findOneBy method.

I need it to take capitals into account when talking about string criteria fields.

Example: imagine I have this path field in some table in my database.

id  path
---------
1   path1
2   path2
3   path3
4   path4

If I do findOneByPath("PATH2") it will find the second row.

The question: how can I make it to distinguish capitals, so that it wouldn't find any row in the described case?

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-09-09 10:44

The issue is not a doctrine/symfony issue - the problem is that your table collation is case-insensitive (this is the default), if you want searches to be case sensitive you need to use a different collation on your tables.

查看更多
登录 后发表回答