Bind params
#19275
-
How can I bind params in multiple foreach loops? $attributes = $this->attributes;
$searchTerms = explode(' ', $term);
foreach (Arr::wrap($attributes) as $attribute) {
$sql = new Expression("LOWER(`{$attribute->getAttribute()}`) LIKE ? ESCAPE ?");
foreach ($searchTerms as $searchTerm) {
$searchTerm = mb_strtolower($searchTerm, 'UTF8');
$searchTerm = str_replace("\\", $this->getBackslashByPdo(), $searchTerm);
$searchTerm = addcslashes($searchTerm, "%_");
$attribute->isPartial()
? $query->orWhere("$sql")
->addParams(["%{$searchTerm}%", '\\'])
: $query->orWhere([$attribute->getAttribute() => $searchTerm]);
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
ArtMin96
Feb 27, 2022
Replies: 1 comment
-
Fixed. Replace |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ArtMin96
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fixed. Replace
addParams(["%{$searchTerm}%", '\\'])
toaddParams([1 => "%{$searchTerm}%", 2 => '\\'])