mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
MDL-51052 dml: support for sql_like() under utf8_bin
This commit is contained in:
parent
d230899db8
commit
3d47155643
@ -1523,7 +1523,12 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
if ($accentsensitive) {
|
||||
return "LOWER($fieldname) $LIKE LOWER($param) COLLATE utf8_bin ESCAPE '$escapechar'";
|
||||
} else {
|
||||
return "$fieldname $LIKE $param ESCAPE '$escapechar'";
|
||||
// Set a case sensitive collation if using utf8_bin.
|
||||
if ($this->get_dbcollation() == 'utf8_bin') {
|
||||
return "$fieldname $LIKE $param COLLATE utf8_unicode_ci ESCAPE '$escapechar'";
|
||||
} else {
|
||||
return "$fieldname $LIKE $param ESCAPE '$escapechar'";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3870,6 +3870,11 @@ class core_dml_testcase extends database_driver_testcase {
|
||||
$records = $DB->get_records_sql($sql, array('aui'));
|
||||
$this->assertCount(1, $records);
|
||||
|
||||
// Test LIKE under unusual collations.
|
||||
$sql = "SELECT * FROM {{$tablename}} WHERE ".$DB->sql_like('name', '?', false, false);
|
||||
$records = $DB->get_records_sql($sql, array("%dup_r%"));
|
||||
$this->assertCount(2, $records);
|
||||
|
||||
$sql = "SELECT * FROM {{$tablename}} WHERE ".$DB->sql_like('name', '?', true, true, true); // NOT LIKE.
|
||||
$records = $DB->get_records_sql($sql, array("%o%"));
|
||||
$this->assertCount(3, $records);
|
||||
|
Loading…
x
Reference in New Issue
Block a user