Zend:如何从数据库获取记录而不考虑大小写?
我正在使用 Zend 框架。我想从数据库中获取记录而不考虑区分大小写。
这是我的人员表:
Id|Name |Gender|Occupation
-----------------------------------
1 |Naveed|Male |Software Engineer
-----------------------------------
2 |Ali |Male |Software Developer
现在,如果我使用以下字符串在 where 子句中使用“职业”来搜索上表中的记录,它应该始终返回记录号 1(纳维德的记录)。
Software Engineer
software engineer
SoFtwarE EngIneeR
SOFTWARE ENGINEER
我正在使用以下方法从 Zend 的数据库中获取记录。
$occupation = "Software Engineer";
$table = new Model_Person_DbTable();
$select = $table->select();
$select->where( 'Occupation = ?', $occupation );
$rows = $table->fetchAll( $select );
现在如何针对我的场景更改上面的 zend 代码?
我可以创建一个逻辑来忽略区分大小写的外部数据库查询,但我想知道 Zend/SQL 中是否有任何方法可以在查询中处理此问题。
谢谢
I am using Zend Framework. I want to fetch record from database without considering case sensitive.
This is my Person Table:
Id|Name |Gender|Occupation
-----------------------------------
1 |Naveed|Male |Software Engineer
-----------------------------------
2 |Ali |Male |Software Developer
Now If I use the following strings to search for a record in above table using 'Occupation' in where clause, it should always return record number 1 (Naveed's Record).
Software Engineer
software engineer
SoFtwarE EngIneeR
SOFTWARE ENGINEER
I am using following way to fetch records from database in Zend.
$occupation = "Software Engineer";
$table = new Model_Person_DbTable();
$select = $table->select();
$select->where( 'Occupation = ?', $occupation );
$rows = $table->fetchAll( $select );
Now how to change above zend code for my scenario ?
I can create a logic to ignore case sensitive outside database query but I want to know If there is any way in Zend/SQL to handle this issue in query.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
这将使列中的值和搜索值大写
Try
This will make the values in the column and the search value uppercase