$emp_detail = $this->fetchTable('EmpDetails')
->find(contain: ['Processing.ProcessStage',
'Processing.OrgDress.PrimaryC',
'Processing.OrgDress.SecondaryC',
'Processing.CutStock.ClothCutting.Items',
'Processing.CutStock.ClothCutting.ClothDetail',
'Processing.CutStock.ClothCutting.Orders.Organisation',
'Processing.CutStock.ClothCutting.Orders.OrderDetails'])
->where(['EmpDetails.role_id IN' => array('4', '6', '7')])
->join(['o' => ['table' => 'order_details',
'type' => 'LEFT',
'conditions' => 'o.org_dress_id = processing.org_dress_id']])
->all()
->toList();
this is my code for retrieving the result set for the EmpDetails Table. But for some reasons it is giving me above error. My tables look like this:
| Table Name | Columns |
|---|---|
| emp_details | id, role_id, name |
| processing | id, emp_id, cut_stock_id, sq_str, org_dress_id |
| cut_stock | id, cloth_cutting_id, sq_str |
| cloth_cutting | id, emp_id, cloth_detail_id, item_id, order_id |
| orders | id, org_id |
| order_details | id, order_id, org_dress_id, sq_str |
Now the column org_dress_id is in two tables processing and order_details.
org_dress_id column stores the information about the details of the product. org_dress_id in processing table stores which item is being produced. And org_dress_id in order_details table stored if there is any order of the same product. Now when I retrieve the emp_details data using the above line of code I have put a left join so that it fetches only the orders for which the processing is being done. but it is throwing above error.
If I do not put the join it fetches all the order details related to the order_id but I do not want that.
Processing.org_dress_id, notprocessing.org_dress_id.