本文整理汇总了PHP中Search::addWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::addWhere方法的具体用法?PHP Search::addWhere怎么用?PHP Search::addWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::addWhere方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showMinimalList
//.........这里部分代码省略.........
// If there is search items
if ($_SESSION["glpisearchcount"][$itemtype] > 0 && count($p['contains']) > 0) {
for ($key = 0; $key < $_SESSION["glpisearchcount"][$itemtype]; $key++) {
// if real search (strlen >0) and not all and view search
if (isset($p['contains'][$key]) && strlen($p['contains'][$key]) > 0) {
// common search
if ($p['field'][$key] != "all" && $p['field'][$key] != "view") {
$LINK = " ";
$NOT = 0;
$tmplink = "";
if (is_array($p['link']) && isset($p['link'][$key])) {
if (strstr($p['link'][$key], "NOT")) {
$tmplink = " " . str_replace(" NOT", "", $p['link'][$key]);
$NOT = 1;
} else {
$tmplink = " " . $p['link'][$key];
}
} else {
$tmplink = " AND ";
}
if (isset($searchopt[$itemtype][$p['field'][$key]]["usehaving"])) {
// Manage Link if not first item
if (!empty($HAVING)) {
$LINK = $tmplink;
}
// Find key
$item_num = array_search($p['field'][$key], $toview);
$HAVING .= Search::addHaving($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key], 0, $item_num);
} else {
// Manage Link if not first item
if (!empty($WHERE)) {
$LINK = $tmplink;
}
$WHERE .= Search::addWhere($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key]);
}
// view and all search
} else {
$LINK = " OR ";
$NOT = 0;
$globallink = " AND ";
if (is_array($p['link']) && isset($p['link'][$key])) {
switch ($p['link'][$key]) {
case "AND":
$LINK = " OR ";
$globallink = " AND ";
break;
case "AND NOT":
$LINK = " AND ";
$NOT = 1;
$globallink = " AND ";
break;
case "OR":
$LINK = " OR ";
$globallink = " OR ";
break;
case "OR NOT":
$LINK = " AND ";
$NOT = 1;
$globallink = " OR ";
break;
}
} else {
$tmplink = " AND ";
}
// Manage Link if not first item
if (!empty($WHERE)) {
示例2: constructSQL
//.........这里部分代码省略.........
// If there is search items
if ($_SESSION["glpisearchcount"][$itemtype] > 0 && count($p['contains']) > 0) {
for ($key = 0; $key < $_SESSION["glpisearchcount"][$itemtype]; $key++) {
// if real search (strlen >0) and not all and view search
if (isset($p['contains'][$key]) && strlen($p['contains'][$key]) > 0) {
// common search
if ($p['field'][$key] != "all" && $p['field'][$key] != "view") {
$LINK = " ";
$NOT = 0;
$tmplink = "";
if (is_array($p['link']) && isset($p['link'][$key])) {
if (strstr($p['link'][$key], "NOT")) {
$tmplink = " " . str_replace(" NOT", "", $p['link'][$key]);
$NOT = 1;
} else {
$tmplink = " " . $p['link'][$key];
}
} else {
$tmplink = " AND ";
}
if (isset($searchopt[$itemtype][$p['field'][$key]]["usehaving"])) {
// Manage Link if not first item
if (!empty($HAVING)) {
$LINK = $tmplink;
}
// Find key
$item_num = array_search($p['field'][$key], $toview);
$HAVING .= Search::addHaving($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key], 0, $item_num);
} else {
// Manage Link if not first item
if (!empty($WHERE)) {
$LINK = $tmplink;
}
$WHERE .= Search::addWhere($LINK, $NOT, $itemtype, $p['field'][$key], $p['searchtype'][$key], $p['contains'][$key]);
}
// view and all search
} else {
$LINK = " OR ";
$NOT = 0;
$globallink = " AND ";
if (is_array($p['link']) && isset($p['link'][$key])) {
switch ($p['link'][$key]) {
case "AND":
$LINK = " OR ";
$globallink = " AND ";
break;
case "AND NOT":
$LINK = " AND ";
$NOT = 1;
$globallink = " AND ";
break;
case "OR":
$LINK = " OR ";
$globallink = " OR ";
break;
case "OR NOT":
$LINK = " AND ";
$NOT = 1;
$globallink = " OR ";
break;
}
} else {
$tmplink = " AND ";
}
// Manage Link if not first item
if (!empty($WHERE)) {
示例3: 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'] . "&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);
//.........这里部分代码省略.........
示例4: showBoard
function showBoard($width = '', $limit = '')
{
global $DB, $CFG_GLPI, $LANG;
$where = '';
if ($limit == 'hosts') {
$where = "`plugin_monitoring_services_id`='0' ";
} else {
if ($limit == 'services') {
$where = "`plugin_monitoring_services_id`>0 ";
}
}
if (isset($_SESSION['plugin_monitoring']['service']['field'])) {
foreach ($_SESSION['plugin_monitoring']['service']['field'] as $key => $value) {
$wheretmp = '';
if (isset($_SESSION['plugin_monitoring']['service']['link'][$key])) {
$wheretmp .= " " . $_SESSION['plugin_monitoring']['service']['link'][$key] . " ";
}
$wheretmp .= Search::addWhere("", 0, "PluginMonitoringService", $_SESSION['plugin_monitoring']['service']['field'][$key], $_SESSION['plugin_monitoring']['service']['searchtype'][$key], $_SESSION['plugin_monitoring']['service']['contains'][$key]);
if (!strstr($wheretmp, "``.``")) {
if ($where != '' and !isset($_SESSION['plugin_monitoring']['service']['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 = '';
if (isset($_SESSION['plugin_monitoring']['service']['field'])) {
foreach ($_SESSION['plugin_monitoring']['service']['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') {
$leftjoin .= " LEFT JOIN `glpi_plugin_monitoring_components`\n ON `plugin_monitoring_components_id` = \n `glpi_plugin_monitoring_components`.`id` ";
} 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` ";
}
}
}
}
}
}
$query = "SELECT `" . getTableForItemType("PluginMonitoringService") . "`.* FROM `" . getTableForItemType("PluginMonitoringService") . "`\n " . $leftjoin . "\n " . $where . "\n ORDER BY `name`";
$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'] . "&order=" . $_GET['order'] . $globallinkto;
printPager($_GET['start'], $numrows, $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.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);
if ($width == '') {
echo "<table class='tab_cadrehov' style='width:100%;'>";
} else {
echo "<table class='tab_cadrehov' style='width:100%;'>";
}
echo "<tr class='tab_bg_1'>";
echo "<th>";
echo $LANG['joblist'][0];
echo "</th>";
echo "<th>";
echo $LANG['entity'][0];
echo "</th>";
echo "<th>";
echo $LANG['stats'][7];
echo "</th>";
echo "<th>";
echo $LANG['state'][6] . " - " . $LANG['common'][16];
echo "</th>";
echo "<th>";
echo $LANG['plugin_monitoring']['component'][0];
echo "</th>";
echo "<th>";
echo $LANG['state'][0];
echo "</th>";
echo "<th>";
echo $LANG['plugin_monitoring']['service'][18];
echo "</th>";
//.........这里部分代码省略.........