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 insert.
|
|
|
|
**/
|
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
|
|
|
|
|
|
|
,render: function (batch)
|
|
|
|
{
|
|
|
|
var sql;
|
|
|
|
var n;
|
|
|
|
|
|
|
|
sql = 'INSERT INTO ' + this.renderTarget (batch) + ' (';
|
|
|
|
|
|
|
|
for (n = 0; n < this.field.length; n++)
|
|
|
|
{
|
|
|
|
if (n > 0)
|
|
|
|
sql += ', ';
|
|
|
|
sql += this.field[n].render (batch);
|
|
|
|
}
|
|
|
|
|
|
|
|
sql += ') VALUES (';
|
|
|
|
|
|
|
|
for (n = 0; n < this.field.length; n++)
|
|
|
|
{
|
|
|
|
if (n > 0)
|
|
|
|
sql += ', ';
|
|
|
|
sql += this.expr[n].render(batch);
|
|
|
|
}
|
|
|
|
|
|
|
|
sql += ')';
|
|
|
|
|
|
|
|
return sql;
|
|
|
|
}
|
|
|
|
})
|