Custom Filter 2 or 3 fields with LOWER CASE

Hello, I know custom filter for just 1 column from this forum.

function custom_filter($filter_by){
       $index = $filter_by->index("name");
       if ($index!==false) {
             $value = $filter_by->rules[$index]["value"];
             // any sql code here
             $filter_by->rules[$index]="name LIKE $value";
        }
}

$grid->event->attach("beforeFilter", "custom_filter");
$grid->render_table("employee","id","name,address");

How about 2 columns ?
First I want know if user filtering using 1 column or 2 columns & then make LOWER CASE(value) for that column(s) in WHERE statement

Pseudo Code

if (one field ) {
	WHERE LOWER(field1) LIKE LOWER(value);
}
if (more than one field ) {
	WHERE LOWER(field1) LIKE LOWER(value) AND LOWER(field2) LIKE LOWER(value2);
}

Thanks

I solved this by myself, If anyone need (I’m using it with PostgreSQL).

myGrid.attachHeader("#connector_text_filter,#connector_text_filter"); //filtering at server

function custom_filter($filter_by) {
	foreach ($filter_by->rules as $index => $arr) {
		$name = $filter_by->rules[$index]["name"];
		$value = $filter_by->rules[$index]["value"];
		$filter_by->rules[$index] = " LOWER(".$name.") LIKE LOWER('%".$value."%') ";
	}
}