e
2025-08-02 3e7eca2c5b346e22872f92bc383aa29042f97658
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "stdafx.h"
#include "SaveSQL.h"
 
 
SaveSQL::SaveSQL()
{
}
 
 
SaveSQL::~SaveSQL()
{
}
 
int SaveSQL::get_file_ID(std::string filename)
{
    //    Õâ¸öÓï¾äÓÐsql×¢ÈëÎÊÌ⣬Êý¾Ý¿â²»Ó¦¸ÃÌṩ½Ó¿Ú°ïÎÒÃDzåÈëÂð£¿
    std::string sql = "select file_id from files where name=\'" + filename + "\'";
    int file_id = -1;    
    vector<vector<string>> rets;
    int ret = sqlDb.query(sql, rets);
    if (ret != 0) {
        return file_id;
    }
    if (!rets.empty() && !rets[0].empty()) {
        string firstField = rets[0][0];
        file_id = std::stoi(firstField);
        cout << "First field of first row: " << firstField << endl;
    }
    // µ÷ÓÃÊý¾Ý¿âº¯Êý......
    return file_id;
}
 
int SaveSQL::create_InsFiles(SQLFiles fileInfo)
{
    std::string sql = "INSERT INTO `files` (`name`, `current_version`) VALUES ('"
                    + fileInfo.filename + "','"
                    + fileInfo.current_ver + "')";
 
    // µ÷ÓÃÊý¾Ý¿âº¯Êý......
    int ret = sqlDb.insert_del_update(sql);
    return ret;
}
 
int SaveSQL::create_InsVersions(SQLVersions versionInfo)
{    
    std::string sql = "INSERT INTO `versions` (`file_id`, `change_description`) VALUES ('"
        + versionInfo.file_id + "','"
        + versionInfo.desc + "')";
 
    // µ÷ÓÃÊý¾Ý¿âº¯Êý......
    int ret = sqlDb.insert_del_update(sql);
    return ret;
}