我使用 Laravel,如果我使用以下语句进行选择,我会使用 DB 对象,我会收到错误消息:响应内容必须是实现 __toString() 的字符串或对象,给定“对象”。
return DB::table('todos')->where("title","your List")->first();
如果我使用以下语句进行选择,它会起作用:
return DB::table('todos')->where("title","your List")->get();
你知道第一个语句有什么问题吗?
最佳答案
我试过了,我也一样。得再调查一下。执行以下操作:
return DB::table('todos')->where("title","your List")->take(1)->get()
现在你会没事的。
关于php - Laravel DB 首先选择 : The Response content must be a string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30890729/