Inner Join – Edit Error

QuestionsInner Join – Edit Error
Shannon DeWitt asked 3 years ago

I have 2 tables [gamelist] and [user] and I run an inner join on them to show the table in GRIDPHP. It works perfect. Even though there is an INNER JOIN, I only plan to edit/delete from table [gamelist]. I never plan to edit [user] with the grid. I can delete rows with NO PROBLEM, it removes them from [gamelist]. If I try to EDIT a row and click save, I get an error that there are UNKNOWN COLUMNS. These are the columns from [user] table, I did not make change to those and dont plan to.

$g->table = “gamelist”;

$g->select_command = “SELECT games.gamelistid, games.gametitle, games.gametype, user.firstname, user.lastname, games.ownerid, games.builtyear, games.manufacturer, games.awards
FROM gamelist as games
LEFT JOIN accounts as user on games.ownerid=user.id”;

2 Answers
Tim Moore answered 3 years ago

The grid does not know what to do with that information. The easiest way to fix this, in my opinion, is to call an event on add or update and unset the data you do not want to update. This will remove the error. example below.

https://gist.github.com/tmoore88/63c429dd91859738d35fc61e8d02d07f

this does require the licensed version. If you are not using that, then you might have to set those values and make them un-editable. Not 100% sure on that, and you will have to wait for an answer from Abu.

Abu answered 3 years ago

Hi,

Yes, that’s correct. Setting column’s editable property to false will remove it from insert / update query.

Another way is to connect on_update event handler and unset indexes of $data array which you don’t want to be part of library internal update query.

You can also disable the librarys update query and write your own update logic referring the docs.

https://www.gridphp.com/docs/grid-events/

You can share code as well in case of any issue.

Your Answer

3 + 11 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?