Example #1
0
 /**
  *
  * @param string $pName
  * @param string | Zupal_Places_States $pState
  * @param string | Zupal_Places_Countries $pCountry
  * @return <type>
  */
 public static function find_city($pName, $pState, $pCountry)
 {
     $table = self::getInstance()->table();
     if (!$pCountry instanceof Zupal_Places_Countries && $pCountry) {
         $pCountry = Zupal_Places_Countries::get_country($pCountry);
     }
     if (!$pCountry) {
         return NULL;
     }
     if ($pCountry->has_states) {
         if (!$pState instanceof Zupal_Places_States && $pState) {
             $pState = Zupal_Places_States::get_state($pState);
         }
         if (!$pState) {
             return NULL;
         }
         $select = $table->select()->where('name LIKE ?', $pName)->where('state = ?', $pState->identity())->where('country LIKE ?', $pCountry->identity());
     } else {
         $select = $table->select()->where('name LIKE ?', $pName)->where('country LIKE ?', $pCountry->identity());
     }
     $row = $table->fetchRow($select);
     if ($row) {
         return new Zupal_Places_Cities($row);
     } else {
         return NULL;
     }
 }
Example #2
0
 /**
  * @return Zupal_Places_Countries;
  */
 public function getCountry()
 {
     if ($this->country_id) {
         return Zupal_Places_Countries::get_country($this->country_id);
     } elseif ($this->country) {
         return Zupal_Places_Countries::get_country($this->country);
     } else {
         return NULL;
     }
 }