开发者

How to save an array of unsigned char to MySQL

开发者 https://www.devze.com 2022-12-13 22:26 出处:网络
Any idea on how to save an array of unsigned char to a field in MySQL database开发者_如何学JAVA ? I\'m considering BLOB, but how can I convert it to QByteArray and convert it back to an array of unsig

Any idea on how to save an array of unsigned char to a field in MySQL database开发者_如何学JAVA ? I'm considering BLOB, but how can I convert it to QByteArray and convert it back to an array of unsigned char when I want to ? BTW, I'm trying to save fingerprint data.


I managed to solve this using the codes below (copied directly from my project)


struct fp {
    unsigned char Template[MAX_TEMPLATE_SIZE];
    int size;
};


// unsigned char to QByteArray
QByteArray FingerPrint::charArrayToByteArray(fp fp0) {

    QByteArray ba;
    for (int i=0; i

// QByteArray to unsigned char fp FingerPrint::byteToFp(QByteArray *ba) { fp fp0; for (int i=0; isize(); i++) { fp0.Template[i] = ba->at(i); } fp0.size = ba->size(); return fp0; }

0

精彩评论

暂无评论...
验证码 换一张
取 消