0

How do To save data where grid and form has joint table?

Ok. So I have 2 tables.

employee

+---------+------------------------+
| employee_id |employee_contact_id |
+-------------+--------------------+
|  1          | 1                  |
|  2          | 2                  |
+-------------+--------------------+

employee_contact
+---------+---------------------------------+
| employee_contact_id | email               |
+---------------------+---------------------+
|  1                  | emailFrom@Employee1 |
|  2                  | emailFrom@Employee2 |
+---------------------+---------------------+

The employee table column employee_contact_id referencesenter code here employee_contact table column employee_contact_id;

My collection:

$this->getSelect()->joinLeft(
        ['secondTable' => $this->getTable('employee_contact')], //2nd table name by which you want to join
        'main_table.employee_contact_id = secondTable.employee_contact_id', // common column which available in both table 
        '*' // '*' define that you want all column of 2nd table. if you want some particular column then you can define as ['column1','column2']
    );

Appreciate Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.