php - PHP:替换数据库中的现有日期
问题描述
我正在尝试删除当前日期并使用新日期对其进行更新,以表明它是最新版本。发生这种情况时不会在 DB 表中创建新条目。以下内容用于更新信息的其他部分,但日期本身在最初插入数据库后不会更新。我一直在尝试不同的东西,但没有什么是完全正确的。有什么建议么?谢谢。
if(isset($_POST['productId'])) {
$productId = $_POST['product'];
$userId = $_POST['userId'];
$teamplay = $_POST['teamplay'];
$date = date("Y-m-d H:i:s");
if( $database->has('teamplays', [
'AND' => [
'productId' => $productId,
'userId' => $userId
]
]) ) {
$database->update('teamplays', [
'teamplay' => $teamplay,
], [
'productId' => $productId,
'userId' => $userId
]);
} else {
$database->insert('teamplays', [
'teamplay' => $teamplay,
'productId' => $productId,
'userId' => $userId,
'teamplaydate' => $date
]);
}
}
解决方案
推荐阅读
- apache-kafka - 异常发生时Kafka Event收到10次
- mule - 有没有办法在 DataWeave 2.0 中修剪数字中不必要的零?
- python - 将数据帧索引移动一定数量
- python - 根据条件使用多索引更新熊猫数据框
- c - Visual Studio 编译错误退出状态 1
- java - 如何在 Java 中使用带有 CriteriaBuilder 的 sql 函数?
- python - python中的.doc到.docx的转换
- typescript - 更新的状态未反映在我的 onPress 事件中
- c# - C# - DSharp 获得 Bots(最高)角色的颜色
- ios - 在 SwiftUI 中将绑定传递给导航堆栈中每个视图的最佳方法是什么