// printf("the count is %d ,the field count %d\n",row_count,field_count);
if(result == NULL && field_count == 0) {
printf("无数据");
return 1;
}
while(row = mysql_fetch_row(result))
{
printf("%d \n", atoi(row[0]));
}
// for(i = 0; i < row_count; i++) {
// row = mysql_fetch_row(result);
// printf("%d \n", atoi(row[0]));
// }
mysql_free_result(result);
return 0;
}
/*获取函数*/
int getChannelList(MYSQL *mysql,MYSQL_RES **result,int sectionID)
{
char sql[500];
intret;
memset(sql,0x00,500);
sprintf(sql,"select a.baseID,a.deviceID,a.channelID,b.param3,b.param2,b.param1,b.param0 from baseinfo a,baseParam b where a.baseID=b.baseID AND a.flag=1 AND a.sectionID=%d order by a.deviceID, a.channelID,a.baseID ;",sectionID);
// printf("[INFO]: SQL is %s\n",sql);
ret= mysql_real_query(mysql,sql, strlen(sql));
if(ret!= 0) {
printf("exec sql %s error!\n",sql);
return -1;
}
*result = mysql_store_result(mysql);
return 0;
}
/*插入数据*/
int insertTempData(MYSQL *mysql,int baseID,double temperature)
{
char sql[500];
intret;
memset(sql,0x00,500);
sprintf(sql,"INSERT INTO tempData(baseID,temperature) VALUES(%d,%f);",baseID,temperature);