/
auroraos
/
mirror_sqlite3pp
Обзор
Документация
Войти
/
auroraos
/
mirror_sqlite3pp
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
master
test/testinsert.cpp
47 строк
976 B
Wongoo Lee
Uses 'copy' copy semantic when binder operator is used to bind string args.
09 фев 2016, 19:35
09 фев 2016, 19:35
b771065
Код
Авторство
О чём код?
#include <iostream> #include "sqlite3pp.h" using namespace std; int main() { try { sqlite3pp::database db("test.db"); { db.execute("INSERT INTO contacts (name, phone) VALUES ('AAAA', '1234')"); } { sqlite3pp::transaction xct(db); sqlite3pp::command cmd(db, "INSERT INTO contacts (name, phone) VALUES (?, ?)"); cout << cmd.bind(1, "BBBB", sqlite3pp::copy) << endl; cout << cmd.bind(2, "1234", sqlite3pp::copy) << endl; cout << cmd.execute() << endl; cout << cmd.reset() << endl; cmd.binder() << "CCCC" << "1234"; cout << cmd.execute() << endl; xct.commit(); } { sqlite3pp::transaction xct(db, true); sqlite3pp::command cmd(db, "INSERT INTO contacts (name, phone) VALUES (:name, :name)"); cout << cmd.bind(":name", "DDDD", sqlite3pp::copy) << endl; cout << cmd.execute() << endl; } } catch (exception& ex) { cout << ex.what() << endl; } }