Insert data in multiple table

Hello i am new with Yii. I have two tables

  1. sale_order

  2. sale_order_product

Model name is:

  1. SaleOrder

  2. SaleOrderProduct

Controller is:

  1. SaleOrderController

  2. SaleOrderProductController

I want to when user fill up SaleOrder form and chose products one by one and click add button from SaleOrder form. Then i create a custom jquery, thats $_POST data to SaleOrderController. Now SaleOrderController successfully receive that data what i am insert in sale_order_product table. I write that code but it’s not working.

This function inside in SaleOrderController.




public function actionInsertOrder()

	{

		$Product = new SaleOrderProduct;

		

		$order_no = $_POST[order_no];

		

		//echo $order_no;

		

		$Product->sale_id=$order_no;

		if($Product->save())

		{

			echo 1;

		}


	}



Please help me someone for better solution.

If 1 is not echoed… it means that save has failed… check the validation errors

for that you can use $Product->getErrors() - http://www.yiiframework.com/doc/api/1.1/CModel#getErrors-detail