[英]Zend Properl filterBy with collate
I'm new with propel and I have one question. 我是propel的新手,我有一个问题。 How I can put into filterBy collation?
我怎样才能放入filterBy排序规则? I need something like this:
我需要这样的东西:
SELECT id, name, email FROM users WHERE email COLLATE utf8_bin = "teSt@domain.com"
I need case-sensitivity search, but I can't change table schema for now. 我需要区分大小写的搜索,但目前无法更改表架构。 I'm trying:
我正在努力:
$model = Model_Propel_Users::create()->filterByName('COLLATE utf8_bin ' . $name)
But it doesn't work. 但这是行不通的。 Anyone have ideas?
有人有主意吗?
Thanks! 谢谢!
I've found solution, perhaps it will be usefull for somebody. 我找到了解决方案,也许对某人有用。
First, I've added new method into model: 首先,我在模型中添加了新方法:
public function findUser($email)
{
$criteria = new Criteria();
$conn = Propel::getConnection();
$cq = Model_Propel_Users::EMAIL . ' COLLATE utf8_bin LIKE ' . $conn->quote($email);
$criteria->add(null, $cq, Criteria::CUSTOM);
$user = Model_Propel_Users::doSelectOne($criteria);
return $user;
}
Then just make call to get result: 然后只需拨打电话即可获得结果:
$user = Model_Propel_Users::create()->findUser($email);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.