Created
January 6, 2016 15:41
-
-
Save marceloandrader/3f5739807e87720d3496 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/API/Entity.php b/src/API/Entity.php | |
| index 476073b..b81e574 100644 | |
| --- a/src/API/Entity.php | |
| +++ b/src/API/Entity.php | |
| @@ -465,7 +465,11 @@ class Entity extends \Phalcon\DI\Injectable | |
| $fieldName = $this->prependFieldNameNamespace($processedSearchField['fieldName']); | |
| $operator = $this->determineWhereOperator($processedSearchField['fieldValue']); | |
| $newFieldValue = $this->processFieldValue($processedSearchField['fieldValue'], $operator); | |
| - $query->andWhere("$fieldName $operator \"$newFieldValue\""); | |
| + if ($operator === 'LIKE') { | |
| + $query->andWhere("$fieldName $operator \"$newFieldValue\" COLLATE utf8_general_ci"); | |
| + } else { | |
| + $query->andWhere("$fieldName $operator \"$newFieldValue\""); | |
| + } | |
| break; | |
| case 'or': | |
| @@ -493,7 +497,11 @@ class Entity extends \Phalcon\DI\Injectable | |
| foreach ($fieldValueArray as $fieldValue) { | |
| $operator = $this->determineWhereOperator($fieldValue); | |
| $newFieldValue = $this->processFieldValue($fieldValue, $operator); | |
| - $queryArr[] = "$fieldName $operator \"$newFieldValue\""; | |
| + if ($operator === 'LIKE') { | |
| + $queryArr[] = "$fieldName $operator \"$newFieldValue\" COLLATE utf8_general_ci"; | |
| + } else { | |
| + $queryArr[] = "$fieldName $operator \"$newFieldValue\""; | |
| + } | |
| } | |
| } | |
| $sql = implode(' OR ', $queryArr); | |
| diff --git a/src/API/SearchHelper.php b/src/API/SearchHelper.php | |
| index ca816c0..3f1716b 100644 | |
| --- a/src/API/SearchHelper.php | |
| +++ b/src/API/SearchHelper.php | |
| @@ -367,7 +367,7 @@ class SearchHelper | |
| // if we spot a wild card, convert to LIKE | |
| if (strstr($value, '*')) { | |
| $value = str_replace('*', '%', $value); | |
| - $approved_search[] = "$field LIKE '$value'"; | |
| + $approved_search[] = "$field LIKE '$value' COLLATE utf8_general_ci"; | |
| } else { | |
| $approved_search[] = "$field='$value'"; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment