public function executeIndex(sfWebRequest $request) { //get request parameters $this->selectedBrand = $this->getRequestParameter('brand'); $this->selectedSeries = $this->getRequestParameter('series'); $this->selectedModel = $this->getRequestParameter('model'); $cConfig = new Criteria(); $cConfig->addJoin(ConfigPeer::MODEL_ID, ModelPeer::ID); $cConfig->addJoin(ModelPeer::SERIES_ID, SeriesPeer::ID); $cConfig->addJoin(SeriesPeer::BRAND_ID, BrandPeer::ID); if ($this->selectedBrand) { $cConfig->add(BrandPeer::ID, $this->selectedBrand); } if ($this->selectedSeries) { $cConfig->add(SeriesPeer::SERIES_NAME, $this->selectedSeries, Criteria::LIKE); } if ($this->selectedModel) { $cConfig->add(ModelPeer::MODEL_NAME, $this->selectedModel, Criteria::LIKE); } //$this->Configs = ConfigPeer::doSelect($cConfig); //paginatiom $pager = new sfPropelPager('Config', 15); $pager->setCriteria($cConfig); $pager->setPage($this->getRequestParameter('page')); $pager->init(); $this->pager = $pager; //get config columns $c = new Criteria(); $c->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT); $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect($c); //get brands $cBrand = new Criteria(); $this->brands = BrandPeer::doSelect($cBrand); }
public function execute($request) { /*$this->form = new sfForm(); $this->form->setWidgets(array( 'brand' => new sfWidgetFormInputText(), 'series' => new sfWidgetFormInputText(), 'model' => new sfWidgetFormInputText(), 'id' => new sfWidgetFormInputHidden(), 'cpu' => new sfWidgetFormInputText(), 'cache' => new sfWidgetFormInputText(), 'hdd' => new sfWidgetFormInputText(), 'ram' => new sfWidgetFormInputText(), 'graphic' => new sfWidgetFormInputText(), 'display' => new sfWidgetFormInputText(), 'weight' => new sfWidgetFormInputText(), 'optic' => new sfWidgetFormInputText(), 'network' => new sfWidgetFormInputText(), 'wifi' => new sfWidgetFormInputText(), 'wwan' => new sfWidgetFormInputText(), 'size' => new sfWidgetFormInputText(), 'battery' => new sfWidgetFormInputText(), 'os' => new sfWidgetFormInputText(), 'created_at' => new sfWidgetFormDateTime(), 'updated_at' => new sfWidgetFormDateTime(), ));*/ $this->isNew = true; //load config $this->config = new Config(); $this->configId = null; //load model $this->model = new Model(); //load other configuration for this model $this->configs = $this->model->getConfigs(); //load series $this->series = new Series(); //get brands $cBrand = new Criteria(); $this->brands = BrandPeer::doSelect($cBrand); $this->selectedBrand = null; $cFieldCat = new Criteria(); $cFieldCat->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT); $this->configFieldCategories = ConfigFieldCategoryPeer::doselect($cFieldCat); $this->setTemplate('config'); }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { //tabs array, we add tab items to it $this->tabs = array(); //get available brands $this->brands = BrandPeer::doSelect(new Criteria()); $tabIndex = 1; $this->tabs[$tabIndex]['title'] = 'برند'; $this->tabs[$tabIndex]['content'] = $this->renderBrands($this->brands); ++$tabIndex; //get field sets $this->configFieldCategories = ConfigFieldCategoryPeer::doSelect(new Criteria()); foreach ($this->configFieldCategories as $configFieldCategory) { $this->tabs[$tabIndex]['title'] = $configFieldCategory->getName(); $this->tabs[$tabIndex]['content'] = $this->renderFieldCategory($configFieldCategory); ++$tabIndex; } }
public function executeListMoveDown(sfWebRequest $request) { $id = $request->getParameter('id'); $current = BrandPeer::retrieveByPK($id); $items = BrandPeer::doSelect(new Criteria()); for ($i = count($items) - 2; $i >= 0; $i--) { //echo $items[$i]; if ($items[$i]->getId() == $id) { $tmp = $items[$i + 1]->getWeight(); $items[$i + 1]->setWeight($tmp != $items[$i]->getWeight() ? $items[$i]->getWeight() : $items[$i]->getWeight() + 1); $items[$i]->setWeight($tmp); $items[$i]->save(); $items[$i + 1]->save(); break; } } $this->redirect('brand'); }
public function execute($request) { $this->isNew = false; //load config $this->config = ConfigPeer::retrieveByPK($this->configId = $this->getRequestParameter('id')); $this->forward404Unless($this->config); $this->configId = $this->config->getId(); //load model $this->model = $this->config->getModel(); //load other configuration for this model $this->configs = $this->model->getConfigs(); //load series $this->series = $this->model->getSeries(); //get brands $cBrand = new Criteria(); $this->brands = BrandPeer::doSelect($cBrand); $this->selectedBrand = $this->series->getBrandId(); $cFieldCat = new Criteria(); $cFieldCat->addDescendingOrderByColumn(ConfigFieldCategoryPeer::WEIGHT); $this->configFieldCategories = ConfigFieldCategoryPeer::doselect($cFieldCat); $this->setTemplate('config'); }
public function executeDelete(sfWebRequest $request) { $type = $request->getParameter('type'); $id = $request->getParameter('id'); $c = new Criteria(); try { if ($type == "brand") { BrandPeer::doDelete($c->add(BrandPeer::ID, $id)); } if ($type == "series") { SeriesPeer::doDelete($c->add(SeriesPeer::ID, $id)); } if ($type == "model") { ModelPeer::doDelete($c->add(ModelPeer::ID, $id)); } if ($type == "config") { ConfigPeer::doDelete($c->add(ConfigPeer::ID, $id)); } $this->res = "OK"; } catch (Exception $exc) { $this->res = $exc->getMessage(); } }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = BrandPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setLabel($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setClientId($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setApplicationNumber($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setApplicationDate($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setStatus($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setRegisterNumber($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setRegistrationDate($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setKind($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setExpiresOn($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setViennaClasses($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setColors($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setNiceClasses($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setRightsOwner($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setRightsOwnerId($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setRightsOwnerAddress($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setRightsRepresentative($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setRightsRepresentativeId($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setRightsRepresentativeAddress($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setOfficeOfOrigin($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setDesignatedContractingParty($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setImage($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setCreatedAt($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setUpdatedAt($arr[$keys[23]]); } if (array_key_exists($keys[24], $arr)) { $this->setPublicationStatus($arr[$keys[24]]); } }
/** * Get the associated Brand object * * @param PropelPDO Optional Connection object. * @return Brand The associated Brand object. * @throws PropelException */ public function getBrand(PropelPDO $con = null) { if ($this->aBrand === null && ($this->brand_id !== "" && $this->brand_id !== null)) { $this->aBrand = BrandPeer::retrieveByPk($this->brand_id); /* The following can be used additionally to guarantee the related object contains a reference to this object. This level of coupling may, however, be undesirable since it could result in an only partially populated collection in the referenced object. $this->aBrand->addSeriess($this); */ } return $this->aBrand; }
/** * 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(BrandPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(BrandPeer::DATABASE_NAME); $criteria->add(BrandPeer::ID, $pks, Criteria::IN); $objs = BrandPeer::doSelect($criteria, $con); } return $objs; }
/** * Populates the object using an array. * * This is particularly useful when populating an object from one of the * request arrays (e.g. $_POST). This method goes through the column * names, checking to see whether a matching key exists in populated * array. If so the setByName() method is called for that column. * * You can specify the key type of the array by additionally passing one * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. * The default key type is the column's phpname (e.g. 'AuthorId') * * @param array $arr An array to populate the object from. * @param string $keyType The type of keys the array uses. * @return void */ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = BrandPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setBrandName($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setBrandInfo($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setBrandCountry($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setWeight($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setCreatedAt($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setUpdatedAt($arr[$keys[6]]); } }
/** * Selects a collection of Series objects pre-filled with all related objects. * * @param Criteria $criteria * @param PropelPDO $con * @param String $join_behavior the type of joins to use, defaults to Criteria::LEFT_JOIN * @return array Array of Series objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(self::DATABASE_NAME); } SeriesPeer::addSelectColumns($criteria); $startcol2 = SeriesPeer::NUM_COLUMNS - SeriesPeer::NUM_LAZY_LOAD_COLUMNS; BrandPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + (BrandPeer::NUM_COLUMNS - BrandPeer::NUM_LAZY_LOAD_COLUMNS); $criteria->addJoin(SeriesPeer::BRAND_ID, BrandPeer::ID, $join_behavior); // symfony_behaviors behavior foreach (sfMixer::getCallables(self::getMixerPreSelectHook(__FUNCTION__)) as $sf_hook) { call_user_func($sf_hook, 'BaseSeriesPeer', $criteria, $con); } $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = SeriesPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = SeriesPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://propel.phpdb.org/trac/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = SeriesPeer::getOMClass(false); $obj1 = new $cls(); $obj1->hydrate($row); SeriesPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined Brand rows $key2 = BrandPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = BrandPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = BrandPeer::getOMClass(false); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); BrandPeer::addInstanceToPool($obj2, $key2); } // if obj2 loaded // Add the $obj1 (Series) to the collection in $obj2 (Brand) $obj2->addSeries($obj1); } // if joined row not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }