⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 persistent.cpp

📁 LiteSQL is a C++ library that integrates C++ objects tightly to relational database and thus provide
💻 CPP
字号:
/* LiteSQL - Persistent-class implementation *  * By Tero Laitinen  *  * See LICENSE for copyright information. */#include "compatibility.hpp"#include "litesql/persistent.hpp"#include "litesql/updatequery.hpp"#include <iostream>namespace litesql {using namespace std;const Persistent & Persistent::operator=(const Persistent & p) {    if (this != &p) {         db = p.db;        inDatabase = p.inDatabase;        oldKey = p.oldKey;    }    return *this;}string Persistent::insert(Record& tables,                           Records& fieldRecs,                          Records& values,                          const string& sequence) {    if (values[0][0] == "0")        for(size_t i = 0; i < values.size(); i++)            values[i][0] = "NULL";    string key = db->groupInsert(tables, fieldRecs, values, sequence);    oldKey = atoi(key);    inDatabase = true;    return key;}void Persistent::update(Updates& updates) {    for (Updates::iterator i = updates.begin(); i != updates.end(); i++) {        UpdateQuery uq(i->first);        uq.where(RawExpr("id_ = '" + toString(oldKey) + "'"));        bool notEmpty = false;        for (vector<pair<FieldType, string> >::iterator i2 =                i->second.begin(); i2 != i->second.end();             i2++) {            uq.set(i2->first, i2->second);            notEmpty = true;        }        if (notEmpty)            db->query(uq);    }}void Persistent::prepareUpdate(Updates& updates, string table) {    if (updates.find(table) == updates.end()) {        updates[table] = vector<pair<FieldType, string> >();    }}void Persistent::deleteFromTable(string table, string id) {    db->query("DELETE FROM " + table + " WHERE id_="+escapeSQL(id));}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -