![]() |
Call to undefined method Builder::affectedRows() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Call to undefined method Builder::affectedRows() (/showthread.php?tid=75167) |
Call to undefined method Builder::affectedRows() - Dedov_Evgeniy - 01-03-2020 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 Call to undefined method CodeIgniter\\Database\\MySQLi\\Builder::affectedRows() Please tell me what I'm doing wrong. RE: Call to undefined method Builder::affectedRows() - vincent78 - 01-03-2020 Have you tried : $this->db->affectedRows() instead of : $db->affectedRows() RE: Call to undefined method Builder::affectedRows() - Dedov_Evgeniy - 01-04-2020 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 () RE: Call to undefined method Builder::affectedRows() - vincent78 - 01-04-2020 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 ... |