From 27f5c66fc20e2c2198b92b9bc943a4addd2f945f Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 22 Dec 2014 06:37:26 +0000 Subject: [PATCH] SqlCtrl: Update of key column option git-svn-id: svn://ultimatepp.org/upp/trunk@7989 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/SqlCtrl/SqlArray.cpp | 3 ++- uppsrc/SqlCtrl/SqlCtrl.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/uppsrc/SqlCtrl/SqlArray.cpp b/uppsrc/SqlCtrl/SqlArray.cpp index 4310bd772..3a17fee65 100644 --- a/uppsrc/SqlCtrl/SqlArray.cpp +++ b/uppsrc/SqlCtrl/SqlArray.cpp @@ -69,7 +69,7 @@ bool SqlArray::UpdateRow() { else { SqlUpdate update(table); for(int i = 0; i < GetIndexCount(); i++) - if(!GetId(i).IsNull() && IsModified(i) && (i || lateinsert)) + if(!GetId(i).IsNull() && IsModified(i) && (i || lateinsert || updatekey)) update(GetId(i), Get(i)); if(update) { Session().ClearError(); @@ -235,6 +235,7 @@ SqlArray::SqlArray() { offset = 0; count = Null; WhenFilter = true; + updatekey = false; } END_UPP_NAMESPACE diff --git a/uppsrc/SqlCtrl/SqlCtrl.h b/uppsrc/SqlCtrl/SqlCtrl.h index e741f8aee..bbe95d5f9 100644 --- a/uppsrc/SqlCtrl/SqlCtrl.h +++ b/uppsrc/SqlCtrl/SqlCtrl.h @@ -79,6 +79,7 @@ private: bool lateinsert; bool goendpostquery; bool autoinsertid; + bool updatekey; SqlBool GetWhere(); #ifndef NOAPPSQL @@ -128,6 +129,7 @@ public: SqlArray& GoEndPostQuery(bool b = true) { goendpostquery = b; return *this; } SqlArray& AutoInsertId(bool b = true) { autoinsertid = b; return *this; } SqlArray& AppendingAuto() { Appending(); return AutoInsertId(); } + SqlArray& UpdateKey(bool b = true) { updatekey = b; return *this; } void Clear(); void Reset();