我在列pushed_closed
中的值为“ 09:51 ”。
我需要添加列pushed_closed
,旁边是值' 09:51 ',值2,如:
09:51 , 09:54 (以逗号分隔)。
我的PHP代码:
$connection = db_connect();
$username = $_SESSION['username'];
$ora_terminare = '09:54';
mysqli_begin_transaction($connection);
$query = mysqli_query($connection, "UPDATE birouri SET closed_program = 'DA', pushed_closed = '$ora_terminare' WHERE username = '$username'");
mysqli_commit($connection);
如何创建正确的Mysqli查询?
答案 0 :(得分:0)
$connection = db_connect();
$username = $_SESSION['username'];
$ora_terminare = '09:54';
mysqli_begin_transaction($connection);
$query = mysqli_query($connection, "UPDATE birouri SET closed_program = 'DA', pushed_closed = concat(coalesce(pushed_closed, ''), ',', '$ora_terminare') WHERE username = '$username'");
mysqli_commit($connection);
与旧值相结合将为您提供。