Skip to content

Instantly share code, notes, and snippets.

@tomasfejfar
Created March 13, 2012 14:46
Show Gist options
  • Save tomasfejfar/2029216 to your computer and use it in GitHub Desktop.
Save tomasfejfar/2029216 to your computer and use it in GitHub Desktop.
<?php
class Crud_Filter_ValueProcessor_Text extends Crud_Filter_ValueProcessor_Abstract
{
public function isValidFormat($value)
{
return true;
}
public function process($column, $value) {
if ($column->isExactMatch()) {
strtr($value, '*', '');
return new Crud_Filter_ValueProcessor_Result($column . ' = ?', $value);
} else {
$paramValue = str_replace('*', '%', $value);
if (strpos($value, '*') === false) {
$paramValue = '%' . $value . '%';
}
return new Crud_Filter_ValueProcessor_Result($column . ' LIKE ?', $value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment