I understand that I can simply if ($PDO->execute()) { //true } to see if a PDO INSERT was successful, but what if IGNORE is involved?
Eg.
INSERT IGNORE INTO MyTable SET DateTime = CAST(:dateTime AS DATETIME)
If the the record already exists, and so is ignored, will ->execute() return true or false?
I can't seem to find any documentation which tells me.
Try:
$stmt->execute();
$stmt->rowCount();
That will tell you how many rows were affected by the last query.
I thought this would garner me a quick answer, but it didn't, so I tested it myself:
If no records are altered as a result of the IGNORE statement, then ->execute() still returns true. It will only return false if there's an error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With