total rows updated by sql query

total rows updated by sql query

we0038we0038 Posts: 39Questions: 13Answers: 1

Considering standalone editor with keyless data. If I want to use something like

$db
->query( 'update' )
->table( 'table_name' )
->set( 'test', $_POST['data']['keyless']['test'] )
->where( 'id', 1, '=' )
->exec();

How do I get the outcome of this query i.e. (Result) e.g. number of rows effected
I spent a lot of time looking for examples and reading the documentation without any luck.

Answers

  • allanallan Posts: 61,446Questions: 1Answers: 10,055 Site admin

    Normally you would use the fact that $db->exec() returns a Result object.

    But that doesn't include the effected rows. For that I think you'd need the PDO object:

    $db->resource()->rowcount();
    

    Allan

  • we0038we0038 Posts: 39Questions: 13Answers: 1

    thanks for replying.
    nothing worked for my specific need. So, I ended up returning error on error or empty data on both (successful update and nothing updated)

This discussion has been closed.