public function executeRemovePhoto(sfWebRequest $request) { $c = new Criteria(); $c->add(MissionPhotoPeer::ID, $request->getParameter('id')); $photos = MissionPhotoPeer::doSelect($c); $ad_photo = $photos[0]->getPhotoFilename(); $img_dir = sfConfig::get('sf_upload_dir') . '/mission_photo/display/'; $img_thmb = sfConfig::get('sf_upload_dir') . '/mission_photo/thumbnails/'; //unlink function return bool so you can use it as conditon if (@unlink($img_dir . $ad_photo) && @unlink($img_thmb . $ad_photo)) { $c->add(MissionPhotoPeer::PHOTO_FILENAME, ''); MissionPhotoPeer::doUpdate($c); } $this->redirect("mission_photo/show?id=" . $request->getParameter('id')); }
<?php use_helper('Form'); $date_widget = $sf_data->getRaw('date_widget'); use_javascripts_for_form($date_widget); use_stylesheets_for_form($date_widget); $c = new Criteria(); $c->add(MissionPhotoPeer::ID, $mission_photo->getId()); $pht = MissionPhotoPeer::doSelect($c); ?> <style type="text/css"> .mission-photo-table{ width:100%; border-collapse:collapse; margin:5px 0 0; } .mission-photo-table td{ margin:0; padding:0; border:1px solid #bcbcbe; height:20px; } .mission-photo-table thead td{ background:#cfe1fc; border-color:#a6bee0; color:#153f7a; font-weight:bold; text-align:center; } .mission-photo-table tbody td{ padding:5px 15px;
/** * 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(MissionPhotoPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(MissionPhotoPeer::DATABASE_NAME); $criteria->add(MissionPhotoPeer::ID, $pks, Criteria::IN); $objs = MissionPhotoPeer::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 = MissionPhotoPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setFirstName($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setLastName($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setSubmissionDate($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setMissionDate($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setPassengerName($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setPilotName($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setOrigin($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { $this->setDestination($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { $this->setCaption($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { $this->setComment($arr[$keys[10]]); } if (array_key_exists($keys[11], $arr)) { $this->setPhotoFilename($arr[$keys[11]]); } if (array_key_exists($keys[12], $arr)) { $this->setMissionId($arr[$keys[12]]); } if (array_key_exists($keys[13], $arr)) { $this->setReviewDate($arr[$keys[13]]); } if (array_key_exists($keys[14], $arr)) { $this->setReviewBy($arr[$keys[14]]); } if (array_key_exists($keys[15], $arr)) { $this->setApproved($arr[$keys[15]]); } if (array_key_exists($keys[16], $arr)) { $this->setFilesize($arr[$keys[16]]); } if (array_key_exists($keys[17], $arr)) { $this->setHeight($arr[$keys[17]]); } if (array_key_exists($keys[18], $arr)) { $this->setWidth($arr[$keys[18]]); } if (array_key_exists($keys[19], $arr)) { $this->setFileFormat($arr[$keys[19]]); } if (array_key_exists($keys[20], $arr)) { $this->setPhotoQuality($arr[$keys[20]]); } if (array_key_exists($keys[21], $arr)) { $this->setEventId($arr[$keys[21]]); } if (array_key_exists($keys[22], $arr)) { $this->setLegId($arr[$keys[22]]); } if (array_key_exists($keys[23], $arr)) { $this->setCategory($arr[$keys[23]]); } if (array_key_exists($keys[24], $arr)) { $this->setPhotoUse($arr[$keys[24]]); } }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Mission is new, it will return * an empty collection; or if this Mission has previously * been saved, it will retrieve related MissionPhotos from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Mission. */ public function getMissionPhotosJoinMissionLeg($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { if ($criteria === null) { $criteria = new Criteria(MissionPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collMissionPhotos === null) { if ($this->isNew()) { $this->collMissionPhotos = array(); } else { $criteria->add(MissionPhotoPeer::MISSION_ID, $this->id); $this->collMissionPhotos = MissionPhotoPeer::doSelectJoinMissionLeg($criteria, $con, $join_behavior); } } else { // 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(MissionPhotoPeer::MISSION_ID, $this->id); if (!isset($this->lastMissionPhotoCriteria) || !$this->lastMissionPhotoCriteria->equals($criteria)) { $this->collMissionPhotos = MissionPhotoPeer::doSelectJoinMissionLeg($criteria, $con, $join_behavior); } } $this->lastMissionPhotoCriteria = $criteria; return $this->collMissionPhotos; }