Maybe I forgot to add the quotation marks?
sprintf(' WHEN \'%s\' THEN \'%s\'', $v['open_id'], $v['unionid']);
Maybe I forgot to add the quotation marks?