Only last element of array getting inserted in the table


I am using jappendo to get multiple copies of rows.

I am not able to inert all the entries into the table. Only the last row is getting inserted. Can anybody tell me what is wrong with my code.

The following is my controller code:

public function actionCreate()


		$model=new BusType;

         $model2=new BusProducts;

		// Uncomment the following line if AJAX validation is needed


 //Get the number of models you will be working with 

$maxRows =count($model2->cat_id=$_POST['cat_id']);









					 for ($i = 0; $i <= $maxRows; $i++) 

            { $model2->bus_type_id = $model->bus_type_id;


					   $model2->quantity = $_POST['quantity'][$i]; 

					    $model2->cat_id =$_POST['cat_id'][$i];

						 $model2->subcat_id = $_POST['subcat_id'][$i];