Sql: Sql::Attach/Detach, SetSession

git-svn-id: svn://ultimatepp.org/upp/trunk@4304 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-12-15 10:28:58 +00:00
parent 6f8c3327b9
commit 418c76a798
2 changed files with 13 additions and 4 deletions

View file

@ -551,8 +551,8 @@ bool Sql::Update(Fields nf, SqlId table) {
return Update(nf, (const char *)~table);
}
void Sql::Assign(SqlSource& s) {
if(cn) delete cn;
void Sql::SetSession(SqlSource& s) {
Detach();
cn = s.CreateConnection();
}
@ -624,6 +624,13 @@ void Sql::Detach()
{
if(cn) delete cn;
cn = NULL;
param.Clear();
}
void Sql::Attach(SqlConnection *connection)
{
Detach();
cn = connection;
}
Sql::~Sql() {

View file

@ -92,12 +92,14 @@ class Sql {
friend Sql& AppCursorR();
Value Select0(const String& what);
void Assign(SqlSource& src);
void Detach();
enum _NULLSQL { NULLSQL };
Sql(_NULLSQL) { cn = NULL; }
public:
void SetSession(SqlSource& src);
void Attach(SqlConnection *connection);
void Detach();
String Compile(const SqlStatement& s);
void Clear();