문제

Yes I have a issue when i try to use bindvalues on the variables that looked like this before:

users.firstname LIKE '$firstname%'

Now it looks like this:

users.firstname LIKE ':firstname%'

But it doesn't work, also tried this:

users.firstname LIKE :firstname%

And got some syntax error..

What is the correct solution for this? I also thought adding the % in the bindValue(:firstname, $firstname%) but i need to use the :firstname in other places too that should not have the %..

Help thank you

도움이 되었습니까?

해결책

Ok, add the % to the bound value:

users.firstname LIKE :firstname

And then

$stmt->bindValue(':firstname', $firstname . '%');

But, since you're saying you need to use :firstname in other places, just name this instance something different:

users.firstname LIKE :firstnamewild

And then

$stmt->bindValue(':firstnamewild', $firstname . '%');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top