底下是自己寫的一段小**。假設有62條記錄,在查詢完畢後,還會輸出幾條亂碼,感覺應該是指標方面的問題,但找了半天還是修改失敗,望指教……多謝了……#include#include...
底下是自己寫的一段小**。假設有62條記錄,在查詢完畢後,還會輸出幾條亂碼,感覺應該是指標方面的問題,但找了半天還是修改失敗,望指教……多謝了……
#include
#include
#include "mysql.h"
#include
#pragma comment(lib,"libmysql.lib")
using std::cout;
using std::endl;
using std::string;
mysql mysql;
long long* getfield(char* sql)
mysql_row m_row;
mysql_res *m_res;
long long* p = null;
unsigned long long num = 0;
unsigned long i = 0;
mysql_query(&mysql,sql)
m_res = mysql_store_result(&mysql);
num = mysql_num_rows(m_res);
p = new long long [num];
memset(p, '\0', sizeof(long long) * num);
while(m_row = mysql_fetch_row(m_res))
p[i++] = atoi(m_row[0]);
return p;
int prepare()
char host[32] = "localhost";
char user[32] = "root";
char passwd[32] = "";
char dbname[32] = "test";
char log[512];
//初始化資料庫
if(mysql_init(&mysql) == null)
return 1;
else
printf("init success.\n");
//連線資料庫
if(mysql_real_connect(&mysql,host,user,passwd,dbname,0,null,0) == null)
sprintf(log,"fail to connect to database:%s.",mysql_error(&mysql));
return 1;
else
printf("connect to database:%s.\n",dbname);
return 0;
void main()
prepare();
long long *p = null;
p = getfield("select id from user where id>1");
int i = 0;
while(p[i])
delete p;
p = null;
system("pause");
那個,呃……prepare()那個函式可以不用看,用來初始化資料庫連線的,確認過沒問題,主要是getfield(char* sql)那個函式有問題……希望多幫幫忙哈……多謝多謝……
展開
mysql 游標指標迴圈
儲存過程 delimiter use lost customer repair drop procedure ifexists updateltrepairssuccesscount create definer root procedure updateltrepairssuccesscount ...
mysql 效能指標
qps每秒處理的查詢數 tps每秒處理的事務數 iops每秒磁碟進行的i o操作次數 一 tps transactions per second 每秒傳輸的事物處理個數 即伺服器每秒處理的事務數。tps包括一條訊息入和一條訊息出,加上一次使用者資料庫訪問。業務tps caps 每個呼叫平均tps t...
MySql效能監控指標(部分)
1.當前啟用的連線數 select from global status where variable name threads running 2.當前開啟的連線數 select from global status where variable name threads connected 3....