Symfony2和Doctrine:如何使用findOneBy方法来考虑资本 [英] Symfony2 and Doctrine: how to use findOneBy method taking capitals into account

查看:205
本文介绍了Symfony2和Doctrine:如何使用findOneBy方法来考虑资本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Symfony2,Doctrine和MySQL,我使用 findOneBy 方法。

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

如果我做 findOneByPath(PATH2)它会找到第二行。

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?

推荐答案

问题不是一个教义/ symfony问题 - 问题是你的表格排序规则是不区分大小写的(这是默认值),如果你希望搜索区分大小写,你需要在表格上使用不同的排序规则。

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.

  • Doctrine and collation
  • MySQL Docs for case sensitivity
  • MySQL Docs for altering collaction

这篇关于Symfony2和Doctrine:如何使用findOneBy方法来考虑资本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆