Php 雄辩的orm选择位置,然后更新

Php 雄辩的orm选择位置,然后更新,php,lumen,Php,Lumen,我有一些密码 public function addvote($id,$varia){ $pollsres = Pollsres::where('poll_id', '=',$id)->where('poll_variant','=',$varia)->get(); // and poll_variant = ?',[$id,$varia])->get(); if($pollsres->isEmpty()){ $pollres =

我有一些密码

public function addvote($id,$varia){
    $pollsres = Pollsres::where('poll_id', '=',$id)->where('poll_variant','=',$varia)->get();
    // and poll_variant = ?',[$id,$varia])->get();
    if($pollsres->isEmpty()){
        $pollres = new Pollsres();
        $pollres->poll_id = $id;
        $pollres->poll_variant = $varia;
        $pollres->poll_count = 1;
        $pollres->save();
    }else{
        //return response()->json($pollsres);
        var_dump($pollsres);
    }

}
在db中,我有1条记录$id=1和$varia=1,但我可以更新$pollsres->poll\u count我有错误,如果我更新$pollsres[0]->poll\u count,我更新所有记录,不仅为什么有where表达式(在db中使用2条记录进行测试)


我不检查数据库中是否有记录,其中如果没有添加新的如果有编辑此记录

,因为您的表没有
主键

您需要为表添加
自动递增
主键,因为

然后问题就解决了