首页 > 代码库 > 数据库连接
数据库连接
使用方法:
int resultValue;
char* userId="1000";
char insertQuery[22584];
//init mysql conection
MySqlInit();
//sprintf(insertQuery, "INSERT INTO `webcat_cloud`.`t_wechat_user` (`user_id`,`open_id`, `subscribe_flag`,`create_date`,`l_upd_date`) VALUES (‘367‘,‘adadfasdfs‘, ‘0‘,now(),now())");
//拼接sql语句
strcpy(insertQuery, "INSERT INTO `webcat_cloud`.`t_wechat_user` (`user_id`,`open_id`, `subscribe_flag`,`create_date`,`l_upd_date`) VALUES ( ‘");
strcat(insertQuery, lr_eval_string(userId)); //参数化数据
strcat(insertQuery, "‘, ‘");
strcat(insertQuery, lr_eval_string(openId)); //参数化数据
strcat(insertQuery, "‘,‘0‘,now(),now())");
strcat(insertQuery, ";");
lr_message(insertQuery);
//execute sql
lr_start_transaction("Insert");
resultValue=http://www.mamicode.com/InsertValue(insertQuery);
if(resultValue != 0)
{
lr_end_transaction("Insert",LR_FAIL);
}
else
{
lr_end_transaction("Insert",LR_PASS);
userId ++;
}
变量类型转换:
itoa(count,port,10); //count转CHAR放入port变量
count = atoi(lr_eval_string("<rp>")); //取DAT文件中的端口号转化成整数型放到count变量中
变量类型转换:
itoa(count,port,10); //count转CHAR放入port变量
count = atoi(lr_eval_string("<rp>")); //取DAT文件中的端口号转化成整数型放到count变量中
数据库连接