次の列を持つMySQLテーブルがあります
urlByCustomer table
----------------------------------------------
|customerID | TeamID | date | numUrlsConsumed|
----------------------------------------------
| | | | |
----------------------------------------------
urlmapping
Column Type Null Default Comments MIME
urlMappingID bigint(20) No
customerID int(11) Yes 0
activityID int(11) Yes 0
contactID int(11) Yes 0
fullURL mediumtext Yes NULL
lastModified timestamp No CURRENT_TIMESTAMP
developerSandbox varchar(25) Yes
テーブルを更新するために実行されているこのコードがあります
$start = strtotime(date('Y-m-d 00:00:00'));
$end = strtotime(date('Y-m-d 23:59:59'));
$countAllThisGuysVals = "SELECT COUNT( DISTINCT`customerID`,`fullURL`)
FROM `urlmapping`
WHERE `urlMappingID` >= $ORIGINAL_COPY
AND `customerID` = $currentCustomerID";
$countTheVals= $conn->query($countAllThisGuysVals);
$countedfinal =0;
foreach ($countTheVals as $countRow) {
$countedfinal = array_sum($countRow)/2;
}
$tableUpdateQuery = "UPDATE `urlByCustomer`
SET `date` = NOW()
WHERE `customerID`= $currentCustomerID AND
UNIX_TIMESTAMP(`date`) BETWEEN '{$start}' and '{$end}'";
$conn->exec($tableUpdateQuery);
$tableUpdateQuery = "UPDATE `urlByCustomer`
SET `numUrlsConsumed` = $countedfinal
WHERE `customerID`= $currentCustomerID AND
UNIX_TIMESTAMP(`date`) BETWEEN '{$start}' and '{$end}'";
$conn->exec($tableUpdateQuery);
echo "update path <br>";
$tableModified = true;
$originalLPID++;
変数はほとんどすべて宣言されていますが、宣言は分散しているので、この部分を投稿して短縮します。日付列への更新クエリは機能しているようですが、2番目の更新は機能していません。17分前は機能していましたが、次のテストで変更されたのは、その列を更新するための新しい値を追加したことだけだったので、混乱しました。
Idk。1つの可能性はUNIX_TIMESTAMPである可能性があると思います。私はこれをMacのParallelsで実行しているので、タイムスタンプに何が変換されるのかわかりません。