public function actionEliminarProducto() { $id = Yii::app()->getRequest()->getQuery('id'); $producto = PresupuestoProductos::model()->findByPk($id); $presuPros = array(); if (!empty($producto)) { if ($producto->proyectoPartida->ente_organo_id == $this->usuario()->ente_organo_id) { $transaction = $producto->dbConnection->beginTransaction(); // Transaction begin //Yii::app()->db->beginTransaction try { if ($producto->delete()) { $transaction->commit(); // committing //return true; } else { $transaction->rollBack(); } } catch (Exception $e) { $transaction->rollBack(); } $presuPros = PresupuestoProductos::model()->findAllByAttributes(array('proyecto_partida_id' => $producto->proyecto_partida_id)); } } echo $this->renderPartial('_nacional', array('presuPros' => $presuPros), false); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = PresupuestoProductos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }