public function filterFacility($c, $filters) { $filters_key = array_keys($filters); foreach ($filters_key as $key) { $value = $filters[$key]; if ($value == '' || $value == null) { continue; } if ($key == 'CODE') { $c->addJoin(FacilityPeer::ID, FacilityLocationPeer::FACILITY_ID); $column = FacilityPeer::getTableMap()->getColumn('CODE'); } elseif ($key == 'NAME') { $c->addJoin(FacilityPeer::ID, FacilityLocationPeer::FACILITY_ID); $column = FacilityPeer::getTableMap()->getColumn('NAME'); } else { $column = FacilityLocationPeer::getTableMap()->getColumn($key); } $name = $column->getFullyQualifiedName(); $creoleType = $column->getCreoleType(); if ($creoleType == CreoleTypes::TIMESTAMP) { $from = $value['from']; $to = $value['to']; if ($from != '' && $from != null) { $c->add($name, $from, Criteria::GREATER_EQUAL); } if ($to != '' && $to != null) { $c->add($name, $to, Criteria::LESS_EQUAL); } } else { if ($creoleType == CreoleTypes::INTEGER) { $c->add($name, $value, Criteria::EQUAL); } else { if ($creoleType == CreoleTypes::VARCHAR) { $c->add($name, "%{$value}%", Criteria::LIKE); } } } } }
public function executeDelete() { $facility = FacilityPeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($facility); $ref_error = 0; foreach ($facility->getRefCountMethods() as $ref) { $method = "count" . $ref['affix']; $count = $facility->{$method}(); if ($count > 0) { ++$ref_error; $this->getRequest()->setError('facility/delete/' . sfInflector::camelize($ref['table']), $count); } } if ($ref_error > 0) { $this->getRequest()->setError('facility/delete', '_ERR_DELETE_ (' . $facility->toString() . ' - id:' . $facility->getId() . ')'); } else { $facility->delete(); } return $this->forward('facility', 'list'); }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = FacilityPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setCode($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setName($arr[$keys[2]]); } }
public static function doSelectJoinAllExceptAcademicCalendar(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } FacilityLocationPeer::addSelectColumns($c); $startcol2 = FacilityLocationPeer::NUM_COLUMNS - FacilityLocationPeer::NUM_LAZY_LOAD_COLUMNS + 1; FacilityPeer::addSelectColumns($c); $startcol3 = $startcol2 + FacilityPeer::NUM_COLUMNS; LocationPeer::addSelectColumns($c); $startcol4 = $startcol3 + LocationPeer::NUM_COLUMNS; $c->addJoin(FacilityLocationPeer::FACILITY_ID, FacilityPeer::ID); $c->addJoin(FacilityLocationPeer::LOCATION_ID, LocationPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = FacilityLocationPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = FacilityPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getFacility(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addFacilityLocation($obj1); break; } } if ($newObject) { $obj2->initFacilityLocations(); $obj2->addFacilityLocation($obj1); } $omClass = LocationPeer::getOMClass(); $cls = Propel::import($omClass); $obj3 = new $cls(); $obj3->hydrate($rs, $startcol3); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj3 = $temp_obj1->getLocation(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) { $newObject = false; $temp_obj3->addFacilityLocation($obj1); break; } } if ($newObject) { $obj3->initFacilityLocations(); $obj3->addFacilityLocation($obj1); } $results[] = $obj1; } return $results; }
public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(FacilityPeer::ID, $pks, Criteria::IN); $objs = FacilityPeer::doSelect($criteria, $con); } return $objs; }
public function getFacility($con = null) { include_once 'lib/model/om/BaseFacilityPeer.php'; if ($this->aFacility === null && $this->facility_id !== null) { $this->aFacility = FacilityPeer::retrieveByPK($this->facility_id, $con); } return $this->aFacility; }