如何使用mysqli面向对象插入多个查询

时间:2015-04-17 16:13:20

标签: mysqli

$db->query("UPDATE users SET solde = solde - '$aDeduire' WHERE telephone = '$msisdn'"); // works
$db->query("UPDATE users SET solde = solde + '$montant' WHERE telephone = '$numaPayer'"); //works
$db->query("UPDATE systems SET solde = solde + '$fraisTransaction' WHERE nom = 'SYSTEM'"); //works
$db->query("INSERT INTO transactions (day, description, expediteur, destinataire, debit, credit, numserie ) 

VALUES (NOW(), '$textExp', '$msisdn',null ,'$montant',null , '$numSerie')");// not working

$db->query("INSERT INTO transactions (day, description, expediteur, destinataire, debit, credit, numserie )

VALUES (NOW(), '$textDes't, null, '$numaPayer', null,'$montant', '$numSerie')"); // not working

$db->query("INSERT INTO transactions (day, description, expediteur, destinataire, debit, credit, numserie )

VALUES (NOW(), '$textSyst', null,'SYSTEM', null, '$montant', '$numSerie')");// not working

任何人都可以帮助您使用此代码。 我想一次插入多个dats。 代码有什么问题?

1 个答案:

答案 0 :(得分:0)

$db->query("INSERT INTO transactions (day, expediteur, destinataire, debit, credit, description, numserie) 
                VALUES (NOW(), '$msisdn','' ,'$montant', 0, '$textExp', '$numSerie'), 
                        (NOW(), '', '$numaPayer', 0,'$montant', '$textDest', '$numSerie'),
                        (NOW(), '$msisdn','', '$fraisTransaction', 0, '$textFrais', '$numSerie'), 
                        (NOW(), '','SYSTEM', 0, '$fraisTransaction', '$textSyst', '$numSerie')");

这是我如何解决它

问候