Answer the question
In order to leave comments, you need to log in
Is it possible to immediately get an array from the database when inserting into the database?
How to immediately get the answer from the database when inserting into the database? Whether not to do SELECT to check there is such record or not? It is necessary to receive at an insertion record not that that is interposed and already from a DB. What is the best way to do this? It is necessary to insert or update a record, but not update all the fields except for two and immediately get a row from the database in response to an already prepared record.
The code below is an example, in the example only INSERT. But it is not important. What is important is how to make such a request?
function user(val) {
return new Promise(function (resolve, reject) {
const connection = mysql.createConnection(query);
const win="INSERT INTO `test`(`id`, `vas`, `sas`, `nas`) VALUES (3,2,2,2)";
const par = [];
connection.query(win, par,
function(err, results) {
if (err) reject(err);
resolve(results);
});
connection.end();
})
}
Answer the question
In order to leave comments, you need to log in
Because it create
's a method Eloquent\Builder
, but it's update
proxied to Query\Builder
.
PS You seem to have been taught to read the documentation, now we will teach you to study the framework code?
const win="INSERT INTO `test`(`id`, `vas`, `sas`, `nas`) VALUES (3,2,2,2) RETURNING :id, :vas, :sas, :nas";
par = {
id: {type: BIND_OUT},
vas: {type: BIND_OUT},
sas: {type: BIND_OUT},
nas: {type: BIND_OUT}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question