我正在使用 cron 作业从事务表中获取总计并更新另一个表。在我的 cron 作业电子邮件中,我返回任务已完成但没有看到我的数据发生变化。
<?php
try {
$dbh = new PDO("mysql:host=localhost;dbname=the", 'the', '1');
$query = "UPDATE Test a
INNER JOIN
(
SELECT ID, SUM(Total) as Total,
FROM TestTrans
WHERE Status = ?
Group By ID
) b
ON a.ID = b.ID
SET a.Total = b.Total
Where a.Total > b.Total";
$iStatus = 1;
$stmt = $dbh->prepare($query);
$stmt->bindParam(1, $iStatus);
$stmt->execute();
echo 'Task Completed';
}
catch(PDOException $e)
{
echo $e->getMessage();
}
?>