diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 9d5a02db9f6e..058ecd7c2994 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1151,7 +1151,7 @@ protected function _like($field, string $match = '', string $type = 'AND ', stri foreach ($keyValue as $k => $v) { if ($insensitiveSearch === true) { - $v = strtolower($v); + $v = mb_strtolower($v); } $prefix = empty($this->{$clause}) ? $this->groupGetType('') : $this->groupGetType($type); diff --git a/tests/_support/Database/Seeds/CITestSeeder.php b/tests/_support/Database/Seeds/CITestSeeder.php index f8582839cf05..3311ac969890 100644 --- a/tests/_support/Database/Seeds/CITestSeeder.php +++ b/tests/_support/Database/Seeds/CITestSeeder.php @@ -86,6 +86,10 @@ public function run(): void 'key' => 'key', 'value' => 'value', ], + [ + 'key' => 'accented characters', + 'value' => 'śćźżłąęó', + ], ], 'type_test' => [ [ diff --git a/tests/system/Database/Live/LikeTest.php b/tests/system/Database/Live/LikeTest.php index 5884f9d01220..48a85bf83b7b 100644 --- a/tests/system/Database/Live/LikeTest.php +++ b/tests/system/Database/Live/LikeTest.php @@ -75,6 +75,14 @@ public function testLikeCaseInsensitive(): void $this->assertSame('Developer', $job->name); } + public function testLikeCaseInsensitiveWithAccentedCharacter(): void + { + $wai = $this->db->table('without_auto_increment')->like('value', 'ŁĄ', 'both', null, true)->get(); + $wai = $wai->getRow(); + + $this->assertSame('accented characters', $wai->key); + } + public function testOrLike(): void { $jobs = $this->db->table('job')->like('name', 'ian') diff --git a/user_guide_src/source/changelogs/v4.5.6.rst b/user_guide_src/source/changelogs/v4.5.6.rst index b982f54b38f7..3f29dc456879 100644 --- a/user_guide_src/source/changelogs/v4.5.6.rst +++ b/user_guide_src/source/changelogs/v4.5.6.rst @@ -32,6 +32,7 @@ Bugs Fixed - **Session Library:** The session initialization debug message now uses the correct log type "debug" instead of "info". - **Validation:** Fixed the `getValidated()` method that did not return valid data when validation rules used multiple asterisks. +- **Database:** Fixed the case insensitivity option in the ``like()`` method when dealing with accented characters. See the repo's `CHANGELOG.md `_