public function nuevoAction() { $tipoQuery = \TipoQuery::create()->find(); $tipoArray = array(); foreach ($tipoQuery as $tipo) { $tipoArray[$tipo->getIdtipo()] = $tipo->getTipoNombre(); } $productoForm = new ProductoForm($tipoArray); $request = $this->getRequest(); if ($request->isPost()) { $productoFilter = new ProductoFilter(); $productoForm->setInputFilter($productoFilter->getInputFilter()); $productoForm->setData($request->getPost()); if ($productoForm->isValid()) { if (\ArticuloQuery::create()->filterByArticuloNombre($request->getPost()->articulo_nombre)->exists()) { $ProductoQuery = \ArticuloQuery::create()->filterByArticuloNombre($request->getPost()->articulo_nombre)->findOne(); if (\PropiedadQuery::create()->filterByPropiedadNombre($request->getPost()->propiedad_nombre)->exists()) { $PropiedadQuery = \PropiedadQuery::create()->filterByPropiedadNombre($request->getPost()->propiedad_nombre)->findOne(); $Propiedadvalor = new \Propiedadvalor(); $Propiedadvalor->setIdarticulo($ProductoQuery->getIdarticulo()); $Propiedadvalor->setIdpropiedad($PropiedadQuery->getIdpropiedad()); $Propiedadvalor->setPropiedadvalorNombre($request->getPost()->propiedadvalor_nombre); $Propiedadvalor->save(); } } $Producto = new \Articulo(); foreach ($productoForm->getData() as $ProductoKey => $ProductoValue) { if ($ProductoKey != 'idarticulo' && $ProductoKey != 'propiedad_nombre' && $ProductoKey != 'idpropiedad' && $ProductoKey != 'propiedadvalor_nombre' && $ProductoKey != 'submit') { $Producto->setByName($ProductoKey, $ProductoValue, BasePeer::TYPE_FIELDNAME); } } $Producto->save(); $Propiedad = new \Propiedad(); $Propiedad->setIdarticulo($Producto->getIdarticulo()); $Propiedad->setPropiedadNombre($request->getPost()->propiedad_nombre); $Propiedad->save(); $Propiedadvalor = new \Propiedadvalor(); $Propiedadvalor->setIdarticulo($Producto->getIdarticulo()); $Propiedadvalor->setIdpropiedad($Propiedad->getIdpropiedad()); $Propiedadvalor->setPropiedadvalorNombre($request->getPost()->propiedadvalor_nombre); $Propiedadvalor->save(); $propiedadvalorQuery = \PropiedadvalorQuery::create()->filterByPropiedadvalorNombre($Propiedadvalor->getPropiedadvalorNombre())->find(); $propiedadvalorArray = array(); foreach ($propiedadvalorQuery as $propiedadvalorEntity) { $propiedadvalorArray[$propiedadvalorEntity->getIdpropiedadvalor()] = $propiedadvalorEntity->getPropiedadvalorNombre(); } /* return array( 'productoForm' => $productoForm, 'propiedadvalor' => $propiedadvalorArray, ); */ if ($error = !null) { return $this->redirect()->toRoute('producto'); } } } return array('productoForm' => $productoForm); }
/** * Resets all references to other model objects or collections of model objects. * * This method is a user-space workaround for PHP's inability to garbage collect * objects with circular references (even in PHP 5.3). This is currently necessary * when using Propel in certain daemon or large-volume/high-memory operations. * * @param boolean $deep Whether to also clear the references on all referrer objects. */ public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->aArticulo instanceof Persistent) { $this->aArticulo->clearAllReferences($deep); } if ($this->aArticulovariante instanceof Persistent) { $this->aArticulovariante->clearAllReferences($deep); } if ($this->aPropiedad instanceof Persistent) { $this->aPropiedad->clearAllReferences($deep); } if ($this->aPropiedadvalor instanceof Persistent) { $this->aPropiedadvalor->clearAllReferences($deep); } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aArticulo = null; $this->aArticulovariante = null; $this->aPropiedad = null; $this->aPropiedadvalor = null; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Propiedadvalor $obj A Propiedadvalor object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getIdpropiedadvalor(); } // if key === null PropiedadvalorPeer::$instances[$key] = $obj; } }
/** * Filter the query by a related Propiedadvalor object * * @param Propiedadvalor|PropelObjectCollection $propiedadvalor the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ArticuloQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByPropiedadvalor($propiedadvalor, $comparison = null) { if ($propiedadvalor instanceof Propiedadvalor) { return $this->addUsingAlias(ArticuloPeer::IDARTICULO, $propiedadvalor->getIdarticulo(), $comparison); } elseif ($propiedadvalor instanceof PropelObjectCollection) { return $this->usePropiedadvalorQuery()->filterByPrimaryKeys($propiedadvalor->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByPropiedadvalor() only accepts arguments of type Propiedadvalor or PropelCollection'); } }
/** * @param Propiedadvalor $propiedadvalor The propiedadvalor object to add. */ protected function doAddPropiedadvalor($propiedadvalor) { $this->collPropiedadvalors[] = $propiedadvalor; $propiedadvalor->setPropiedad($this); }
/** * Exclude object from result * * @param Propiedadvalor $propiedadvalor Object to remove from the list of results * * @return PropiedadvalorQuery The current query, for fluid interface */ public function prune($propiedadvalor = null) { if ($propiedadvalor) { $this->addUsingAlias(PropiedadvalorPeer::IDPROPIEDADVALOR, $propiedadvalor->getIdpropiedadvalor(), Criteria::NOT_EQUAL); } return $this; }