Esempio n. 1
0
 /**
  * Zwraca liste wspisow pasujacych do zadanych parametrow
  *
  * Lista ograniczona jest parametrem $limit, domyslnie do 100 rekordow.
  *
  * @param string $hash
  * @param string $place_name
  * @param string $zip_code
  * @param string $region
  * @param string $district
  * @param string $commune
  * @param string $town
  * @param string $street
  * @param string $terc_region
  * @param string $terc_district
  * @param string $terc
  * @param string $simc
  * @param string $sym_ul
  * @param integer $limit
  * @throws SoapFault
  * @return object
  */
 public function searchByParams($hash, $place_name, $zip_code, $region, $district, $commune, $town, $street, $terc_region, $terc_district, $terc, $simc, $sym_ul, $limit = 100)
 {
     try {
         $mapping = array('place_name' => $place_name, 'zip_code' => $zip_code, 'region' => $region, 'commune' => $commune, 'street' => $street, 'terc_region' => $terc_region, 'terc_district' => $terc_district, 'terc' => $terc, 'simc' => $simc, 'sym_ul' => $sym_ul);
         // usluga: Kody pocztowe; id: 4
         $this->_init($hash, 'Kes)9sW%', 'searchByParams', $mapping, $this->_revision);
         $model = new Zipcode();
         $select = $model->select();
         foreach ($mapping as $key => $val) {
             if (!empty($val)) {
                 $select->where($key . ' LIKE ?', '%' . mb_strtolower(strval($val), 'UTF-8') . '%');
             }
         }
         if ($district || $town) {
             $model->getAdapter()->query('SELECT set_limit(0.6);');
             if ($district && $town && $district != $town) {
                 $select->where($model->getAdapter()->quoteInto('district % ?', mb_strtolower(strval($district), 'UTF-8')) . ' OR ' . $model->getAdapter()->quoteInto('town % ?', mb_strtolower(strval($town), 'UTF-8')));
             } elseif ($district) {
                 $select->where('district % ?', mb_strtolower(strval($district), 'UTF-8'));
             } else {
                 $select->where('town % ?', mb_strtolower(strval($town), 'UTF-8'));
             }
         }
         $select->limit($limit);
         $results = $model->fetchAll($select);
         $object = new stdClass();
         if (!empty($results)) {
             $object->resultsList = $results->toArray();
         } else {
             $object->resultsList = array();
         }
         return $this->_responseHandler($object);
     } catch (Logic_WebService_Exception $e) {
         return $this->_faultHandler($e);
     }
 }