0
$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.

3
  • 1
    I think you want Processing.org_dress_id, not processing.org_dress_id. Commented Oct 12, 2024 at 14:04
  • I've tried that but it still isn't working Commented Oct 13, 2024 at 6:44
  • Is the error message the same when you try it that way? Commented Oct 14, 2024 at 14:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.