Hacker News new | past | comments | ask | show | jobs | submit login

Just use a placeholder like (??) and flatten everything out. Translate (??) and array(1,2,3) into (?,?,?) with 1, 2, 3 as the binds.



Then what do you do if the passed tuple has zero length?

Dynamically rewriting the SQL isn't going to be tractable in all cases - doing `IN (NULL)` might be a valid value - and throwing an exception is poor form for an actually valid case.


Check for bad inputs? I'm not saying this is a cure all, but it's a lot better than not being able to use arrays at all.


I don't think PDO supports this AFAIK.


I had to implement it manually, but it works. FWIW, I'm using a custom wrapper around MySQLi though.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: