我试过这个来插入出勤率: -
$sims->imsi = $v
此代码运行良好,但需要花费太多次。我需要在短时间内完成这项操作
答案 0 :(得分:-1)
这个想法怎么样
<?php
$selectEmployee = "SELECT employeeId FROM employee WHERE status='ACTIVE'";
$queryEmployee = mysqli_query($conn, $selectEmployee);
if(mysqli_num_rows($queryEmployee) > 0)
{
$myInsert = "";
while($employeeRow = mysqli_fetch_assoc($queryEmployee))
{
$employeeId = $employeeRow['employeeId'];
$myInsert .= "('$employeeId', '$inTime', '$outTime', '$date'),";
}
$insert = "INSERT INTO attendace (employeeId, inTime, outTime, date)
VALUES $myInsert";
$query = mysqli_query($conn, $insert);
}
?>
注意:删除最后一个逗号