If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
ESCAPE_STRING(buf, newval);
- ast_str_set(&sql, 0, "UPDATE %s SET %s = '%s'", tablename, newparam, ast_str_buffer(buf));
+ ast_str_set(&sql, 0, "UPDATE %s SET `%s` = '%s'", tablename, newparam, ast_str_buffer(buf));
/* If the column length isn't long enough, give a chance to lengthen it. */
if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) {
}
ESCAPE_STRING(buf, newval);
- ast_str_append(&sql, 0, ", %s = '%s'", newparam, ast_str_buffer(buf));
+ ast_str_append(&sql, 0, ", `%s` = '%s'", newparam, ast_str_buffer(buf));
/* If the column length isn't long enough, give a chance to lengthen it. */
if (strncmp(column->type, "char", 4) == 0 || strncmp(column->type, "varchar", 7) == 0) {
va_end(ap);
ESCAPE_STRING(buf, lookup);
- ast_str_append(&sql, 0, " WHERE %s = '%s'", keyfield, ast_str_buffer(buf));
+ ast_str_append(&sql, 0, " WHERE `%s` = '%s'", keyfield, ast_str_buffer(buf));
ast_debug(1, "MySQL RealTime: Update SQL: %s\n", ast_str_buffer(sql));
return -1;
}
ESCAPE_STRING(buf, newval);
- ast_str_append(&where, 0, "%s %s='%s'", first ? "" : " AND", newparam, ast_str_buffer(buf));
+ ast_str_append(&where, 0, "%s `%s` = '%s'", first ? "" : " AND", newparam, ast_str_buffer(buf));
first = 0;
/* If the column length isn't long enough, give a chance to lengthen it. */
}
ESCAPE_STRING(buf, newval);
- ast_str_append(&sql, 0, "%s %s = '%s'", first ? "" : ",", newparam, ast_str_buffer(buf));
+ ast_str_append(&sql, 0, "%s `%s` = '%s'", first ? "" : ",", newparam, ast_str_buffer(buf));
first = 0;
/* If the column length isn't long enough, give a chance to lengthen it. */
/* Create the first part of the query using the first parameter/value pairs we just extracted
If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
ESCAPE_STRING(buf, newval);
- ast_str_set(&sql, 0, "INSERT INTO %s (%s", table, newparam);
+ ast_str_set(&sql, 0, "INSERT INTO %s (`%s`", table, newparam);
ast_str_set(&sql2, 0, ") VALUES ('%s'", ast_str_buffer(buf));
internal_require(database, table, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL);
ast_str_reset(buf);
}
if (internal_require(database, table, newparam, RQ_CHAR, ast_str_strlen(buf), SENTINEL) == 0) {
- ast_str_append(&sql, 0, ", %s", newparam);
+ ast_str_append(&sql, 0, ", `%s`", newparam);
ast_str_append(&sql2, 0, ", '%s'", ast_str_buffer(buf));
}
}
/* Create the first part of the query using the first parameter/value pairs we just extracted
If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
ESCAPE_STRING(buf, lookup);
- ast_str_set(&sql, 0, "DELETE FROM %s WHERE %s = '%s'", table, keyfield, ast_str_buffer(buf));
+ ast_str_set(&sql, 0, "DELETE FROM %s WHERE `%s` = '%s'", table, keyfield, ast_str_buffer(buf));
while ((newparam = va_arg(ap, const char *))) {
newval = va_arg(ap, const char *);
ESCAPE_STRING(buf, newval);
- ast_str_append(&sql, 0, " AND %s = '%s'", newparam, ast_str_buffer(buf));
+ ast_str_append(&sql, 0, " AND `%s` = '%s'", newparam, ast_str_buffer(buf));
}
va_end(ap);
res = -1;
break;
}
- ast_str_set(&sql, 0, "ALTER TABLE %s MODIFY %s %s", tablename, column->name, ast_str_buffer(typestr));
+ ast_str_set(&sql, 0, "ALTER TABLE %s MODIFY `%s` %s", tablename, column->name, ast_str_buffer(typestr));
if (!column->null) {
ast_str_append(&sql, 0, " NOT NULL");
}