有人可以指导我吗,
我似乎无法正确阅读我的 blob。
不知道怎么回事,有大神帮忙吗?
这是我的功能:
我想做的是:
将 bob 读取为二进制并将字节存储在 char *data 中;
有人可以帮忙吗?
int baramdb::dbreadblob(int pid)
{
sqlite3_stmt *res;
const char *tail;
int count = 0;
this->dbopen(this->dbfile);
if (sqlite3_prepare_v2(this->db, "SELECT * FROM Packet_Send_Queue", 128, &res, &tail) != SQLITE_OK)
{
printf("[Baram] Can't retrieve data: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return(1);
}
while (sqlite3_step(res) == SQLITE_ROW)
{
int *plength = 0;
*plength = sqlite3_column_bytes(res, 2);
unsigned char **pbuffer = (unsigned char **)malloc(*plength);
memcpy(*pbuffer, sqlite3_column_blob(res, 0), *plength);
count++;
}
sqlite3_close(this->db);
this->lastresult = count;
return count;
}