function saveNewProductSpec($id) { $product = new product($id); $productGenSpec = new productgenspec($this->input->post('newProductSpecId')); $ps = new productspec(); $ps->where('productgenspec_id', $productGenSpec->id); $ps->where('product_id', $id); $ps->get(); if ($ps->result_count() == 0) { $productSpec = new productspec(); $productSpec->product_id = $id; $productSpec->save(array('productgenspec' => $productGenSpec)); } }