当前位置: 首页>>代码示例>>PHP>>正文


PHP Search::addOrderBy方法代码示例

本文整理汇总了PHP中Search::addOrderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::addOrderBy方法的具体用法?PHP Search::addOrderBy怎么用?PHP Search::addOrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Search的用法示例。


在下文中一共展示了Search::addOrderBy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showMinimalList


//.........这里部分代码省略.........
             }
         }
     }
     if (!empty($WHERE) || !empty($COMMONWHERE)) {
         if (!empty($COMMONWHERE)) {
             $WHERE = ' WHERE ' . $COMMONWHERE . (!empty($WHERE) ? ' AND ( ' . $WHERE . ' )' : '');
         } else {
             $WHERE = ' WHERE ' . $WHERE . ' ';
         }
         $first = false;
     }
     $query .= $WHERE;
     //// 7 - Manage GROUP BY
     $GROUPBY = "";
     // Meta Search / Search All / Count tickets
     if (in_array('all', $p['field'])) {
         $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
     }
     if (empty($GROUPBY)) {
         foreach ($toview as $key2 => $val2) {
             if (!empty($GROUPBY)) {
                 break;
             }
             if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) {
                 $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
             }
         }
     }
     $query .= $GROUPBY;
     //// 4 - ORDER
     $ORDER = " ORDER BY `id` ";
     foreach ($toview as $key => $val) {
         if ($p['sort'] == $val) {
             $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key);
         }
     }
     $query .= $ORDER;
     // Get it from database
     if ($result = $DB->query($query)) {
         $numrows = $DB->numrows($result);
         $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']);
         $parameters = "sort=" . $p['sort'] . "&order=" . $p['order'] . $globallinkto;
         if ($output_type == Search::GLOBAL_SEARCH) {
             if (class_exists($itemtype)) {
                 echo "<div class='center'><h2>" . $this->getTypeName();
                 // More items
                 if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) {
                     echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>";
                 }
                 echo "</h2></div>\n";
             } else {
                 return false;
             }
         }
         if ($p['start'] < $numrows) {
             // Pager
             if ($output_type == Search::HTML_OUTPUT) {
                 Html::printPager($p['start'], $numrows, $target, $parameters, $itemtype);
             }
             //massive action
             $sel = "";
             if (isset($_GET["select"]) && $_GET["select"] == "all") {
                 $sel = "checked";
             }
             // Add toview elements
             $nbcols = $toview_count;
开发者ID:geldarr,项目名称:hack-space,代码行数:67,代码来源:resourceresting.class.php

示例2: constructSQL


//.........这里部分代码省略.........
                     $WHERE .= " ( ";
                     $first2 = true;
                     $items = array();
                     if ($p['field'][$key] == "all") {
                         $items = $searchopt[$itemtype];
                     } else {
                         // toview case : populate toview
                         foreach ($toview as $key2 => $val2) {
                             $items[$val2] = $searchopt[$itemtype][$val2];
                         }
                     }
                     foreach ($items as $key2 => $val2) {
                         if (is_array($val2)) {
                             // Add Where clause if not to be done in HAVING CLAUSE
                             if (!isset($val2["usehaving"])) {
                                 $tmplink = $LINK;
                                 if ($first2) {
                                     $tmplink = " ";
                                     $first2 = false;
                                 }
                                 $WHERE .= Search::addWhere($tmplink, $NOT, $itemtype, $key2, $p['searchtype'][$key], $p['contains'][$key]);
                             }
                         }
                     }
                     $WHERE .= " ) ";
                 }
             }
         }
     }
     //// 4 - ORDER
     $ORDER = " ORDER BY `id` ";
     foreach ($toview as $key => $val) {
         if ($p['sort'] == $val) {
             $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key);
         }
     }
     //// 5 - META SEARCH
     // Preprocessing
     if ($_SESSION["glpisearchcount2"][$itemtype] > 0 && is_array($p['itemtype2'])) {
         // a - SELECT
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                 $SELECT .= Search::addSelect($p['itemtype2'][$i], $p['field2'][$i], $i, 1, $p['itemtype2'][$i]);
             }
         }
         // b - ADD LEFT JOIN
         // Already link meta table in order not to linked a table several times
         $already_link_tables2 = array();
         // Link reference tables
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                 if (!in_array(getTableForItemType($p['itemtype2'][$i]), $already_link_tables2)) {
                     $FROM .= Search::addMetaLeftJoin($itemtype, $p['itemtype2'][$i], $already_link_tables2, $p['contains2'][$i] == "NULL" || strstr($p['link2'][$i], "NOT"));
                 }
             }
         }
         // Link items tables
         for ($i = 0; $i < $_SESSION["glpisearchcount2"][$itemtype]; $i++) {
             if (isset($p['itemtype2'][$i]) && !empty($p['itemtype2'][$i]) && isset($p['contains2'][$i]) && strlen($p['contains2'][$i]) > 0) {
                 if (!isset($searchopt[$p['itemtype2'][$i]])) {
                     $searchopt[$p['itemtype2'][$i]] =& Search::getOptions($p['itemtype2'][$i]);
                 }
                 if (!in_array($searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["table"] . "_" . $p['itemtype2'][$i], $already_link_tables2)) {
                     $FROM .= Search::addLeftJoin($p['itemtype2'][$i], getTableForItemType($p['itemtype2'][$i]), $already_link_tables2, $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["table"], $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["linkfield"], 1, $p['itemtype2'][$i], $searchopt[$p['itemtype2'][$i]][$p['field2'][$i]]["joinparams"]);
                 }
             }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:67,代码来源:search.class.php

示例3: showMinimalList


//.........这里部分代码省略.........
     }
     // Search all case :
     if (in_array("all", $p['field'])) {
         foreach ($searchopt[$itemtype] as $key => $val) {
             // Do not search on Group Name
             if (is_array($val)) {
                 $query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]);
             }
         }
     }
     $query .= " WHERE `" . $itemtable . "`.`plugin_resources_resources_id` = '" . $p['id'] . "'";
     $query .= " AND `" . $itemtable . "`.`is_deleted` = '" . $p['is_deleted'] . "' ";
     //// 7 - Manage GROUP BY
     $GROUPBY = "";
     // Meta Search / Search All / Count tickets
     if (in_array('all', $p['field'])) {
         $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
     }
     if (empty($GROUPBY)) {
         foreach ($toview as $key2 => $val2) {
             if (!empty($GROUPBY)) {
                 break;
             }
             if (isset($searchopt[$itemtype][$val2]["forcegroupby"])) {
                 $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
             }
         }
     }
     $query .= $GROUPBY;
     //// 4 - ORDER
     $ORDER = " ORDER BY `id` ";
     foreach ($toview as $key => $val) {
         if ($p['sort'] == $val) {
             $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key);
         }
     }
     $query .= $ORDER;
     // Get it from database
     if ($result = $DB->query($query)) {
         $numrows = $DB->numrows($result);
         $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']);
         $parameters = "sort=" . $p['sort'] . "&amp;order=" . $p['order'] . $globallinkto;
         if ($output_type == Search::GLOBAL_SEARCH) {
             if (class_exists($itemtype)) {
                 echo "<div class='center'><h2>" . $item->getTypeName();
                 // More items
                 if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) {
                     echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>";
                 }
                 echo "</h2></div>\n";
             } else {
                 return false;
             }
         }
         if ($p['start'] < $numrows) {
             if ($output_type == Search::HTML_OUTPUT && !$p['withtemplate']) {
                 echo "<div align='center'>";
                 echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/resources/front/task.php?contains%5B0%5D=" . $p['id'] . "&field%5B0%5D=13&sort=1&is_deleted=0&start=0'>" . _x('button', 'Search') . "</a><br>";
                 echo "</div>";
             }
             // Pager
             if ($output_type == Search::HTML_OUTPUT) {
                 // HTML display - massive modif
                 $search_config = "";
                 if ($item->canCreate() && $canedit) {
                     $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&amp;itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\"";
开发者ID:geldarr,项目名称:hack-space,代码行数:67,代码来源:task.class.php

示例4: showMinimalList


//.........这里部分代码省略.........
             }
         }
     }
     if (!empty($WHERE) || !empty($COMMONWHERE)) {
         if (!empty($COMMONWHERE)) {
             $WHERE = ' WHERE ' . $ASSIGN . ' ' . $COMMONWHERE . (!empty($WHERE) ? ' AND ( ' . $WHERE . ' )' : '');
         } else {
             $WHERE = ' WHERE ' . $ASSIGN . ' ' . $WHERE . ' ';
         }
         $first = false;
     }
     $query .= $WHERE;
     //// 7 - Manage GROUP BY
     $GROUPBY = "";
     // Meta Search / Search All / Count tickets
     if (in_array('all', $p['field'])) {
         $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
     }
     if (empty($GROUPBY)) {
         foreach ($toview as $key2 => $val2) {
             if (!empty($GROUPBY)) {
                 break;
             }
             if (isset($searchopt["PluginResourcesDirectory"][$val2]["forcegroupby"])) {
                 $GROUPBY = " GROUP BY `" . $itemtable . "`.`id`";
             }
         }
     }
     $query .= $GROUPBY;
     //// 4 - ORDER
     $ORDER = " ORDER BY `id` ";
     foreach ($toview as $key => $val) {
         if ($p['sort'] == $val) {
             $ORDER = Search::addOrderBy($itemtype, $p['sort'], $p['order'], $key);
         }
     }
     $query .= $ORDER;
     // Get it from database
     if ($result = $DB->query($query)) {
         $numrows = $DB->numrows($result);
         $globallinkto = Search::getArrayUrlLink("field", $p['field']) . Search::getArrayUrlLink("link", $p['link']) . Search::getArrayUrlLink("contains", $p['contains']) . Search::getArrayUrlLink("searchtype", $p['searchtype']) . Search::getArrayUrlLink("field2", $p['field2']) . Search::getArrayUrlLink("contains2", $p['contains2']) . Search::getArrayUrlLink("searchtype2", $p['searchtype2']) . Search::getArrayUrlLink("itemtype2", $p['itemtype2']) . Search::getArrayUrlLink("link2", $p['link2']);
         $parameters = "sort=" . $p['sort'] . "&amp;order=" . $p['order'] . $globallinkto;
         if ($output_type == Search::GLOBAL_SEARCH) {
             if (class_exists($itemtype)) {
                 echo "<div class='center'><h2>" . $this->getTypeName();
                 // More items
                 if ($numrows > $p['start'] + Search::GLOBAL_DISPLAY_COUNT) {
                     echo " <a href='{$target}?{$parameters}'>" . __('All') . "</a>";
                 }
                 echo "</h2></div>\n";
             } else {
                 return false;
             }
         }
         if ($p['start'] < $numrows) {
             // Pager
             if ($output_type == Search::HTML_OUTPUT) {
                 // HTML display - massive modif
                 $search_config = "";
                 if ($item->canCreate() && $canedit) {
                     $tmp = " class='pointer' onClick=\"var w = window.open('" . $CFG_GLPI["root_doc"] . "/front/popup.php?popup=search_config&amp;itemtype=" . $itemtype . "' ,'glpipopup', " . "'height=400, width=1000, top=100, left=100, scrollbars=yes' ); w.focus();\"";
                     $search_config = "<img alt='" . __('Select default items to show') . "' title='" . __('Select default items to show') . "' src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' ";
                     $search_config .= $tmp . ">";
                 }
                 //echo Search::showHeaderItem($output_type,$search_config,$header_num,"",0,$p['order']);
             }
开发者ID:geldarr,项目名称:hack-space,代码行数:67,代码来源:directory.class.php

示例5: showBoard

 function showBoard($width = '', $limit = '')
 {
     global $DB, $CFG_GLPI;
     $order = "ASC";
     if (isset($_GET['order'])) {
         $order = $_GET['order'];
     }
     $where = '';
     if ($limit == 'hosts') {
         $where = "`plugin_monitoring_services_id`='0' ";
     } else {
         if ($limit == 'services') {
             $where = "`plugin_monitoring_services_id`>0 ";
         }
     }
     if (isset($_GET['field'])) {
         foreach ($_GET['field'] as $key => $value) {
             $wheretmp = '';
             if (isset($_GET['link'][$key])) {
                 $wheretmp .= " " . $_GET['link'][$key] . " ";
             }
             $wheretmp .= Search::addWhere("", 0, "PluginMonitoringService", $_GET['field'][$key], $_GET['searchtype'][$key], $_GET['contains'][$key]);
             if (!strstr($wheretmp, "``.``")) {
                 if ($where != '' and !isset($_GET['link'][$key])) {
                     $where .= " AND ";
                 }
                 $where .= $wheretmp;
             }
         }
     }
     if ($where != '') {
         $where = "(" . $where;
         $where .= ") AND ";
     }
     $where .= ' `glpi_plugin_monitoring_services`.`entities_id` IN (' . $_SESSION['glpiactiveentities_string'] . ')';
     if ($where != '') {
         $where = " WHERE " . $where;
         $where = str_replace("`" . getTableForItemType("PluginMonitoringDisplay") . "`.", "", $where);
     }
     $leftjoin = '';
     $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_components`\n         ON `plugin_monitoring_components_id` = \n         `glpi_plugin_monitoring_components`.`id` ";
     $leftjoin .= " LEFT JOIN `glpi_entities`\n         ON `" . getTableForItemType("PluginMonitoringService") . "`.`entities_id` = \n               `glpi_entities`.`id`";
     if (isset($_GET['field'])) {
         foreach ($_GET['field'] as $value) {
             if ($value == '20' or $value == '21' or $value == '22') {
                 $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n                  ON `plugin_monitoring_componentscatalogs_hosts_id` = \n                  `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` ";
             } else {
                 if ($value == '7') {
                 } else {
                     if ($value == '8') {
                         if (!strstr($leftjoin, 'LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`')) {
                             $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs_hosts`\n                  ON `plugin_monitoring_componentscatalogs_hosts_id` = \n                  `glpi_plugin_monitoring_componentscatalogs_hosts`.`id` ";
                         }
                         if (!strstr($leftjoin, 'LEFT JOIN `glpi_plugin_monitoring_componentscatalogs`')) {
                             $leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_componentscatalogs`\n                     ON `glpi_plugin_monitoring_componentscatalogs_hosts`.`plugin_monitoring_componentscalalog_id` = \n                     `glpi_plugin_monitoring_componentscatalogs`.`id` ";
                         }
                     }
                 }
             }
         }
     }
     // * ORDER
     $ORDERQUERY = " ORDER BY `name` ";
     $toview = array(3, 6, 7, 10, 4, 9);
     $toviewComplete = array('ITEM_0' => 'state', 'ITEM_1' => 'completename', 'ITEM_2' => 'component_name', 'ITEM_3' => 'state', 'ITEM_4' => 'last_check', 'ITEM_5' => 'event');
     foreach ($toview as $key => $val) {
         if ($_GET['sort'] == $val) {
             $ORDERQUERY = Search::addOrderBy("PluginMonitoringService", $_GET['sort'], $_GET['order'], $key);
             foreach ($toviewComplete as $keyi => $vali) {
                 $ORDERQUERY = str_replace($keyi, $vali, $ORDERQUERY);
             }
         }
     }
     $query = "SELECT `" . getTableForItemType("PluginMonitoringService") . "`.*,\n            `glpi_plugin_monitoring_components`.`name` as component_name, \n            `glpi_entities`.`completename`\n         FROM `" . getTableForItemType("PluginMonitoringService") . "`\n         " . $leftjoin . "\n         " . $where . "\n         " . $ORDERQUERY;
     $result = $DB->query($query);
     $start = 0;
     if (isset($_GET["start"])) {
         $start = $_GET["start"];
     }
     $numrows = $DB->numrows($result);
     $parameters = '';
     $globallinkto = Search::getArrayUrlLink("field", $_GET['field']) . Search::getArrayUrlLink("link", $_GET['link']) . Search::getArrayUrlLink("contains", $_GET['contains']) . Search::getArrayUrlLink("searchtype", $_GET['searchtype']) . Search::getArrayUrlLink("field2", $_GET['field2']) . Search::getArrayUrlLink("contains2", $_GET['contains2']) . Search::getArrayUrlLink("itemtype2", $_GET['itemtype2']) . Search::getArrayUrlLink("searchtype2", $_GET['searchtype2']) . Search::getArrayUrlLink("link2", $_GET['link2']);
     $parameters = "sort=" . $_GET['sort'] . "&amp;order=" . $_GET['order'] . $globallinkto;
     Html::printPager($_GET['start'], $numrows, $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/service.php", $parameters);
     $limit = $numrows;
     if ($_SESSION["glpilist_limit"] < $numrows) {
         $limit = $_SESSION["glpilist_limit"];
     }
     $query .= " LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
     $result = $DB->query($query);
     echo '<div id="custom_date" style="display:none"></div>';
     echo '<div id="custom_time" style="display:none"></div>';
     if ($width == '') {
         echo "<table class='tab_cadrehov' style='width:100%;'>";
     } else {
         echo "<table class='tab_cadrehov' style='width:100%;'>";
     }
     $num = 0;
     echo "<tr class='tab_bg_1'>";
     $this->showHeaderItem(__('Status'), 3, $num, $start, $globallinkto);
//.........这里部分代码省略.........
开发者ID:geldarr,项目名称:hack-space,代码行数:101,代码来源:display.class.php

示例6: get_additional_team_bio_page_info

	protected function get_additional_team_bio_page_info( $team )
	{
		/* code to get testimonials ordered by date new to old */
 		loadModel( "/entities/testimonials/EntityTestimonial" );
		//$testimonials = EntityTestimonial::GetEntityTeamTestimonialsWithSubTestimonials( $team  );
		$testimonials = EntityTestimonial::GetEntityTestimonialsOrderByOrder( $team );
		$testimonial_dicts = array();
		foreach( $testimonials as $testimonial ) {
			$testimonial_dicts[] = $testimonial->getAsDictionary();
		}
		
		/* get team listings */
		loadModel( "/search/Search" );
		$properties = array();
		$search = new Search();
		$search->addTerm( 'realtor', $team->rebrand_code );
		$search->addOrderBy( 'list_price', false);
		$props = $search->run( 0, 7 );
		$tmp_properties = Property::GetPropertiesFromIdArray($props, PropertyLoadLevel::IDX_SUMMARY, true);
		foreach( $props as $prop ) {
			try{
				$property = $tmp_properties[$prop];
				// add open house
				// $property->open_house = $property->getAllDates( true );
				$temp_pic = $property->get_first_pic();
				if ( is_object( $temp_pic ) ){
					$property->photo = $temp_pic->getUrl();
				} else {
					$property->photo = false;
				}
				$properties[] = $property;
			}
			catch( Exception $e ) {}
		}
		unset($tmp_properties);
		

		/* get team sold listings */
		$sold_properties = array();
		$sold_search = new Search();
		$sold_search->addTerm( 'buyer_seller', $team->rebrand_code );
		$sold_search->addFilter( SearchFilter::SOLD );
		$sold_search->addOrderBy( 'list_price', false);
		$sold_props = $sold_search->run( 0, 3);
		//set idx view to the sold table to get the sold prop info
		IDX::Set_IDX_View_Name( IDX::SOLD );
		$tmp_properties = Property::GetPropertiesFromIdArray($sold_props, PropertyLoadLevel::IDX_SUMMARY, true);

		foreach( $sold_props as $sold_prop ) {
			try{
				$property = $tmp_properties[$sold_prop];
				$temp_pic = $property->get_first_pic();
				if ( is_object( $temp_pic ) ){
					$property->photo = $temp_pic->getUrl();
				} else {
					$property->photo = false;
				}
				$sold_properties[] = $property;
			}
			catch( Exception $e ) {}
		}
		unset($tmp_properties);

		//reset back to normal idx view
		IDX::Set_IDX_View_Name( IDX::MATERIALIZED );

		$tpl_args = array(
			'testimonials' => $testimonial_dicts,
			'properties' => $properties,
			'sold_properties' => $sold_properties,
		);
		return $tpl_args;
 	}
开发者ID:nicholasbooj,项目名称:Enterprise_Boilerplate,代码行数:73,代码来源:ctrl_Realtor.action.php


注:本文中的Search::addOrderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。