vendredi 24 février 2017

Deleting multiple same id from mysql database

Below is my code for deleting all rows with ids one.It seems that only first index was deleted and an error will trigger right away.How can i loop through the array and delete all rows with id one. The array I've created here is only a representation from my database with multiple columns. Any idea in resolving this problem is much appreciated.

public function deleteRow(){

 $ids = ['1','1','1','3','3','1','1'];


    foreach($ids as $id ){
      $id = Scholarshipcount::find($id);
      $id->delete();    
    }
}

my error

Call to a member function delete() on a non-object



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lzIWD9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire