Skip to content

Commit 24da29a

Browse files
authored
Merge pull request #109 from kalider/bugfix
Add LIKE operator for Postgres database on Codeigniter 4 adapter
2 parents 8c83cce + 5f33793 commit 24da29a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/DB/Codeigniter4Adapter.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Ozdemir\Datatables\DB;
44

5+
use Ozdemir\Datatables\Column;
56
use Ozdemir\Datatables\Iterators\ColumnCollection;
67
use Ozdemir\Datatables\Query;
78

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

9899
return $query;
99100
}
101+
102+
/**
103+
* @param Query $query
104+
* @param Column $column
105+
* @param $word
106+
* @return string
107+
*/
108+
public function makeLikeString(Query $query, Column $column, string $word)
109+
{
110+
if ($this->db->getPlatform() == 'Postgre') {
111+
return $column->name.'::TEXT ILIKE '.$this->escape('%'.$word.'%', $query);
112+
}
113+
114+
return $column->name.' LIKE '.$this->escape('%'.$word.'%', $query);
115+
}
100116
}

0 commit comments

Comments
 (0)