0
I would like to compare information coming from PHP Json and persist in WEBSQL.
Have a moment I should know if the information coming from Mysql: Has already been registered Amended Unexciting
Below I have the javascript I’d like you to do this BUT it’s not working.
What is done wrong ?
function verificaSincronizacao(objetoJSON) {
db.readTransaction(function (t) {
t.executeSql('SELECT * FROM tbl_appramal WHERE codigo = ?', [objetoJSON.ram_codigo], function (t, data) {
var length = data.rows.length;
if(length > 0){// Temos o cadastro já sincronizado
if((data.rows[0].unidade != d.ram_unidade)){//Se dados for iguais não precisa atualizar
Atualiza(objetoJSON);
}
}else{//Caso não houver length dados não cadastrados então cadatrar
Insere(objetoJSON);
}
});
});
}
Isn’t it easier for you to delete the information and enter it again? This way if it was registered there will be no problem, if it is changed it will be updated and if it does not exist will be created.
– KhaosDoctor
My friend does not want to delete. I want the following: 1 - If you have already registered in WEBSQL and MYSQL no auteração, do nothing. 2 - If you have already registered in WEBSQL and MYSQL has been changed, change also in WEBSQL. 3 - If you have not registered enter. This I want because if you have already registered in MYSQL and synchronized in WEBSQL does not need to be updated what was not filed in MYSQL, understood my friend ----- Thanks for the help :)
– Cyberlacs
Did you manage to find the flaw in my code ?????? :)
– Cyberlacs
What you’re not getting done exactly ?
– Guilherme Lopes
I can get the information from the Mysql bank in my hosting service via PHP in JSON format, and I want to persist in WEBSQL, thus staying, I register Guilherme | Luiz Santos | Francisco Queiroz in Mysql then the user on mobile click synchronize and persist in Websql, So at a certain point I make a change by staying like this Guilherme LOPES | Luiz Santos | Francisco Queiroz, seeing this scenario the only register to have maintenance in sync is Guilherme because the change in Mysql was inserted Lopes, so this is what I want to do. Change Insert at the right times.
– Cyberlacs
Face this involves a programming effort that is not so necessary... Because you can simply insert always, saving client-side processing, as if it were a complete sync every time.
– KhaosDoctor
@Khaosdoctor the problem of inserting is that it will duplicate already entered data, or Websql does like Indexeddb that recognizes the already entered data and does the Update in the data ?
– Cyberlacs
For this reason I suggested to delete the data and to delete the data first. Not in separate transactions, but whenever you are going to remotely update the database, delete the record before and enter the same record again, this way you cover Update and insertion.
– KhaosDoctor
@Khaosdoctor thanks for the tip works perfectly, thanks even for the tip.
– Cyberlacs