lundi 14 octobre 2019

Am using to update the multiple rows in laravel but it give me error

public function productUpdate(Request $request)
{

    $product_id = $request->product_id;
    $new_weight = $request->new_weight;
    $id = array();
    $name = array();
    $query ='';
    for ($i = 0; $i < count($product_id); $i++) {
        $id = $product_id[$i];

        $name = $new_weight[$i];
        if($name != 0){

            // $query .= DB::statement("UPDATE acc_products SET prodweight = '$name' WHERE productid = '$id';")->toSql();
            DB::table('acc_products')->where('productid', $id)->update(['prodweight'=>$name])->toSql();

         }

    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire