I have the following problem,I don't know how to check if my MySql query has actually inserted or ignored the insert from my php code.
This is because as far as I know it always returns true, due to the error preventing of the ignore clause.
A sample of what I have is:
$addTagSql = "INSERT IGNORE INTO tags (text)
VALUES ('$text')";
$resultAddTag = $db -> query($addTagSql);
if(!$resultAddTag) {
$response["success"] = 0;
}
else{
$response["success"] = 1;
}
Should I just let it break and handle the error?
I couldn't find a good answer, so I'd be glad if you can help me :)
Use mysqli_affected_rows()
reference: http://php.net/manual/en/mysqli.affected-rows.php
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