public function getQueryWhere() { $queryWhere = new \DbTableWhere(); $queryWhere->where('country_iso', $this->_data['country_iso']); if ($this->_data['postal_code']) { $queryWhere->where(new \DbTableFunction("REPLACE(postal_code, ' ', '')"), str_replace(' ', '', $this->_data['postal_code'])); } else { $queryWhere->where('city', $this->_data['city']); } return $queryWhere; }
/** * * @param int $movie_id * @param string $date * @param string|\DbTableFunction $order * @return Showtime[] */ public function getShowtimes($movie_id = null, $date = null, $order = null) { $showtimesWhere = new \DbTableWhere(); if ($movie_id) { $showtimesWhere->where('movie_id', $movie_id); } if ($date) { $showtimesWhere->where('show_date', $date); } if (!$order) { $order = new \DbTableFunction('type,show_date,show_time'); } $showtimesWhere->setOrderBy($order)->where('theatre_id', $this->_data['id']); return Showtime::manager()->getEntitiesWhere($showtimesWhere); }
/** * * @param TheatreNearby $tnb * @return GeocodeCached * */ public static function getGeocodeCached(TheatreNearby $tnb) { $queryWhere = new \DbTableWhere(); $queryWhere->where('country_iso', $tnb->country_iso); if ($tnb->postal_code) { $queryWhere->where(new \DbTableFunction("REPLACE(postal_code, ' ', '')"), str_replace(' ', '', $tnb->postal_code)); } else { $queryWhere->where('city', $tnb->city); } $key = $queryWhere->getWhereString(); if (array_key_exists($key, self::$cachedGeocodes)) { return self::$cachedGeocodes[$key]; } else { return self::$cachedGeocodes[$key] = GeocodeCached::manager()->getEntityWhere($queryWhere); } }
/** * * @param string $postalCode * @param string $countryIso * @param string $city * @return \models\entities\GeocodeCached */ public function postalCodeLookup($postalCode, $countryIso, $city = null) { $lookupWhere = new \DbTableWhere(); $countryIso = LookupResult::remapIso($countryIso); $lookupWhere->where('country_iso', $countryIso); $postalCode = str_replace(' ', '', $postalCode); if ($postalCode) { $lookupWhere->where(new \DbTableFunction("REPLACE(postal_code, ' ', '')"), $postalCode); } elseif ($city) { $lookupWhere->where('city', $city); } //var_dump($lookupWhere);exit; $cached = $this->geocodeCachedManager->getEntityWhere($lookupWhere); if ($cached) { return $cached; } $country = LookupResult::$ISO_TABLE[$countryIso]; $address = preg_replace('/\\s+/', ' ', "{$postalCode} {$city}, {$country}"); return $this->addressLookup(trim($address), array('postal_code' => $postalCode, 'city' => $city, 'country_iso' => $countryIso)); }