我正在设置一个触发器,该触发器读取一个timestamp列并将其添加7天,然后将新计算的日期放入同一表的另一列中。时间戳列称为date_requested,新列称为DELIMITER //
CREATE TRIGGER external_requests_date_trig BEFORE INSERT ON external_requests
FOR EACH ROW
BEGIN
SET NEW.return_date = DATE_ADD(NEW.date_requested, INTERVAL 7 DAY);
END//
DELIMITER ;
。到目前为止,这是我的代码。
预先感谢
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width>, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CANVAS animacje</title>
<style>
body{
margin: 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
</style>
</head>
<body>
<canvas></canvas>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
canvas.width = 1000;
canvas.height = 500;
let cw = canvas.width;
let ch = canvas.height;
let canvasX = 0;
let canvasY = 0;
let rectX = 0;
let rectY = ch/2;
let rectSize = 50;
let rectSizeRight = 100;
let rectSpeed = 10;
function field(){
ctx.fillStyle = '#ddd';
ctx.fillRect(canvasX, canvasY, cw, ch);
window.requestAnimationFrame(field);
}
function randomColors(){
let r = Math.floor(Math.random()*255);
let g = Math.floor(Math.random()*255);
let b = Math.floor(Math.random()*255);
return 'rgb('+r+','+g+','+b+')';
window.requestAnimationFrame(randomColors);
}
function rect(){
ctx.fillStyle = randomColors()
ctx.fillRect(rectX,rectY,rectSize,rectSize);
rectX+=rectSpeed;
if(rectX+rectSize == 0){
rectSize = rectSize;
rectSpeed=rectSpeed;
} else if(rectX+rectSizeRight == cw){
rectSize=rectSizeRight;
rectSpeed = -rectSpeed;
} ;
window.requestAnimationFrame(rect);
// if(rectX+rectSizeRight == cw){
// rectSize=rectSizeRight;
// rectSpeed = -rectSpeed
// }
// if (rectX+rectSize <= 0){
// rectSize = rectSize;
// rectSpeed = -rectSpeed;
// }
// if(rectX+rectSizeRight>=cw){
// rectSize=rectSizeRight;
// rectSpeed = -rectSpeed;
// }
}
function animate(){
field();
rect();
randomColors();
}
window.requestAnimationFrame(animate);
</script>
</body>
</html>