【发布时间】:2020-02-27 22:57:31
【问题描述】:
我正在尝试设置一个 Laravel.io 社区门户,并在 [Github] (https://github.com/laravelio/portal) 上共享。
但是,当我在终端中运行composer setup 时遇到以下错误
语法错误:7 错误:“,”或附近的语法错误 第 1 行:更新 taggables,threads SET taggables.created_at = threads... ^ (SQL: UPDATE taggables, threads SET taggables.created_at = threads.created_at, taggables.updated_at = threads.updated_at WHERE taggables.thread_id = threads.id)
我已经多次检查了 SQL 语句,它检查正常,但不知道为什么它不会在运行时通过。
这是运行 SQL 的 PHP 代码。
// Refactor tags
Schema::rename('tagged_items', 'taggables');
// Fix timestamps on taggables
if (! app()->runningUnitTests()) {
DB::statement('UPDATE taggables, threads SET taggables.created_at = threads.created_at, taggables.updated_at = threads.updated_at WHERE taggables.thread_id = threads.id');
}
【问题讨论】:
-
通常一次不能更新多个表。使用 PostGres,有一种使用通用表表达式 (CTE) 的方法,但您做错了:postgresql.org/docs/current/queries-with.html
标签: php laravel postgresql