pansen
2019-01-25 30d0bd43f53740554e8387fcd14bfab689eeca9c
QiaoJiaSystem/LocalDBTool/SqliteToolkit.hpp
@@ -86,13 +86,13 @@
    //
    std::string getFacesFromTableSql(std::string tableName) {
        std::string sql =
            "select uuid,feature,create_time,faceUrl,del_flag from " + tableName +
            "_fea where feature is not null ";
            "select uuid,feature,create_time,faceUrl,del_flag from '" + tableName +
            "_fea' where feature is not null ";
        return sql;
    }
    std::string getTableListSqlWithType(std::string type) {
        std::string sql = "select tableName,del_flag from " + g_tableName + " where del_flag = 0";
        std::string sql = "select tableName,del_flag from '" + g_tableName + "' where del_flag = 0";
        if (type.size() > 0) {
            sql.append(" and tableType = '" + type + "'");
        }
@@ -100,7 +100,7 @@
    }
    std::string getTableInfosSql(std::string tableName) {
        std::string sql = "select * from " + tableName;// + " where del_flag = 0";
        std::string sql = "select * from '" + tableName+"';";// + " where del_flag = 0";
        return sql;
    }
@@ -129,7 +129,7 @@
        str_fea.assign(feature.begin(), feature.end());
        std::stringstream sql;//= ;
        sql << "INSERT INTO " << tableName << " (";
        sql << "INSERT INTO '" << tableName << "' (";
        //std::string sqlTemp = sql;
        std::string sql2 = ") VALUES(\"";
        if (id >= 0) {
@@ -154,7 +154,7 @@
            //#todo errInfo
            return "tableName or fieldValues is NULL";
        }
        std::string sql = "DELETE from " + tableName + " where 1 = 1 ";
        std::string sql = "DELETE from '" + tableName + "' where 1 = 1 ";
        for (auto item : fieldValues) {
            if (item.first.size() != 0) {
                sql.append("and " + item.first + " = '" + item.second + "' ");
@@ -174,7 +174,7 @@
            //#todo errInfo
            return "tableName or fieldValues is NULL";
        }
        std::string sql = "INSERT INTO " + tableName + " (";
        std::string sql = "INSERT INTO '" + tableName + "' (";
        std::string sqlTemp = sql;
        std::string sql2 = ") VALUES('";
        for (auto item : fieldValues) {
@@ -187,7 +187,7 @@
        sql = sql.substr(0, sql.length() - 1);
        //sql2 delete 2 ,'  add )
        sql2 = sql2.substr(0, sql2.length() - 2);
        sql2.append(" )");
        sql2.append(" );");
        sql.append(sql2);
        return sql;
    }
@@ -230,9 +230,9 @@
            return "tableName is NULL";
        }
        // 人员信息表
        std::string sql = "CREATE TABLE " + g_dbName + ".";
        std::string sql = "CREATE TABLE " + g_dbName + ".'";
        sql.append(tableName);
        sql.append(" (  uuid        varchar(255) PRIMARY KEY,");
        sql.append("' (  uuid        varchar(255) PRIMARY KEY,");
        sql.append("personName  varchar(255) DEFAULT NULL,");
        sql.append("age         varchar(255) DEFAULT NULL,");
        sql.append("sex         varchar(255) DEFAULT NULL,");
@@ -245,8 +245,8 @@
        sql.append("    enabled     varchar(255) DEFAULT 1");
        sql.append(");");
        // 人脸特征表
        sql.append("CREATE TABLE " + g_dbName + ".");
        sql.append(tableName + "_fea");
        sql.append("CREATE TABLE " + g_dbName + ".'");
        sql.append(tableName + "_fea'");
        sql.append(" (  uuid        varchar(255) PRIMARY KEY,");
        sql.append("    feature     BLOB NOT NULL,");
        sql.append("    faceUrl     BLOB NOT NULL,");
@@ -274,13 +274,13 @@
            SQLERR("fieldValues size is error");
            return "";
        }
        std::string sql = "update ";
        sql.append(tableName + " set ");
        std::string sql = "update '";
        sql.append(tableName + "' set ");
        for (auto &item :fieldValues) {
            sql.append(item.first + " =  '" + item.second + "',");
        }
        sql.append(" update_time ='" + AppUtil::getTimeSecString() + "'");
        sql.append(" where uuid ='" + uuid + "'");
        sql.append(" where uuid ='" + uuid + "';");
        return sql;
    }
@@ -291,8 +291,8 @@
            //#todo errInfo
            return "tableName is NULL";
        }
        std::string sql = "DROP TABLE " + g_dbName + "." + tableName + ";";
        sql.append("DROP TABLE " + g_dbName + "." + tableName + "_fea;");
        std::string sql = "DROP TABLE " + g_dbName + ".'" + tableName + "';";
        sql.append("DROP TABLE " + g_dbName + ".'" + tableName + "_fea';");
        return sql;
    }