@@ -1706,22 +1706,22 @@ end rigDbFieldData
17061706--| FUNCTION rigDbInsertString
17071707--|
17081708--| Author: rabit
1709- --| Version: 1.1
1710- --| Created: 01 -10-09
1711- --| Last Mod: 14-10-09
1709+ --| Version: 1.2
1710+ --| Created: 2009 -10-01
1711+ --| Last Mod: 2019-08-08
17121712--| Requires: _rigEscapeIdentifiers(), rigDbEscape(), _rigProtectIdentifiers(), _rigInsert()
17131713--|
17141714--| Summary: Generate an insert string.
17151715--|
1716- --| Format: rigDbInsertString(param1, param2)
1716+ --| Format: rigDbInsertString(param1, param2[, param3] )
17171717--|
17181718--| Parameters: string <pTable> the table upon which the query will be performed,
1719- --| array <pData> an associative array data of key/values
1719+ --| array <pData> an associative array data of key/values, bool <pReplace> (optional)
17201720--|
17211721--| Return: string
17221722----------------------------------------------------------------------*/
17231723
1724- function rigDbInsertString pTable pData
1724+ function rigDbInsertString pTable pData pReplace
17251725 local tCounter , tVal , tFields , tValues , tTable
17261726
17271727 put 0 into tCounter
@@ -1735,7 +1735,7 @@ function rigDbInsertString pTable pData
17351735
17361736 put _rigProtectIdentifiers(pTable , TRUE , NULL , FALSE ) into tTable
17371737
1738- return _rigInsert(tTable , tFields , tValues )
1738+ return _rigInsert(tTable , tFields , tValues , pReplace )
17391739end rigDbInsertString
17401740
17411741
@@ -2840,25 +2840,30 @@ end _rigFromTables
28402840--| FUNCTION _rigInsert
28412841--|
28422842--| Author: rabit
2843- --| Version: 1.0
2844- --| Created: 11 -04-14
2845- --| Last Mod: --
2843+ --| Version: 1.1
2844+ --| Created: 2014 -04-11
2845+ --| Last Mod: 2019-08-08
28462846--| Requires: --
28472847--|
28482848--| Summary: Generates a platform-specific insert string from the supplied data.
28492849--|
2850- --| Format: _rigInsert(param1, param2, param3)
2850+ --| Format: _rigInsert(param1, param2, param3[, param4] )
28512851--|
2852- --| Parameters: string <pTable> the table name, array <pKeys> the insert keys, array <pValues> the insert values
2852+ --| Parameters: string <pTable> the table name, array <pKeys> the insert keys,
2853+ --| array <pValues> the insert values, bool <pReplace> (optional)
28532854--|
28542855--| Return: string
28552856----------------------------------------------------------------------*/
28562857
2857- private function _rigInsert pTable pKeys pValues
2858+ private function _rigInsert pTable pKeys pValues pReplace
28582859 combine pKeys using comma
28592860 combine pValues using comma
28602861
2861- return "INSERT INTO " & pTable & " (" & pKeys & ") VALUES (" & pValues & ")"
2862+ if pReplace <> TRUE then
2863+ return "INSERT INTO " & pTable & " (" & pKeys & ") VALUES (" & pValues & ")"
2864+ else
2865+ return "INSERT OR REPLACE INTO " & pTable & " (" & pKeys & ") VALUES (" & pValues & ")"
2866+ end if
28622867end _rigInsert
28632868
28642869
@@ -6372,24 +6377,25 @@ end rigDbGetWhere
63726377--| FUNCTION rigDbInsert
63736378--|
63746379--| Author: rabit
6375- --| Version: 1.0
6376- --| Created: 22 -04-14
6377- --| Last Mod: --
6380+ --| Version: 1.1
6381+ --| Created: 2014 -04-22
6382+ --| Last Mod: 2019-08-08
63786383--| Requires: rigDbValuesSet(), dbErrorHandling, _rigProtectIdentifiers(), rigArrayKeys()
63796384--| rigArrayValues(), _rigInsert(), _rigResetWrite, rigDbQuery(), _rigDbLastInsertID()
63806385--|
63816386--| Summary: Compiles an insert string and runs the query.
63826387--|
6383- --| Format: rigDbInsert(param1, param2, param3)
6388+ --| Format: rigDbInsert(param1, param2[ , param3][, param4] )
63846389--|
63856390--| Parameters: string <pTable> the table to retrieve the results from, array <pInsertVals>
63866391--| an associative array of insert values, bool <pLastInsertID> flag which determines
6387- --| if the last automatically generated ID value of an AUTO_INCREMENT column should be returned
6392+ --| if the last automatically generated ID value of an AUTO_INCREMENT column should be returned (optional),
6393+ --| bool <pReplace> (optional)
63886394--|
63896395--| Return: mixed
63906396----------------------------------------------------------------------*/
63916397
6392- function rigDbInsert pTable pInsertVals pLastInsertID
6398+ function rigDbInsert pTable pInsertVals pLastInsertID pReplace
63936399 local tInsertVals , tLastInsertID , tTable , tArrayKeys , tArrayValues , tSQL , tResultVal
63946400
63956401 if pInsertVals is an array then
@@ -6431,7 +6437,7 @@ function rigDbInsert pTable pInsertVals pLastInsertID
64316437 put rigArrayKeys(sActiveRecord ["set" ]) into tArrayKeys
64326438 put rigArrayValues(sActiveRecord ["set" ], FALSE ) into tArrayValues -- use apostrophes (false) is already done by rigDbValuesSet(pInsertVals)
64336439
6434- put _rigInsert(tTable , tArrayKeys , tArrayValues ) into tSQL
6440+ put _rigInsert(tTable , tArrayKeys , tArrayValues , pReplace ) into tSQL
64356441
64366442 _rigResetWrite
64376443
0 commit comments