Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
integration
prechecker
Commits
f8e0b4ec
Commit
f8e0b4ec
authored
Aug 11, 2015
by
Charles Fulton
Committed by
David Monllaó
Sep 18, 2015
Browse files
MDL-51052 dml: support for sql_like() under utf8_bin
parent
a91caeef
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/dml/mysqli_native_moodle_database.php
View file @
f8e0b4ec
...
...
@@ -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
'"
;
}
}
}
}
...
...
lib/dml/tests/dml_test.php
View file @
f8e0b4ec
...
...
@@ -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);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment