Welcome Guest, Not a member yet? Register   Sign In
CI4 $db->query() & Model's update() Issue
#1

Dear CI fellows;

I'm using CI4.11. I'm not sure is this the correct place to report this...

I've found that there is no hints at all for an SQL UPDATE statement when using $db->query('UPDATE...'). The return value of $db->query() is always an instance of CodeIgniter\Database\MySQLi\Result, and calling of $db->affectedRows() ALWAYS return -1, no matter update successfully or no record to be updated (such as purposely delete the record ).

In addition, calling of $query->hasError() always failed with:
Code:
Call to undefined method CodeIgniter\Database\MySQLi\Result::hasError()

Is this a bug or have I overlooked somethings...?

Whereas, when using Query Builder or Model's update(), then $db->affectedRows() work correctly. However, calling of $this->update() or $builder->update() ALWAYS return true, even no record has found to be updated. According to documentation, it supposes to return false on failure.

Any idea?

Thanks.
Reply


Messages In This Thread
CI4 $db->query() & Model's update() Issue - by gordonblue - 03-27-2021, 05:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB