-2

I had an error about 1 month ago that hasn't happened again. (See: MysqlError: Duplicate entry '1-5' for key 'PRIMARY' on insert unsure of how)

This is a follow up question to that.

The error hasn't happened since then and I am starting to wonder if it is possible for one query to fail out of a bunch. (You can refer back to the other question for the queries)

Is it possible that mysql_num_rows could return FALSE if there was a connection blip? (The rest of the queries in the transaction seemed to work fine). I have also tried replying the exact scenario without error.

Community
  • 1
  • 1
Chris Muench
  • 17,444
  • 70
  • 209
  • 362
  • You just didnt try inserting a duplicate key for a month – Jack M. Aug 20 '14 at 19:50
  • 2
    mysql_*() functions return false on **ANY** kind of failure. false is how they signal that error, and then you check mysql_error() to find out what that error was. – Marc B Aug 20 '14 at 19:51
  • @MrJack In the original question you will see that I did a select before insert. I know that isn't ideal (as pointed out by other posters), but it is in a transaction and the data was there. Is it possible for mysql_num_rows to fail randomly? – Chris Muench Aug 20 '14 at 19:55
  • No, it wont fail randomly. If there is a connection error, it wont just resume and skip other statements. It will return an error. If it fails, there is a way, somehow to reproduce it. There are, in transactions, certain issues (not bugs) that can arise though with certain commands. Are your versions up to date? – Jack M. Aug 20 '14 at 21:28
  • I forgot when this error occurred transactions were not yet implemented. I am not sure if this makes a difference. (they are on now in development). Do you see any way that http://stackoverflow.com/questions/24782271/mysqlerror-duplicate-entry-1-5-for-key-primary-on-insert-unsure-of-how can cause a duplicate key insert? Could it have anything to do with locks? – Chris Muench Aug 20 '14 at 22:19

1 Answers1

2

"Return values: The number of rows in a result set on success or FALSE on failure." Reading the documentation can be helpful. Source

Michael Wagner
  • 1,018
  • 8
  • 20
  • Do you know the possible reasons for failure (Without calling mysqli_error()). If I could examine all he possible errors that could happen that might help me figure out what happened. I have logging turned on now, but it hasn't happened in a month and there are a lot of transactions that have run. – Chris Muench Aug 21 '14 at 15:16