I have ‘companies’ ‘employees’ ‘event_registrations’ as tables, and I need to show this as 1 table.
eg.
event_reg / name / company
16 Nov. / John / Smith Inc.
↳ One person can have multiple registrations and one company can have multiple employees.
How do I put all this in 1 table? They are linked with: employee_ID on the event_registrations table and with company_ID on the employee table.
Cheers!
-Luca Ban
In case of using the dhtmlxConnector to load the data to the grid you may try to use the render_complex_sql method:
docs.dhtmlx.com/connector__php__ … complexsql
Here is the tutorial:
docs.dhtmlx.com/connector__php__ … omdatabase
Dear sematik,
Thank you for the links.
I was able to show the data but not edit it…
The guide says I should be able to edit the data as well, so I’m not sure what I wrote wrong in my code…
This is my code:
if ($conn->is_select_mode())//code for loading data
$conn->render_sql("Select * from employees, login_info where login_info.employee_id=employees.id",
"employees.id","id, first_name, login");
else //code for other operations - i.e. update/insert/delete
$conn->render_table("employees","id","first_name");
$conn->render_table("login_info","id","login");
There is no way to edit data in many tables at once.
You can configure connector to load data from many tables, and save only into one ( one render_table command only )
If you need to save data in multiple tables, you can define your own data saving logic
docs.dhtmlx.com/connector__php__ … lexqueries
Dear Stanislav,
I’m able to show the data of multiple tables.
However, as you said I should only be able to “edit the main table, not the joined one” But unfortunately I cannot edit even the main table with the following code:
if ($conn->is_select_mode())//code for loading data
$conn->render_sql("Select * from employees, login_info where login_info.employee_id=employees.id",
"employees.id","id, first_name, login");
else
$conn->render_table("employees","id","first_name");
The changes don’t get saved…
I also tried a complex query, but that also doesn’t work:
if ($conn->is_select_mode())//code for loading data
$conn->render_sql("Select * from employees, login_info where login_info.employee_id=employees.id",
"employees.id","id, first_name, login");
else
$conn->sql->attach("Update","Update employees set first_name='{name}' where id={id}");
$conn->render_complex_sql("employees","id","first_name");
First I’d like to be able to edit just one table with a JOINED view, if that works I wanna try going further by making the joined table also editable.
Now I can’t do either…
What I don’t understand in this example is the ‘a.id’, where does this ‘a’ come from?
↓↓↓↓↓
if ($grid->is_select_mode())//code for loading data
$grid->render_sql("Select * from tableA, tableB where tableA.id=tableB.id",
"a.id","name,price,other");
else //code for other operations - i.e. update/insert/delete
$grid->render_table("tableA","id","name,price");
Shouldn’t it be ‘tableA.id’ ?
I used ‘employees.id’ in my code above, maybe this is why I cannot save my edits.