Exemplo n.º 1
0
 private function setQuery($in)
 {
     setMickaLog($in, 'FUNCTION', "MdExport.setQuery.start");
     $rs = array();
     //$wms_service = Array([0] => Array([0] => "@type = 'service'", [1] => 'AND', [2] => "@stype = 'WMS'"));
     $this->setSqlMd();
     if (is_array($in)) {
         if (count($in) == 0 && $this->sql_uuid == '') {
             $this->setSqlEmptyIn();
         } elseif (count($in) == 1 && is_array($in[0]) === TRUE && count($in[0]) == 0 && $this->sql_uuid == '') {
             $this->setSqlEmptyIn();
         } elseif (count($in) == 0 && $this->sql_uuid != '') {
             // zjednodušený dotaz dle uuid
             $this->sql_final[0] = 'SELECT recno, last_update_date, title FROM md WHERE uuid IN ' . $this->sql_uuid;
         } else {
             if ($this->isSimpleQuery() === TRUE) {
                 $this->walkQueryInSimple();
             } else {
                 $this->walkSqlArray($in);
             }
         }
         //$this->setSqlMd();
         //Debugger::dump($this->sql_md);
         $sql = $this->getSql('count', $this->user, 0, $this->sortBy);
         // pro odhad na Oracle
         //$sql = $this->getSql('sample', $this->user, 0, 0, $this->maxRecords, $this->sortBy);
         if ($this->query_status === FALSE) {
             return -1;
         }
     } else {
         setMickaLog('Bad format query (not array)!', 'ERROR', 'MdExport.setQuery');
         return -1;
     }
     if ($sql == -1 || $sql == '') {
         setMickaLog('SQL == -1 or null', 'ERROR', 'MdExport.setQuery');
         return -1;
     }
     if ($this->search_uuid === TRUE) {
         setMickaLog('search UUID', 'DEBUG', "MdExport.setQuery.uuid");
         $rs['paginator']['records'] = 1;
         $rs['sql'] = "SELECT recno, uuid, md_standard, lang, data_type, create_user, create_date, last_update_user, last_update_date, edit_group, view_group, valid, xmldata AS pxml FROM md";
         //$rs['sql'] = "SELECT recno, uuid, xmldata FROM md";
         /*
         if (strpos($this->sql_uuid, ",") === FALSE) {
         	$rs['sql'] .= " WHERE uuid='" . $this->sql_uuid . "'";
         }
         else {
         	$this->sql_uuid = str_replace(',', "','", $this->sql_uuid);
         	$rs['sql'] .= " WHERE uuid IN ('" . $this->sql_uuid . "')";
         }
         */
         $rs['sql'] .= " WHERE " . $this->getRight() . " uuid IN " . $this->sql_uuid;
         return $rs;
     }
     $founds = getPaginator($sql, $this->maxRecords, $this->page_number);
     setMickaLog($founds, 'DEBUG', "MdExport.setQuery.founds");
     if ($founds == -1) {
         setMickaLog('$founds == -1', 'ERROR', 'MdExport.setQuery');
         $this->error = -1;
         //Error
     } else {
         $rs['paginator'] = $founds;
     }
     /*
     		// Pokud je použit odhad pro Oracle
     		if ($founds['records'] > 0 && $founds['records'] < 1000) {
     			$sql = $this->getSql('count', $this->user, 0, 0, $this->maxRecords, $this->sortBy);
     			$founds = getPaginator($sql, $this->maxRecords, $this->page_number);
     			setMickaLog($founds, 'DEBUG', "MdExport.setQuery.founds_count");
     			$rs['paginator'] = $founds;
     		}
     * 
     */
     $sql = '';
     if ($founds['records'] > 0) {
         if ($founds['end_page'] < $this->page_number) {
             if ($this->startPosition - $this->maxRecords > 0) {
                 $this->startPosition = $this->startPosition - $this->maxRecords;
             }
         }
         $sql = $this->getSql('find', $this->user, $this->startPosition, $this->sortBy);
     }
     if ($sql == -1) {
         setMickaLog('SQL == -1', 'ERROR', 'MdExport.setQuery');
         return -1;
     }
     $rs['sql'] = $sql;
     return $rs;
 }
Exemplo n.º 2
0
 $user[] = $values['user_name'];
 //$user[] = $values['user_description'];
 $group[] = $values['group_name'];
 $group[] = $values['group_description'];
 $group[] = $values['group_tag'];
 //$group[] = $values['group_category'];
 $page[] = $values['page_name'];
 $page[] = $values['page_description'];
 //$page[] = $values['page_city'];
 //$page[] = $values['page_state'];
 //$page[] = $values['page_phone'];
 $other[] = $values['other_name'];
 $other[] = $values['other_description'];
 $directory[] = $values['directory_name'];
 $directory[] = $values['directory_description'];
 $paginator = getPaginator($query, null, $user, $group, $page, $directory, $other);
 $paginator->setItemCountPerPage($item_per_page);
 $data = array();
 $availableTypes = Engine_Api::_()->getItemTypes();
 $availableTypes = array_diff($availableTypes, array("groupbuy_category", "groupbuy_location", "groupbuy_param", "groupbuy_album", "groupbuy_photo", "music_playlist_song", "ynshare", "ynsharebutton", "classified_album"));
 if (count($paginator) == 0) {
     $data[] = array('key' => $query, 'label' => $view->translate('No results were found'), 'type' => 'no_result_found_link', 'url' => $view->url(array('controller' => 'search', 'module' => 'ynadvsearch'), 'default', true) . '?is_search=1&query=' . $query);
 } elseif (count($paginator) < $item_per_page) {
     $temp_data = array();
     foreach ($paginator as $item) {
         if (!$item) {
             continue;
         }
         $type = $item['type'];
         if (!in_array($type, $availableTypes)) {
             continue;