How to use alphanumeric array for IN clause in PDO

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pooja1110
Forum Newbie
Posts: 4
Joined: Thu Mar 13, 2014 12:17 am

How to use alphanumeric array for IN clause in PDO

Post by pooja1110 »

I have check boxes with values like - 2610, 1234, 2200MSR, 2200MSTY, MAko, Stack-TA.. etc

Thn have this PDO query in which I am checking this alphanumerical array against family.

Code: Select all

SELECT SUM( IF( STATUS = :status, 1, 0 ) ) passed_count FROM tooldata WHERE family IN ('.$family_implode.') AND startTime >= :date GROUP BY family ORDER BY family' );
Now here when ever I selected any alphanumeric value my query does not work properly. For example .. If I check 2200MSR, I get the data for all the array values having 2200, i.e., 2200MSR, 2200MSTY, Moreover when I select Mako, stack-ta I don't get any output.

How this can be resolved. Please guide.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to use alphanumeric array for IN clause in PDO

Post by Celauran »

What does your $family_implode look like? Are you getting errors or just bad data?
pooja1110
Forum Newbie
Posts: 4
Joined: Thu Mar 13, 2014 12:17 am

Re: How to use alphanumeric array for IN clause in PDO

Post by pooja1110 »

It has all the correct values. If I select 2200MSI, it shows the same but the problem is with the query.. Where I am using IN clause .. Its taking all the values which have 2200
Post Reply