Nasıl MySQL ve PHP ile iki tabloları güncellemek için?

2 Cevap php

Ben nasıl mysql ve php kullanarak iki tabloyu güncelleştirmek merak ediyorum?

Nasıl kod ikinci tablo eklersiniz?

Aşağıda kodudur.

$dbc = mysqli_query($mysqli,"UPDATE tags SET count='$tag_info_count' WHERE id='$tag_info_id'")

2 Cevap

Bir transaction oluşturun. Ben mysqli'nin için işlem sözdizimi unutmak, ama temelde

try 
{
   mysql_begin_transaction(); //not correct syntax
   mysql_query("UPDATE table1..."); // not correct syntax
   mysql_query("UPDATE table2..."); // not correct syntax
   msyql_commit_transaction() // not correct syntax
}
catch (Exception E)
{
   msyql_rollback_transaction(); // not correct syntax
}

kontrol Execute Multiple MySQL Queries from One String in PHP.

Aksi takdirde, PHP ayrı sorgu ifadeleri yazmak.