Skip to content

Instantly share code, notes, and snippets.

@Ziumin
Created August 14, 2012 08:37
Show Gist options
  • Save Ziumin/3347568 to your computer and use it in GitHub Desktop.
Save Ziumin/3347568 to your computer and use it in GitHub Desktop.
[Postgres] Replace LIKE with IIKE (output walker)
<?php
namespace XXX\SearchBundle\Doctrine;
use Doctrine\ORM\Query\SqlWalker;
/**
* Replace LIKE with ILIKE
* Usage: $query->setHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'XXX\SearchBundle\Doctrine\IlikeWalker');
*
* @author Ziumin
*/
class IlikeWalker extends SqlWalker
{
/**
* Walks down a WhereClause AST node, thereby generating the appropriate SQL.
*
* @param WhereClause $whereClause
*
* @return string The SQL.
*/
public function walkWhereClause($whereClause)
{
$sql = parent::walkWhereClause($whereClause);
$sql = str_replace('LIKE', 'ILIKE', $sql);
return $sql;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment