![]() |
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. |
Messages In This Thread |
how to check if update on model did succeed? - by StefanKittel - 05-21-2023, 04:15 PM
RE: how to check if update on model did succeed? - by InsiteFX - 05-22-2023, 12:12 AM
RE: how to check if update on model did succeed? - by StefanKittel - 05-22-2023, 12:51 AM
RE: how to check if update on model did succeed? - by kenjis - 05-22-2023, 12:55 AM
RE: how to check if update on model did succeed? - by StefanKittel - 05-23-2023, 07:59 AM
RE: how to check if update on model did succeed? - by kenjis - 05-23-2023, 03:46 PM
RE: how to check if update on model did succeed? - by mhmmd - 10-26-2024, 10:33 AM
RE: how to check if update on model did succeed? - by StefanKittel - 06-06-2023, 06:58 AM
|