Welcome Guest, Not a member yet? Register   Sign In
how to check if update on model did succeed?
#6

It is recommended put all DB related code in models, but if you call it in a controller:
$JobModel_obj->affectedRows();

But you need to call affectedRows() (this is actually a method in a DB connection) right after calling the update statement. Check the all SQL statements that executed.

If your Model calls another SQL statement inside, then executing affectedRows() afterwards will not return the correct value.
In such a case, you need to use Query Builder instead of the Model method.
https://codeigniter4.github.io/CodeIgnit...ilder.html
https://codeigniter4.github.io/CodeIgnit...ry-builder

Model and Query Builder are different things, but they are mixed. So if you don't understand
the concepts well, you may be confusing.
Reply


Messages In This Thread
RE: how to check if update on model did succeed? - by kenjis - 05-23-2023, 03:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB