Trying to find the amount of rows deleted in a mysql query '$this->db->query("DELETE FROM ____")'. Google search is only turning up results for pdo and mysqli. And num_rows doesn't work on php 8. Any help please.
Last edited by Joe1234 on Wed Jul 31, 2024 5:59 pm, edited 1 time in total.
v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.
Have you tried.
https://dev.mysql.com/doc/refman/8.4/en ... _row-count
Code: Select all
SELECT ROW_COUNT();
I did, but I didn't get a result. I may not have implemented it correctly, but I don't know. I tried each of the following (and other variations):
Even though it is less efficient, and I would have preferred the other way, I ended up querying to see if the value exists before deleting it.
Code: Select all
$test1 = $this->db->query("DELETE FROM ____")'
$test2 = $this->db->query("SELECT ROW_COUNT(".$test1.")");
Code: Select all
$test1 = $this->db->query("DELETE FROM ____")'
$test2 = $this->db->query("SELECT ROW_COUNT($test1)");
Code: Select all
$this->db->query("DELETE FROM ____")'
$test2 = $this->db->query("SELECT ROW_COUNT()");
v3.0.4.0 php 8.1
I'm here for a reason, if your response is contact a/the developer, just don't reply.
It must be because it's two separate queries.
Have you tried?
Have you tried?
Code: Select all
$test2 = $this->db->countAffected();
Who is online
Users browsing this forum: Bing [Bot], jog2le and 18 guests