Created
August 14, 2012 08:37
-
-
Save Ziumin/3347568 to your computer and use it in GitHub Desktop.
[Postgres] Replace LIKE with IIKE (output walker)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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