CodeIgniter Forums

Full Version: Call to undefined method Builder::affectedRows()
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
in the documentation - affectedRows();
Quote:Displays the number of affected rows, when doing “write” type queries (insert, update, etc.).
My code:

PHP Code:
// Method in model
function editClient($id ''$FIELDS = [])
$db $this->db->table('WK_clients');

->where('id', (int)$id)

$FIELDS['id'] = $id;

$db->affectedRows() ? $FIELDS false;

As a result, I get the error:
Call to undefined method CodeIgniter\\Database\\MySQLi\\Builder::affectedRows()

Please tell me what I'm doing wrong.
Have you tried :
instead of :
This is how it works. Not very logical. If you work with Query Builder Class, then these methods should also be there, at least you can just make a mistake. And this also applies to the method -> insertID ()
You're right !

An other solution is :
the method update() should return FALSE if failure and the number of affected rows if success

The signature of the method would be :
public function update($withAffectedRows = FALSE)

It's better with a parameter because we don't always want the number of affected rows and it costs a query ...

My mistake, the method affectedRows() doesn't perform a database query ...