public function update($id, $data) { $change_id = false; if (isset($data['id'])) { if ($data['id'] == $id) { unset($data['id']); } else { $change_id = true; } } $this->updateById($id, $data); if ($change_id) { $set_products_model = new shopSetProductsModel(); $set_products_model->updateByField(array('set_id' => $id), array('set_id' => $data['id'])); } }