试图雄辩地做一次多项选择陈述。
使用了{
vals: [
[
111,
1563454669669
],
[
222,
1563454689665
],
[
333,
1563454669658
]
.......
]
}
...函数,并在其中包含一个数组。
Blog::where()
经过测试,即使对于匹配的输入,正确写入的数据库表名称,它也会返回一个空值
模型扩展了October CMS模型,因此包括了laravel中所有雄辩的方法。下面的博客模型
$matchThese = ['title' => post('title'), 'slug' => post('slug')];
return Blog::where($matchThese)->get();
答案 0 :(得分:0)
能够解决此问题:
DB::table('blog')->where('title', '=',post('title'))->where('slug','=', post('slug'))->get();
答案 1 :(得分:0)
以下两个查询完全相同:
$matchThese = ['title' => post('title'), 'slug' => post('slug')];
return Blog::where($matchThese)->get();
和
return DB::table('blog')->where('title', '=',post('title'))->where('slug','=', post('slug'))->get();
如果一个可行,而其他却不可行,则意味着您的Blog
模型实际上没有针对正确的表blog
。您应该将以下行添加到您的Blog
模型中,并查看旧查询是否有效:
protected $table = 'blog';
同样在控制器内部,请不要忘记添加:
use App\Blog;
最重要的是。滚动一下旧查询,看看是否可行。
答案 2 :(得分:0)
$ table变量必须受保护而不是公开
public $table = 'andre_blog';
到
protected $table = 'andre_blog';