Editor Create: PHP Not Returning Data
Editor Create: PHP Not Returning Data
On initial load and edit, I'm getting all of the data from the serverside (PHP) Editor. However, when I create a new record, the record is created in the database, but no data is then returned from the Editor (viewing the network call confirms this).
The only thing I can think of is that I added some editor fields on the javascript side which are not part of the database schema. Could these be breaking something internally in the Editor on the ->process($_POST)
step?
Also, I can see all of the correct data and get the ID from ->on('postCreate')
, which may not be relevant as I understand that takes place before the actual transaction occurs in the DB.
Answers
Hi,
Is the server returning anything at all? If it is returning
{"data":[]}
is suggests that the newly added row is not able to be read for some reason (perhaps awhere
condition?). Or if it is an empty string that is being returned it suggests an error is occurring in the script.Regards,
Allan
It is indeed returning
{"data":[]}
. If I force refresh the table onsubmitSuccess
the newly created row then appears so it seems to be an issue only on Create. Edit works fine as well.I'll take a look at commenting out all where clauses and options on create.
tried to hack around it using
if(isset($_POST['action']) && ( ($_POST['action'] === 'create'))){}
but it wasn't successful. While creating a record successfully returned data, it was not the data from the newly generated record interestingly enough.After a lot of crying, deliberation, and rook sleuthing, it turns out that was causing the issue wasn't any of the above.
What seems to be creating an issue is the presence of an underlying trigger on the database table used in the PHP Editor. The trigger logs before and after changes to the db.
Are there any work arounds for this? I could use the events possibly, but I'm inately lazy and would rather not The trigger is pretty important for audit purposes
What is the trigger doing? The fact that there is a trigger shouldn't have any effect on the PHP library's ability to read the row back. As long as the row is being assigned a primary key value when the row is inserted (i.e. an auto incrementing column) then it should work fine.
The fact that it is returning an empty array suggests that it either isn't able to get the newly inserted id, or it isn't able to read the data back based on the id given (and probably any condition). The
_get
method inEditor.php
is where this is done if you want to add any debug code (for example it would be useful to know if an id is being passed in or not on edit).Allan
The trigger is executed on before insert.
It executes a copy of the insert into a shadow table to create an "audit trail." It looks like this:
BEGIN INSERT INTO
tblRecord_Shadow (datemodified, DescBefore, DescAfter, ServiceDateBefore, ServiceDateAfter, ChangePerformedBy, ID, MethodOfChange)
SELECT GETDATE(),'', mr.Description,I.ServiceDate,mr.ServiceDate,SUSER_NAME(),mr.ID,'Insert'
FROM tblRecord mr
INNER JOIN INSERTED I ON mr.ID = I.ID
END
Okay, so the trigger doesn't effect the id value at all. Can you confirm that the id is an auto incremented value?
Did you add any checks into the
Editor.php
file to see if it is getting the id correctly?Allan
Allan, apologies for the belated response. I'll check those items tomorrow. I see the correctly created ID in postCreate but then no data is returned. I'll double check to make sure it's an auto incrementing column, but I'm fairly certain it is.
EDIT: It turns out it is an auto increment column. So strange...