我目前正在使用 symfony2、教义 2.3 和 PostgreSQL 9。我已经搜索了几个小时来看看我到底如何ILIKE
使用QueryBuilder
.
看来他们只有LIKE
. 但是,在我的情况下,我正在搜索不区分大小写的内容。到底是怎么做到的?
// -- this is the "like";
$search = 'user';
$query = $this->createQueryBuilder('users');
$query->where($query->expr()->like('users.username', $query->expr()->literal('%:username%')))->setParameter(':username', $search);
// -- this is where I get "[Syntax Error] line 0, col 86: Error: Expected =, <, <=, <>, >, >=, !=, got 'ILIKE'
$search = 'user';
$query = $this->createQueryBuilder('users');
$query->where('users.username ILIKE :username')->setParameter(':username', $search);