FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

Delete after Select request #26

Closed Satwa closed 8 years ago

Satwa commented 8 years ago

There's an issue when you delete a row that you selected before.

After having selected my user, I want to delete the row.

So first, I select him

$usr = $pdo->select(['id'])
               ->from('users')
               ->where('username', '=', $args['username'])
               ->where('password', '=', $args['userpsw'])
               ->where('token', '=', $args['usertk'])
               ->execute()->fetch();

So, $usr['id'] returns me an id (14 in my actual case)

and next, I want to delete him

$pdo->delete()
              ->from('users')
              ->where('id', '=', $usr['id'])
              ->execute();

Slim throws an exception without code error, but when I put another id that was not selected before (like $usr['id']+1, everything work well.

Is there a way to close select request in order to delete it after? Thanks

FaaPz commented 8 years ago

That's strange. It works fine with me using your code... :grin: Also, it's not needed to 'close' the request, because the SELECT is separated from the DELETE.

Could you post the exception here?

Satwa commented 8 years ago

Ok so, I don't know what happened but today it works correctly after two days of weird error.. I didn't change anything. It seems that I did (or Slim has) something inconsistent.. Thanks you for you answear!