public function getFields() { $c = new Criteria(); $c->add(ConfigFieldPeer::CATEGORY_ID, $this->getId()); $c->addAscendingOrderByColumn(ConfigFieldPeer::WEIGHT); return ConfigFieldPeer::doSelect($c); }
public function getConfigFieldCategoryValue($configFieldCategory) { $resultStr = ''; $cFields = new Criteria(); $cFields->add(ConfigFieldPeer::CATEGORY_ID, $configFieldCategory->getId()); $cFields->addDescendingOrderByColumn(ConfigFieldPeer::WEIGTH); $fields = ConfigFieldPeer::doSelect($cFields); //make fields id array $fieldsIdArr = array(); foreach ($fields as $field) { $fieldsIdArr[] = $field->getId(); } //print_r($fields); //exit(); // $cValue = new Criteria(); $cValue->add(FieldValuePeer::FIELD_ID, $fieldsIdArr, Criteria::IN); $cValue->add(FieldValuePeer::CONFIG_ID, $this->getId()); $fieldValues = FieldValuePeer::doSelect($cValue); foreach ($fieldValues as $fieldValue) { if (strlen($fieldValue->getValue()) > 0) { $resultStr .= $fieldValue->getValue() . $fieldValue->getHtmlComment() . '-'; } } return $resultStr; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function retrieveByPKs($pks, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(ConfigFieldPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ConfigFieldPeer::DATABASE_NAME); $criteria->add(ConfigFieldPeer::ID, $pks, Criteria::IN); $objs = ConfigFieldPeer::doSelect($criteria, $con); } return $objs; }
public function execute($request) { //get params $this->brand = $this->getRequestParameter('brand'); $this->series = $this->getRequestParameter('series'); $this->model = $this->getRequestParameter('model'); $this->configId = $this->getRequestParameter('config_id'); //get image files $this->mainImage = $this->getRequest()->getFiles('main_image'); $this->otherImages = $this->getRequest()->getFiles('other_images'); //print_r($this->otherImages); //exit (); //load/create series and model if (SeriesPeer::isNew($this->series)) { //create new series $seriesObj = new Series(); $seriesObj->setSeriesName($this->series); $seriesObj->setBrandId($this->brand); $seriesObj->save(); //create new model $modelObj = new Model(); $modelObj->setModelName($this->model); $modelObj->setSeries($seriesObj); $modelObj->save(); } else { //load series object $seriesObj = SeriesPeer::getSeriesByName($this->series); if (ModelPeer::isNew($this->model)) { //create new model $modelObj = new Model(); $modelObj->setModelName($this->model); $modelObj->setSeries($seriesObj); $modelObj->save(); } else { $modelObj = ModelPeer::getModelByName($this->model); } } ////////////////////// if (($this->isNew = $this->getRequestParameter('is_new')) == 'true') { //create new config $config = new Config(); $config->setConfigName($this->getRequestParameter('name')); $config->setModel($modelObj); $config->save(); //load config fields $configFields = ConfigFieldPeer::doSelect(new Criteria()); foreach ($configFields as $configField) { //get param if ($this->hasRequestParameter("field_" . $configField->getId())) { //if (strlen($this->getRequestParameter("field_".$configField->getId())) > 0 ) //{ $fieldValue = new FieldValue(); $fieldValue->setConfig($config); $fieldValue->setFieldId($configField->getId()); $fieldValue->setValue($this->getRequestParameter("field_" . $configField->getId())); $fieldValue->save(); //} } } } else { //load config $config = ConfigPeer::retrieveByPK($this->configId); //$config->setConfigName($this->getRequestParameter('name')); $config->setModel($modelObj); $config->save(); //load config fields $configFields = ConfigFieldPeer::doSelect(new Criteria()); foreach ($configFields as $configField) { //get param if ($this->hasRequestParameter("field_" . $configField->getId())) { //if (strlen($this->getRequestParameter("field_".$configField->getId())) > 0 ) //{ $fieldValue = FieldValuePeer::getFieldValue($configField->getId(), $config->getId()); $fieldValue->setValue($this->getRequestParameter("field_" . $configField->getId())); $fieldValue->save(); //} } } } //save main image MediaPeer::saveMedia($this->mainImage, $modelObj->getId(), MediaPeer::IMAGE, 'Model', true); //save other images foreach ($this->otherImages as $image) { MediaPeer::saveMedia($image, $modelObj->getId(), MediaPeer::IMAGE, 'Model', false); } if (($saveAndNew = $this->getRequestParameter('save_and_new')) == 'true') { $this->redirect('config/newconfig'); } else { $this->redirect('config/editconfig?id=' . $config->getId()); } }
<div class="config-fields"> <h2>Configurations</h2> <?php foreach ($configFieldCategories as $configFieldCategory) { ?> <fieldset> <legend><?php echo $configFieldCategory->getName(); ?> </legend> <?php $c = new Criteria(); $c->add(ConfigFieldPeer::CATEGORY_ID, $configFieldCategory->getId()); $c->addDescendingOrderByColumn(ConfigFieldPeer::WEIGHT); $configFields = ConfigFieldPeer::doSelect($c); ?> <?php foreach ($configFields as $field) { ?> <div> <label><?php echo $field->getName(); ?> </label> <?php if ($isNew) { ?> <input type="text" name="<?php
/** * Gets an array of ConfigField objects which contain a foreign key that references this object. * * If this collection has already been initialized with an identical Criteria, it returns the collection. * Otherwise if this ConfigFieldCategory has previously been saved, it will retrieve * related ConfigFields from storage. If this ConfigFieldCategory is new, it will return * an empty collection or the current collection, the criteria is ignored on a new object. * * @param PropelPDO $con * @param Criteria $criteria * @return array ConfigField[] * @throws PropelException */ public function getConfigFields($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(ConfigFieldCategoryPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collConfigFields === null) { if ($this->isNew()) { $this->collConfigFields = array(); } else { $criteria->add(ConfigFieldPeer::CATEGORY_ID, $this->id); ConfigFieldPeer::addSelectColumns($criteria); $this->collConfigFields = ConfigFieldPeer::doSelect($criteria, $con); } } else { // criteria has no effect for a new object if (!$this->isNew()) { // the following code is to determine if a new query is // called for. If the criteria is the same as the last // one, just return the collection. $criteria->add(ConfigFieldPeer::CATEGORY_ID, $this->id); ConfigFieldPeer::addSelectColumns($criteria); if (!isset($this->lastConfigFieldCriteria) || !$this->lastConfigFieldCriteria->equals($criteria)) { $this->collConfigFields = ConfigFieldPeer::doSelect($criteria, $con); } } } $this->lastConfigFieldCriteria = $criteria; return $this->collConfigFields; }