php - 发送 : How to fetch record from Database without considering case sensitive?

标签 php mysql zend-framework case-sensitive

我正在使用 Zend 框架。我想在不区分大小写的情况下从数据库中获取记录。

这是我的人员表:

Id|Name  |Gender|Occupation
-----------------------------------
1 |Naveed|Male  |Software Engineer
-----------------------------------
2 |Ali   |Male  |Software Developer

现在,如果我使用以下字符串在 where 子句中使用“职业”来搜索上表中的记录,它应该始终返回记录编号 1(Naveed 的记录)。

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 中是否有任何方法来处理查询中的这个问题。

谢谢

最佳答案

尝试

$select->where( 'upper(Occupation) = upper(?)', $occupation ); 

这将使列中的值和搜索值大写

关于php - 发送 : How to fetch record from Database without considering case sensitive?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2190362/

相关文章:

php - ImageMagick 没有此图像格式的解码委托(delegate)

mysql - 将 MSSQL 分页语句转换为 MySQL 分页语句

mysql - 更新所有行的特定部分

php - 识别具有两个帐户的用户

php - 在 php mysql 中插入数据失败

php - 为什么我不能多次打开命名管道?

php - mysql select 语句作为 php 数组

php - 将域从 http 更改为 https Zend 框架

css - 使用 Zend Framework FlashMessenger 和 jQuery UI 状态类

Linux 上的 PHP 5.4 : How to connect with MS SQL Server 2008?