no message

This commit is contained in:
hellcat 2026-01-11 15:39:52 +08:00
parent 423850da60
commit 9db649d8b9

View File

@ -186,27 +186,26 @@ class ExecController extends Controller
public function likeAuto() public function likeAuto()
{ {
echo "\n#start# like auto \n"; echo "\n#start# like auto \n";
$iRand = rand(0, 3); $iRand = rand(0, 3);
$today = date('Ymd');
if ($iRand > 0) { // 1. 抓取模型实例
$article = ArticleList::where('code', date('Ymd'))->first(); $article = ArticleList::where('code', $today)->first();
if ($article) { if ($article) {
// 使用 updateQuietly 避免触发 updated_at // 2. 关键动作:关闭时间戳维护
$article->updateQuietly([ $article->timestamps = false;
'like' => $article->like + $iRand
]);
echo "like +{$iRand}\n"; // 3. 执行自增increment 内部会自动 save
} else { $r = $article->increment('like', $iRand);
echo "no article found\n";
} echo "Code: {$today}, Added: {$iRand}, Result: " . ($r ? 'Success' : 'Fail');
} else { } else {
echo "skip, rand=0\n"; echo "No record found for today.";
} }
echo "#end# like auto \n"; echo "\n#end# like auto \n";
} }
// 点赞初始 // 点赞初始