How to Know the number of affected rows in Raw Query?

How to Know the number of affected rows in Raw Query?

usha2003usha2003 Posts: 5Questions: 3Answers: 0

I am using PHP version 5.6.19. I have a query written in Raw format which is stored in variable $lsQueryRes executed by
$retRes = $editor->db()->sql($lsQueryRes);. Here I need to know how many rows are affected which is equivalent to mysql function - mysql_affected_rows() using which was working previously with PHP version 5.3.6 and now this seems to be working but returning number of rows as 0 always even though the affected rows are more than zero..

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin

    PDOStatement::rowCount is the equivalent in PDO according to the PHP documentation.

    There isn't currently a public method to access this in Editor's PHP libraries at the moment though I'm afraid. It might be best to create your own PDO connection and pass that into the new Database() constructor, then you can execute your own queries as you require.

    Allan

  • usha2003usha2003 Posts: 5Questions: 3Answers: 0

    Can you show me an example how to achieve for an Update Query to be executed?

  • allanallan Posts: 63,516Questions: 1Answers: 10,473 Site admin
    Answer ✓

    I'm afraid I don't quite understand. The PHP PDO documentation is where you would need to go if you wanted to execute a statement using PDO. There are also loads of tutorials around the web on it.

    Allan

This discussion has been closed.