Welcome Guest, Not a member yet? Register   Sign In
Call to undefined method Builder::affectedRows()

(This post was last modified: 01-03-2020, 12:58 PM by Dedov_Evgeniy.)

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

(This post was last modified: 01-04-2020, 05:52 AM by vincent78.)

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 ...

Theme © iAndrew 2016 - Forum software by © MyBB