lundi 26 octobre 2015

PHP Laravel : Conditional update query from array

I want to add multiple where clause and multiple field to update in a single query. The code below dosen't return error but dosen't do anything :( pls help

        $query = DB::table($table);
        foreach($where as $key => $value ){
            if($key != 0){
                $query -> where( $key , '=' , $value);
            }
        }
        foreach($field as $key => $value ){
            if($key != 0){
                $query -> update([$key => $value]);
            }
        }

        $result2 = $query->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire