* Updates data in the database. This function calls SqlBuilder.prototype.updateData, but provides a shorter syntax to
* Updates data in the database. This function calls SqlBuilder.prototype.updateData, but provides a shorter syntax to
* improve the readability.
* improve the readability.
*
*
* @param {Object} pFieldValues Object with the columns to update as keys mapped to their values
* @param {Object|Map} pFieldValues Object with the columns to update as keys mapped to their values
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* the table of the first where-condition is used.
* the table of the first where-condition is used.
* @return {Number} the number of rows affected
* @return {Number} the number of rows affected
...
@@ -2472,22 +2475,16 @@ SqlBuilder.prototype.updateFields = function (pFieldValues, pTableName)
...
@@ -2472,22 +2475,16 @@ SqlBuilder.prototype.updateFields = function (pFieldValues, pTableName)
if (!pFieldValues||typeof(pFieldValues)!=="object")
if (!pFieldValues||typeof(pFieldValues)!=="object")
* Builds an array containing the table and condition for an update.
* Builds an array containing the table and condition for an update.
*
*
* @param {Object} pFieldValues Object with the columns to update as keys mapped to their values
* @param {Object|Map} pFieldValues Object with the columns to update as keys mapped to their values
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* the table of the first where-condition is used.
* the table of the first where-condition is used.
* @return {Array} array of [tableName, columns, columnTypes, values, preparedCondition], like it is required by db.updates or null if there is no condition
* @return {Array} array of [tableName, columns, columnTypes, values, preparedCondition], like it is required by db.updates or null if there is no condition
...
@@ -2502,25 +2499,51 @@ SqlBuilder.prototype.buildUpdateStatement = function (pFieldValues, pTableName)
...
@@ -2502,25 +2499,51 @@ SqlBuilder.prototype.buildUpdateStatement = function (pFieldValues, pTableName)
if (!pFieldValues||typeof(pFieldValues)!=="object")
if (!pFieldValues||typeof(pFieldValues)!=="object")
if (columnValues.columns.length!==0&&this._checkForUpdate())
for (letfieldinpFieldValues)
{
{
columns.push(field);
if (!pTableName&&!this._tableName)
values.push(pFieldValues[field].toString());
throwSqlBuilder._ERROR_NO_TABLE();
return[
(pTableName?pTableName:this._tableName),
columnValues.columns,
null,
columnValues.values,
this.buildCondition()
];
}
}
returnnull;
}
/**
* Builds an array containing the data for an insert.
*
* @param {Object|Map} pFieldValues Object with the columns to insert into as keys mapped to their values
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* the table of the first where-condition is used.
* @param {String} [pAutoUidField] UID column that should be filled with a random UUID
* @return {Array} array of [tableName, columns, columnTypes, values, preparedCondition], like it is required by db.updates or null if there is no condition
@@ -2559,7 +2582,7 @@ SqlBuilder.prototype.insertData = function(pTableName, pColumns, pColumnTypes, p
...
@@ -2559,7 +2582,7 @@ SqlBuilder.prototype.insertData = function(pTableName, pColumns, pColumnTypes, p
* Inserts data in the database. This function calls SqlBuilder.prototype.insertData, but provides a shorter syntax to
* Inserts data in the database. This function calls SqlBuilder.prototype.insertData, but provides a shorter syntax to
* improve the readability.
* improve the readability.
*
*
* @param {Object} pFieldValues Object with the columns to update as keys mapped to their values
* @param {Object|Map} pFieldValues Object with the columns to update as keys mapped to their values
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* @param {String} [pTableName] The table for updating data. If undefined, the from part of the SqlBuilder will be used (works only if it is a tablename). If no from is set,
* the table of the first where-condition is used.
* the table of the first where-condition is used.
* @param {String} [pAutoUidField] UID column that should be filled with a random UUID
* @param {String} [pAutoUidField] UID column that should be filled with a random UUID
...
@@ -2579,19 +2602,49 @@ SqlBuilder.prototype.insertFields = function (pFieldValues, pTableName, pAutoUid
...
@@ -2579,19 +2602,49 @@ SqlBuilder.prototype.insertFields = function (pFieldValues, pTableName, pAutoUid