时间:2021-07-01 10:21:17 帮助过:2人阅读
db_user_mail* pMail = offline->mutable_user_mail(); ASSERT(pMail->has_content());//系统邮件肯定需要content char* pContent = UTF8ToANSI(pMail->content().c_str()); char sql[1024 * 10] = {0}; sprintf_s(sql, sizeof(sql), "INSERT INTO `user_sys_mail` SET `content` = ‘%s‘, `type` = %d, `send_time` = from_unixtime(%u), `valid_time` = %u;SELECT LAST_INSERT_ID();", pContent, pMail->type(), pMail->send_time(), offline->valid_time()); free(pContent); char* pSql = ANSIToUTF8(sql); int code = CDBMgr::Query(con, pSql, strlen(pSql)); free(pSql); if (0 != code) //非0查询失败 { printf("query failed! [%s] [%d] [%s] \n", sql, mysql_errno(con), mysql_error(con)); return -1; }
插入中文的格式,当时这个问题给我带来了巨大的困扰,吗的都是坑。。
mysql中文坑爹的东西
标签: