Is there a callback for the $db->update() method?
Is there a callback for the $db->update() method?
I have an application that uses the $db->update() method to update a field in a related table. Next, I need to read back that related table (using a PDO query, as there is no editor for that table in this file), to build a groups fie for HTTP AUTH. I find that when I read back the related table I've updated, the update has not yet happened in the related table. It looks like I need a callback for the $db->update() method. I could not find documentation indicating that such a callback exists. Am I missing something, or tell me how I can get a callback with the $db->update() has finished?
Thanks,
Tom
This question has accepted answers - jump to:
Answers
The method is synchronous, so no callback is needed. You just need to execute your code after it.
Without being able to see the hole code it is hard to say what is going wrong, but I’d guess that Editor is in a transaction, and thus you need to use
$editor->db()
to get the database connection in that transaction, or disable the transaction using->transaction(false)
on the Editor instance.Allan
Allan,
The issue arises in this piece of code:
The updateUserRecords function is called from a postEdit event on another table, roles. This file has no editor for the adminGroups table, just for the roles table.
The problem is that the data in the adminGroups table is not available when the PDO query of the adminGroups table is executed at line 27. Examining the data via a breakpoint on line 28 confirms that the adminGroups table has not yet been updated at that point, although it does get updated if you disable the breakpoint and let the entire process finish.
Seeing you answer let me to think my question needed some clarification...
Thanks,
Tom
Hi Tom,
Did you try adding
->transaction(false)
to your Editor class instance (immediately before the->process(...)
method call is the typical place to do it? Certainly, it sounds a lot like the issues is due to the transaction Editor uses.Allan
Hi Allan,
Adding ->transaction(false) fixed the problem. I didn't understand your prior answer correctly, and thought I need to elaborate on the problem. I should have just tried the ->transaction(false). I'm sorry I bothered you unnecessarily.
Thanks again,
Tom
No worries - good to hear that helped. Does it make sense now?
Allan