Skip to content

Commit

Permalink
Merge pull request #109 from kalider/bugfix
Browse files Browse the repository at this point in the history
Add LIKE operator for Postgres database on Codeigniter 4 adapter
  • Loading branch information
n1crack authored Jun 12, 2024
2 parents 8c83cce + 5f33793 commit 24da29a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/DB/Codeigniter4Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Ozdemir\Datatables\DB;

use Ozdemir\Datatables\Column;
use Ozdemir\Datatables\Iterators\ColumnCollection;
use Ozdemir\Datatables\Query;

Expand Down Expand Up @@ -97,4 +98,19 @@ public function getQueryString($query): string

return $query;
}

/**
* @param Query $query
* @param Column $column
* @param $word
* @return string
*/
public function makeLikeString(Query $query, Column $column, string $word)
{
if ($this->db->getPlatform() == 'Postgre') {
return $column->name.'::TEXT ILIKE '.$this->escape('%'.$word.'%', $query);
}

return $column->name.' LIKE '.$this->escape('%'.$word.'%', $query);
}
}

0 comments on commit 24da29a

Please sign in to comment.