Reputation: 1294
I am searching a simple "addslashes" function for a program that must save in a sqlite database some information.
Thanks.
Upvotes: 1
Views: 4429
Reputation: 31233
Sqlite3 uses SQL standard quites, so for escaping text you need to "double the quotes" for blob you need hexadecimal representation, i.e.
C string: char const *s="I'm" -> SQL: 'I''m'
C blob : char s[2]={0xFF,0} -> SQL: x'FF00'
Upvotes: 2
Reputation: 9892
Instead of trying to re-implement addslashes, you should instead look into using prepared statements. They're simpler, faster, and easier.
Upvotes: 4