/** * Find object by primary key using raw SQL to go fast. * Bypass doSelect() and the object formatter by using generated code. * * @param mixed $key Primary key to use for the query * @param PropelPDO $con A connection object * * @return LeasingCountry A model object, or null if the key is not found * @throws PropelException */ protected function findPkSimple($key, $con) { $sql = 'SELECT `id`, `country_name` FROM `country` WHERE `id` = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->execute(); } catch (Exception $e) { Propel::log($e->getMessage(), Propel::LOG_ERR); throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e); } $obj = null; if ($row = $stmt->fetch(PDO::FETCH_NUM)) { $obj = new LeasingCountry(); $obj->hydrate($row); LeasingCountryPeer::addInstanceToPool($obj, (string) $key); } $stmt->closeCursor(); return $obj; }
public function saveAppointmentRequestAction() { $request = $this->getRequest(); $postid = $request->request->get('unitid'); $date = $request->request->get('date'); $time = $request->request->get('time'); $leasePeriod = $request->request->get('leasePeriod'); $targetMoveIn = $request->request->get('targetMoveIn'); $fname = $request->request->get('fname'); $lname = $request->request->get('lname'); $contact = $request->request->get('contact'); $email = $request->request->get('email'); $country = LeasingCountryPeer::getIdByCountryName($request->request->get('country')); $nationality = LeasingNationalityPeer::getIdByNationalityName($request->request->get('nationality')); $notes = $request->request->get('notes'); $clientIp = $request->request->get('clientIp'); $firstHeard = $request->request->get('firstHeard'); //UNIT DETAILS $unit = LeasingUnitPeer::getUnitByPostId($postid); $lead = new LeasingAppointmentLeads(); $lead->setFname($fname); $lead->setLname($lname); $lead->setEmail($email); $lead->setMobile($contact); $lead->setCountryId($country->getId()); $lead->setNationalityId($nationality->getId()); $lead->setClientIp($clientIp); $lead->save(); $now = new \DateTime('now'); $app = new LeasingAppointments(); $app->setAppointmentLeadsId($lead->getId()); $app->setUnitId($unit->getId()); $app->setPreferredDate($date); $app->setPreferredTime($time); $app->setLeasePeriod($leasePeriod); $app->setTargetMoveIn($targetMoveIn); $app->setFirstHeard($firstHeard); $app->setNotes($notes); $app->setDateAdded($now->format(C::DATETIMEFORMAT)); $app->setStatus(C::PENDING); $app->setPrevStatus(C::PENDING); $app->save(); $tl1 = new LeasingTimelineActivity(); $tl1->setLeadTypeId(C::APPOINTMENT); $tl1->setLeadId($lead->getId()); $tl1->setUser('Lead'); $tl1->setActivity('Requested Unit Viewing'); $tl1->setTimestamp($now->format(C::DATETIMEFORMAT)); $tl1->setStatus('Pending'); $tl1->setStatusId(C::PENDING); $tl1->save(); $this->get('session')->set('thank-you', 1); $client = new GlobeClient(); $msg = "Thank you, " . $lead->getFname() . " " . $lead->getLname() . "! Your request to view " . $app->getLeasingUnit()->getName() . " is now being processed. We will update you ASAP once an agent is assigned to assist you. This msg is FREE."; $sms = $client->sms($this->globeShortCode); $response = $sms->sendMessage($lead->getMobile(), $msg, $this->appId, $this->appSecret); if ($response && !isset($response['error'])) { $badge = new LeasingLeadBadges(); $badge->setBadgeId(11); $badge->setLeadTypeId(C::APPOINTMENT); $badge->setLeadId($lead->getId()); $badge->setStatus(1); $badge->save(); $tl2 = new LeasingTimelineActivity(); $tl2->setLeadTypeId(C::APPOINTMENT); $tl2->setLeadId($lead->getId()); $tl2->setUser('System'); $tl2->setActivity('Verified mobile number'); $tl2->setTimestamp($now->format(C::DATETIMEFORMAT)); $tl2->setStatus('Mobile Verified'); $tl2->setStatusId(C::MOBILE_VERIFIED); $tl2->save(); } $ve = VerifyEmail::verifyThisEmail($lead->getEmail()); if ($ve = 'valid') { $badge = new LeasingLeadBadges(); $badge->setBadgeId(12); $badge->setLeadTypeId(C::PARKING); $badge->setLeadId($lead->getId()); $badge->setStatus(1); $badge->save(); $tl3 = new LeasingTimelineActivity(); $tl3->setLeadTypeId(C::PARKING); $tl3->setLeadId($lead->getId()); $tl3->setUser('System'); $tl3->setActivity('Verified email address'); $tl3->setTimestamp($now->format(C::DATETIMEFORMAT)); $tl3->setStatus('Email Verified'); $tl3->setStatusId(C::EMAIL_VERIFIED); $tl3->save(); } echo 1; exit; return new Response(); }
/** * 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 BasePeer::TYPE_PHPNAME * * @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 = LeasingCountryPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setCountryName($arr[$keys[1]]); } }
/** * Selects a collection of LeasingBookingLeads objects pre-filled with all related objects except LeasingNationality. * * @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 LeasingBookingLeads objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExceptLeasingNationality(Criteria $criteria, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $criteria = clone $criteria; // Set the correct dbName if it has not been overridden // $criteria->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($criteria->getDbName() == Propel::getDefaultDB()) { $criteria->setDbName(LeasingBookingLeadsPeer::DATABASE_NAME); } LeasingBookingLeadsPeer::addSelectColumns($criteria); $startcol2 = LeasingBookingLeadsPeer::NUM_HYDRATE_COLUMNS; LeasingCountryPeer::addSelectColumns($criteria); $startcol3 = $startcol2 + LeasingCountryPeer::NUM_HYDRATE_COLUMNS; $criteria->addJoin(LeasingBookingLeadsPeer::COUNTRY_ID, LeasingCountryPeer::ID, $join_behavior); $stmt = BasePeer::doSelect($criteria, $con); $results = array(); while ($row = $stmt->fetch(PDO::FETCH_NUM)) { $key1 = LeasingBookingLeadsPeer::getPrimaryKeyHashFromRow($row, 0); if (null !== ($obj1 = LeasingBookingLeadsPeer::getInstanceFromPool($key1))) { // We no longer rehydrate the object, since this can cause data loss. // See http://www.propelorm.org/ticket/509 // $obj1->hydrate($row, 0, true); // rehydrate } else { $cls = LeasingBookingLeadsPeer::getOMClass(); $obj1 = new $cls(); $obj1->hydrate($row); LeasingBookingLeadsPeer::addInstanceToPool($obj1, $key1); } // if obj1 already loaded // Add objects for joined LeasingCountry rows $key2 = LeasingCountryPeer::getPrimaryKeyHashFromRow($row, $startcol2); if ($key2 !== null) { $obj2 = LeasingCountryPeer::getInstanceFromPool($key2); if (!$obj2) { $cls = LeasingCountryPeer::getOMClass(); $obj2 = new $cls(); $obj2->hydrate($row, $startcol2); LeasingCountryPeer::addInstanceToPool($obj2, $key2); } // if $obj2 already loaded // Add the $obj1 (LeasingBookingLeads) to the collection in $obj2 (LeasingCountry) $obj2->addLeasingBookingLeads($obj1); } // if joined row is not null $results[] = $obj1; } $stmt->closeCursor(); return $results; }
/** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param PropelPDO $con the connection to use * @return LeasingCountry[] * @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(LeasingCountryPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(LeasingCountryPeer::DATABASE_NAME); $criteria->add(LeasingCountryPeer::ID, $pks, Criteria::IN); $objs = LeasingCountryPeer::doSelect($criteria, $con); } return $objs; }