Reputation: 30501
Is there a way to simulate a failed INSERT
query in mysql? Since I'm running PHP/MySQL locally, the return value will always be TRUE
. Turning of MySQL in xampp doesn't seem to work.
NOTE: I may be looking at this the wrong way. Feel free to let me know.
Upvotes: 1
Views: 960
Reputation: 75636
Couple of approaches:
Or if you just need to test INSERTS, create dumb function like:
function my_query( $link, string $query ) {
if( rand() %1 ) {
return false;
} else {
return mysqli_query( $link, $query );
}
}
and update your code that INSERTs to call my_query
instead. Tune your failure conditions and happy testing :)
Upvotes: 1