0

I am using slim3 eloqent/laravel and am trying to build a query to delete an entry from the database using multiple where clauses.

According to laravel's documentation this query should delete correctly;

$deleteGalleryItem = Home_Page::where("ul_id",$ul)
                              ->where("ul_update_no",$ul_update_no)
                              ->delete();
var_dump($deleteGalleryItem);
die();

I also tried;

$deleteGalleryItem = Home_Page::where("ul_id","=",$ul)
                              ->where("ul_update_no","=",$ul_update_no)
                              ->delete();
var_dump($deleteGalleryItem);
die();

However each time I run the var_dump I get returned integer 0

Is this the correct way to structure a mysql delete statement in eloquent/laravel in slim3?

Or should I first select the data then delete?

mp252
  • 453
  • 1
  • 6
  • 18

1 Answers1

0

There is nothing wrong with the way you've constructed your query.

The number returned is how many rows were removed with that query, so the reason you'll be getting 0 is simply because you didn't have any rows in the database with those constraints.

Hope this Helps!

Rwd
  • 34,180
  • 6
  • 64
  • 78
  • Ah ok, this makes sense, I didn't even check the database which would have been a good start, it did delete first time round, but then when I run the var_dump it had already been deleted so it returned 0. When I run it again on a different entry it returned 1. – mp252 Jul 14 '17 at 15:26
  • Glad I could help! :) – Rwd Jul 14 '17 at 15:28