protected function saveCampo($campo) { if (!$campo->getIdCampo()) { if (!$campo->esTipoLista()) { //un campo "no lista" debe tener un item asociado. $item_aux = new ItemBase(); $item_aux->setOrden(1); $campo->addItemBase($item_aux); } } // Update many-to-many for "campoTablas" $campo->initRelCampoTablas(); $c = new Criteria(); $c->add(RelCampoTablaPeer::ID_CAMPO, $campo->getPrimaryKey()); RelCampoTablaPeer::doDelete($c); if (!$campo->getEsGeneral()) { if ($this->getRequestParameter('id_tabla')) { $rel = new RelCampoTabla(); $rel->setIdTabla($this->getRequestParameter('id_tabla')); $campo->addRelCampoTabla($rel); } else { $ids = $this->getRequestParameter('associated_campo_tablas'); if (is_array($ids)) { foreach ($ids as $id) { $rel = new RelCampoTabla(); $rel->setIdTabla($id); $campo->addRelCampoTabla($rel); } } } } $campo->save(); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { foreach (sfMixer::getCallables('BaseRelCampoTabla:delete:pre') as $callable) { $ret = call_user_func($callable, $this, $con); if ($ret) { return; } } if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(RelCampoTablaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { RelCampoTablaPeer::doDelete($this, $con); $this->setDeleted(true); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } foreach (sfMixer::getCallables('BaseRelCampoTabla:delete:post') as $callable) { call_user_func($callable, $this, $con); } }