- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 Laravel 5.1。为了简单起见,我有以下代码
迁移:
Schema::create('sitemap_data', function (Blueprint $table) {
// Primary and foreign keys
$table->increments('id');
$table->string('postUrl');
// Database functions
$table->timestamps();
});
这是我在其他地方使用的代码
$sitemapData = SitemapData::firstOrNew([
'postUrl' => $post
]);
$sitemapData->save();
现在,根据 Laravel 文档
Again, the updated_at timestamp will automatically be updated, so there is no need to manually set its value
updated_at 值应该在表中更新。然而,这并没有发生。
它只在第一次插入时设置,而不是在更新时设置。当我手动做的时候,像这样
$sitemapData = SitemapData::firstOrNew([
'postUrl' => $post
]);
$sitemapData->updated_at = Carbon::now();
$sitemapData->save();
它有效。但是,文档说这应该是自动发生的,那么这里有什么问题呢?
我已经在 stackoverflow 上搜索了一些网站来解决这个问题,但我在 Laravel 3 或 4.1、4.2 等网站上找到了这些网站。
我该如何正确地做到这一点?
最佳答案
如评论中所述,如果模型未更改,则不会更新时间戳。但是,如果您需要更新它们,或者想检查是否一切正常,请使用 $model->touch()
- 更多 here
关于php - Eloquent 模型不更新 updated_at 时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30844792/
给定一个带有多个 date_time 戳的字符串,我想 提取第一个戳及其前面的文本 候选字符串可以有一个或多个时间戳 后续的 date_time 戳记将被 sep="-" 隔开 后续date_time
是否可以合并从相机拍摄的文本和照片?我想在照片上标记日期和时间,但我在 Google 上找不到任何内容。 最佳答案 使用下面的代码来实现你所需要的。 Bitmap src = Bitm
有没有办法通过 Graph API 戳另一个用户?基于this post ,并使用 Graph Explorer ,我发布到“/USERID/pokes”,我已经授予它(Graph API 应用程序和
我有两个向左浮动的元素。一个是 body 的第一个 child ,另一个是容器的第一个 child ,容器是 body 的第二个 child 。 ...
我是一名优秀的程序员,十分优秀!