As part of a chained sequence of transactional queries, I'm inserting values that exist in a temporary table into a new table.

Every query is validated for errors in PHP using:

if (!mysqli_query($dbc, ....) {$errors[] = mysqli_error($dbc);}

If an error occurs it gets pushed into the errors array and the entire sequence is not commited.

With this approach I'm having trouble validatiesg queries that DO NOT CAUSE AN ERROR but DO NOT MEET WHERE CLAUSE CONDITIONS

Is there a way to get MySQL to throw an error signal when the WHERE CLAUSE conditions are not met?


You can try using mysqli_affected_rows to find how many rows are inserted from the last query and generate your own error in case no rows are inserted.

  • I was thinking of using that as a backup plan
    – helloworld
    Jun 25 '15 at 4:15
  • there is another way that i know which uses the same technique but, it's done in a stored procedure. If this option is not good enough I can write that for you.
    – Masoud
    Jun 25 '15 at 4:19
  • Or mysqli_num_rows for SELECTs.
    – Rick James
    Jun 27 '15 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.