我有一个带有产品的订购表,有些产品可以有更多的序列号。我可以有4个数量的订单ID = 1和产品ID = 144。我需要在序列表中添加新的或更新序列号。如何创建或更新序列号?
public string getkampioen(string selecteditem)
{
string kampioen = string.empty; // declared outside of the while
using (MySqlConnection connection = new MySqlConnection(connectionString))
{
connection.Open();
string query = ("select * FROM clubs where naam = '" + selecteditem + "' limit one");
MySqlCommand cmd = new MySqlCommand(query, connection);
MySqlDataReader Reader = cmd.ExecuteReader();
while (Reader.Read())
{
kampioen = (string)Reader["aantalkampioenschappen"].ToString();
}
return kampioen;
}
}
现在我可以获取订单-> Product()并使用循环获取序列号。但是,如何在创建或更新中使用保存?
// Get Used Product ID
$product = StockProduct::find(144);
// Add serial numbers
$serialNumber = new SerialNumber;
$serialNumber->serial_no = '45serial-445';
// Save polymorphic relations
$product->serialNumbers()->save($serialNumber);
或者我该如何从变形表中删除所有序列号?使用产品ID?