/** * Sprawdza obecnosc w bazie danych conajmniej jednego wpisu pasujacego do podanych danych * * @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 * @throws SoapFault * @return boolean */ public function checkPresence($hash, $place_name, $zip_code, $region, $district, $commune, $town, $street, $terc_region, $terc_district, $terc, $simc, $sym_ul) { 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%', 'checkPresence', $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) { 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')); } } $results = $model->fetchRow($select); return $this->_responseHandler($results ? true : false); } catch (Logic_WebService_Exception $e) { return $this->_faultHandler($e); } }