Post by Joe1234 » Sat Jul 27, 2024 5:52 am

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.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Sat Jul 27, 2024 3:30 pm


www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Sun Jul 28, 2024 2:36 am

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):

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()");
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.

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.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am

Post by ADD Creative » Sun Jul 28, 2024 6:43 am

It must be because it's two separate queries.

Have you tried?

Code: Select all

$test2 = $this->db->countAffected();

www.add-creative.co.uk


Guru Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by Joe1234 » Wed Jul 31, 2024 5:59 pm

That's it, thanks.

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.


Active Member

Posts

Joined
Sat Jan 01, 2022 5:47 am
Who is online

Users browsing this forum: jog2le and 19 guests