2016-09-26 09:28:47 +00:00
|
|
|
|
|
|
|
var Dml = require ('./dml');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* The equivalent of a SQL update.
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Dml
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
,render: function (params)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2022-05-30 01:30:33 +00:00
|
|
|
var sql = 'UPDATE'
|
|
|
|
+ this.renderTarget (params)
|
|
|
|
+ ' SET ';
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
this.field.forEach (function (field, i) {
|
|
|
|
if (i > 0)
|
2015-01-23 13:09:30 +00:00
|
|
|
sql += ', ';
|
2022-05-30 01:30:33 +00:00
|
|
|
|
|
|
|
sql += field.render (params)
|
|
|
|
+ ' = '
|
|
|
|
+ this.expr[i].render(params);
|
|
|
|
}, this);
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2022-05-30 01:30:33 +00:00
|
|
|
sql += this.renderIfSet (this.where, 'WHERE', params)
|
|
|
|
+ this.renderLimit(params);
|
2015-01-23 13:09:30 +00:00
|
|
|
return sql;
|
|
|
|
}
|
|
|
|
});
|