I'm trying to run a simple query with node-mysql like this:
client.query("UPDATE mytable SET emote='wtf?' WHERE id=5");
And I get the error
Error: too few parameters given
Because it found a question mark and expects parameters. How the heck do I tell it to ignore the question mark!? Escaping it with \
doesn't work. Passing ['?']
as a parameter is completely out of the question - what if I don't know the amount of question marks the query contains?
Currently I'm using a workaround that counts the amount of question marks in the query and passes that amount of question marks as parameters. But what if I were to actually need the parameters for what they were meant to do? I shiver at the thought.
So to summarize - How do I tell client.query()
to ignore question marks?
Use this:
client.query('UPDATE mytable SET emote=? WHERE id=5', ['wtf?']);
Edit:
Passing ['?'] as a parameter is completely out of the question - what if I don't know the amount of question marks the query contains?
I skipped over this. Why would you not know how many question marks the query contains? Why would you have an unknown query with question marks?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With