implemented SQL_QuoteString and SQL_QuoteStringFmt

fixed sqlx test script not working on first load
This commit is contained in:
David Anderson
2007-04-25 13:55:56 +00:00
parent 58ad23186b
commit 82c3807bd5
5 changed files with 110 additions and 11 deletions

View File

@ -68,13 +68,12 @@ IQuery *SqliteDatabase::PrepareQueryFmt(const char *fmt, ...)
int SqliteDatabase::QuoteString(const char *str, char buffer[], size_t maxlen, size_t *newsize)
{
unsigned long size = static_cast<unsigned long>(strlen(str));
unsigned long needed = size*2 + 1;
char *res = sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
if (size < needed)
return (int)needed;
sqlite3_snprintf(static_cast<int>(maxlen), buffer, "%q", str);
if (res != NULL && newsize != NULL)
{
*newsize = strlen(buffer);
}
return 0;
}