editor php working for data loading, action remove is returning empty json
editor php working for data loading, action remove is returning empty json
Hey,
i'm using editor php to load a serverside datatables, this all works perfectly, but when i add the remove(delete) something starts to be wierd.
the button works, i get the confirmation pop-up and when i hit confirm the post is happening, but the returned data from the post is empty, see below:
{"data":[],"debug":[]}
so it seems as there is no query ran and that seems to confirm what i see, the action remove/delet is not happening.
any idea where to start looking?
This question has an accepted answers - jump to answer
Answers
Hi @Maikel ,
That's the expected response, see an example here. Why do you think it isn't deleting - does the row stay in the table in the browser?
Cheers,
Colin
Hey ,
yes after the delete the row is still there ...
i expected a delete query in the debug output ...
Maikel
You need to add
->debug(true)
to your Editor PHP configuration chain (note, add it before the->process(...)
call).Allan
that is there, so it is enabled.
for the load of the data it works and i see the queries
i started to debug this a bit
and the problems seems to be in the '_remove_table' function of the Editor class
the following if is not returning true,
i think this has something todo with the way we are using the db fields.
we want to query a db from another database then the default one
so we use:
as the fields we use
$this->_part is correctly returning <tablename>
but $table has the <dbname>.<tablename>
so it looks like we either need to add the _part stuff here or the _tables var of the editor object is wrong
Agreed. Do you need to specify the full database path like that for each field? Are you doing cross database joins? Or can you just drop the
<dbname>
part?Regarding the debug not being included, can you remind me what database engine you are using? It could be that on throwing an error the debug isn't being added.
Allan
i use mysql as dbengine
And yes i need the db path in there as i'm doing cross db joins in this specific case.
The debug is empty because there was no sql command ran, in the _remove_table we exit before we can run the sql command
Could you show me your PHP configuration for the Editor please and I'll try to reproduce the error here. That should actually work with PHP and MySQL, so I must have done something "funny" with it...
Thanks,
Allan
Below is the php code, it can be that i do something stupid
note $cols is a list of all the column names for the table.
in the getPDO we connect to db1
Ah I think I see what it might be. You use the db names in the joins but not the fields. Can you add them there as well please? What you have is valid in SQL (assuming the names are unique), but Editor's parser isn't that smart...!
Allan
so you mean adding the dbnames everywhere?
if i add the db to all fields and references to fields i have the same problem
$table in Editor _remove_table is still the db.table name
Okay thank you. I'll take a look into this on Monday and see if I can figure out what is going wrong.
Allan
It ended up being Tuesday, but I have just committed the fix. You will need to have the db names everywhere as I suggested before, but this change will address the issue with not deleting the data.
The db names everywhere isn't strictly required in Editor's code, but I've got it enforced since Editor doesn't attempt to do any object name conflict resolution like SQL does. This just forces you to be explicit with your intent.
Regards,
Allan
Hey Allan, this fixes my issue, thanks a lot