我正在使用 Storage:SFTP (league/flysystem-sftp) 将一些文件上传到外部服务器。一切顺利,但有一个小问题:文件以 0644 (-rw-r--r--) 权限上传。我尝试在 put 方法上使用“public”选项作为文档中的示例,例如
Storage::disk('remote-sftp')->put($filename, $contents, 'public');
Run Code Online (Sandbox Code Playgroud)
但如果失败返回 FALSE 并且不上传文件。
如果我删除 'public' 参数,一切顺利,但文件权限错误。
有没有办法将上传的文件权限设置为0666之类的?
我不知道如何在某些条件下将字段设置为空。这应该是一个简单的查询,但我无法在可为空的字段上设置正确的 NULL 值。
Product::where('id', $product_list)->update(['family_id' => null]);
Run Code Online (Sandbox Code Playgroud)
也不
Product::where('id', $product_list)->update(['family_id' => DB::raw(null)]);
Run Code Online (Sandbox Code Playgroud)
成功了。两种情况都编译得很好,但生成的查询似乎是错误的,因为我收到 SQL 错误。在第一种情况下,错误是:
SQLSTATE[HY093]: Invalid parameter number (SQL: update `products` set `family_id` = ?, `products`.`updated_at` = 2019-11-12 08:41:07 where `id` = ?)
Run Code Online (Sandbox Code Playgroud)
第二个的错误是:
QLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', `products`.`updated_at` = ? where `id` = ?' at line 1 (SQL: update …Run Code Online (Sandbox Code Playgroud)