5 ms·
Just use a placeholder like (??) and flatten everything out. Translate (??) and array(1,2,3) into (?,?,?) with 1, 2, 3 as the binds.
by SapphireSun 12y ago
Just use a placeholder like (??) and flatten everything out. Translate (??) and array(1,2,3) into (?,?,?) with 1, 2, 3 as the binds.
- jiggy2011 12y agoI don't think PDO supports this AFAIK.
- SapphireSun 12y agoI had to implement it manually, but it works. FWIW, I'm using a custom wrapper around MySQLi though.
- mappu 12y agoThen 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.
- SapphireSun 12y agoCheck 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.
- deleted 12y ago[deleted]