PHP $editor->db()->raw() rowcount after UPDATE/DELETE
PHP $editor->db()->raw() rowcount after UPDATE/DELETE
Hi, is there a way to get the number of rows effected after an UPDATE or DELETE statement.
->count() seems working only, if there is a result array after a SELECT
$sql = "DELETE FROM TABLE_X WHERE Y = :Y";
$result = $editor->db()->raw()
->bind(':Y', $Y)
->exec($sql);
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
PDOStatement::rowCount()
https://www.php.net/manual/en/pdostatement.rowcount.php
Not really a DataTables issue.
How can I access the statement. The result does not include rowCount() function?
Uncaught Error: Call to undefined method DataTables\Database\Driver\OracleResult::rowCount()
I have problems with dead locks, if I use my own connection, I need to work in the same session of the Editor backend.
I assumed you were using MySQL. Presumably Oracle has an equivalent statement.
Try an Oracle forum.
rowCount
probably will work with Oracle (it's a standard PDO method), but it is a PDO method, not one which is on ourResult
object.What you probably need to do here is get the PDO object:
and then you can use the regular PDO methods that PHP provides.
Regards,
Allan
Thanks! Still not working. Indeed for Oracle it should work.
Sorry, probably I know now why it does not work. I use a fake PDO Class, as PDO is not installed on my Server. The Fake Class probably does not work here.
Actually it is probably because
$pdo
there is not aPDOStatement
- it is just aPDO
instance. You need to do the wholestmt()
stuff as you usually would with the PDO class - we don't provide access to the PDO statements that our libraries use via an API method.Allan
Ahhh many thanks, this hint brought me now to the right direction.
However it was not a PDO connection, but a OCI8 instead.
Many thanks!