本文整理汇总了PHP中Search::addSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::addSelect方法的具体用法?PHP Search::addSelect怎么用?PHP Search::addSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::addSelect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showMinimalList
//.........这里部分代码省略.........
// Get the items to display
$toview = Search::addDefaultToView($itemtype);
// Add items to display depending of personal prefs
$displaypref = DisplayPreference::getForTypeUser("PluginResourcesResourceResting", Session::getLoginUserID());
if (count($displaypref)) {
foreach ($displaypref as $val) {
array_push($toview, $val);
}
}
// Add searched items
if (count($p['field']) > 0) {
foreach ($p['field'] as $key => $val) {
if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
array_push($toview, $val);
}
}
}
// Add order item
if (!in_array($p['sort'], $toview)) {
array_push($toview, $p['sort']);
}
// Clean toview array
$toview = array_unique($toview);
foreach ($toview as $key => $val) {
if (!isset($limitsearchopt[$val])) {
unset($toview[$key]);
}
}
$toview_count = count($toview);
//// 1 - SELECT
$query = "SELECT " . Search::addDefaultSelect($itemtype);
// Add select for all toview item
foreach ($toview as $key => $val) {
$query .= Search::addSelect($itemtype, $val, $key, 0);
}
$query .= "`" . $itemtable . "`.`id` AS id ";
//// 2 - FROM AND LEFT JOIN
// Set reference table
$query .= " FROM `" . $itemtable . "`";
// Init already linked tables array in order not to link a table several times
$already_link_tables = array();
// Put reference table
array_push($already_link_tables, $itemtable);
// Add default join
$COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables);
$query .= $COMMONLEFTJOIN;
$searchopt = array();
$searchopt[$itemtype] =& Search::getOptions($itemtype);
// Add all table for toview items
foreach ($toview as $key => $val) {
$query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"]);
}
// 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"]);
}
}
}
//// 3 - WHERE
// default string
$COMMONWHERE = Search::addDefaultWhere($itemtype);
$first = empty($COMMONWHERE);
// Add deleted if item have it
示例2: constructSQL
//.........这里部分代码省略.........
/* =========== Add for plugin Monitoring ============ */
$toview = array();
array_push($toview, 1);
// Add searched items
if (count($p['field']) > 0) {
foreach ($p['field'] as $key => $val) {
if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
array_push($toview, $val);
}
}
}
// Add order item
if (!in_array($p['sort'], $toview)) {
array_push($toview, $p['sort']);
}
// // Special case for Ticket : put ID in front
// if ($itemtype=='Ticket') {
// array_unshift($toview, 2);
// }
// Clean toview array
$toview = array_unique($toview);
foreach ($toview as $key => $val) {
if (!isset($limitsearchopt[$val])) {
unset($toview[$key]);
}
}
// $toview_count = count($toview);
// Construct the request
//// 1 - SELECT
// request currentuser for SQL supervision, not displayed
$SELECT = "SELECT " . Search::addDefaultSelect($itemtype);
// Add select for all toview item
foreach ($toview as $key => $val) {
$SELECT .= Search::addSelect($itemtype, $val, $key, 0);
}
//// 2 - FROM AND LEFT JOIN
// Set reference table
$FROM = " FROM `{$itemtable}`";
// Init already linked tables array in order not to link a table several times
$already_link_tables = array();
// Put reference table
array_push($already_link_tables, $itemtable);
// Add default join
$COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables);
$FROM .= $COMMONLEFTJOIN;
$searchopt = array();
$searchopt[$itemtype] =& Search::getOptions($itemtype);
// Add all table for toview items
foreach ($toview as $key => $val) {
$FROM .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]);
}
// 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)) {
$FROM .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$key]["table"], $searchopt[$itemtype][$key]["linkfield"], 0, 0, $searchopt[$itemtype][$key]["joinparams"]);
}
}
}
//// 3 - WHERE
// default string
$COMMONWHERE = Search::addDefaultWhere($itemtype);
$first = empty($COMMONWHERE);
// Add deleted if item have it
if ($item && $item->maybeDeleted()) {
示例3: showMinimalList
//.........这里部分代码省略.........
// Get the items to display
$toview = Search::addDefaultToView($itemtype);
// Add items to display depending of personal prefs
$displaypref = DisplayPreference::getForTypeUser($itemtype, Session::getLoginUserID());
if (count($displaypref)) {
foreach ($displaypref as $val) {
array_push($toview, $val);
}
}
// Add searched items
if (count($p['field']) > 0) {
foreach ($p['field'] as $key => $val) {
if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
array_push($toview, $val);
}
}
}
// Add order item
if (!in_array($p['sort'], $toview)) {
array_push($toview, $p['sort']);
}
// Clean toview array
$toview = array_unique($toview);
foreach ($toview as $key => $val) {
if (!isset($limitsearchopt[$val])) {
unset($toview[$key]);
}
}
$toview_count = count($toview);
//// 1 - SELECT
$query = "SELECT " . Search::addDefaultSelect($itemtype);
// Add select for all toview item
foreach ($toview as $key => $val) {
$query .= Search::addSelect($itemtype, $val, $key, 0);
}
$query .= "`" . $itemtable . "`.`id` AS id ";
//// 2 - FROM AND LEFT JOIN
// Set reference table
$query .= " FROM `" . $itemtable . "`";
// Init already linked tables array in order not to link a table several times
$already_link_tables = array();
// Put reference table
array_push($already_link_tables, $itemtable);
// Add default join
$COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables);
$query .= $COMMONLEFTJOIN;
$searchopt = array();
$searchopt[$itemtype] =& Search::getOptions($itemtype);
// Add all table for toview items
foreach ($toview as $key => $val) {
$query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]);
}
// 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
示例4: showList
//.........这里部分代码省略.........
foreach ($p['field'] as $key => $val) {
if (!in_array($val, $toview) && $val != 'all' && $val != 'view') {
array_push($toview, $val);
}
}
}
// Add order item
if (!in_array($p['sort'], $toview)) {
array_push($toview, $p['sort']);
}
// Special case for Ticket : put ID in front
if ($itemtype == 'Ticket') {
array_unshift($toview, 2);
}
// Clean toview array
$toview = array_unique($toview);
foreach ($toview as $key => $val) {
if (!isset($limitsearchopt[$val])) {
unset($toview[$key]);
}
}
// delete entities display
//var_dump($toview);
if (array_search('80', $toview) !== false) {
unset($toview[array_search('80', $toview)]);
}
$toview_count = count($toview);
// Construct the request
//// 1 - SELECT
//$SELECT = "SELECT ".PluginMobileSearch::addDefaultSelect($itemtype);
$SELECT = "SELECT '" . $_SESSION['glpiname'] . "' AS currentuser, " . PluginMobileSearch::addDefaultSelect($itemtype);
// Add select for all toview item
foreach ($toview as $key => $val) {
$SELECT .= Search::addSelect($itemtype, $val, $key, 0);
}
//// 2 - FROM AND LEFT JOIN
// Set reference table
$FROM = " FROM `{$itemtable}`";
// Init already linked tables array in order not to link a table several times
$already_link_tables = array();
// Put reference table
array_push($already_link_tables, $itemtable);
// Add default join
$COMMONLEFTJOIN = Search::addDefaultJoin($itemtype, $itemtable, $already_link_tables);
$FROM .= $COMMONLEFTJOIN;
$searchopt = array();
$searchopt[$itemtype] =& Search::getOptions($itemtype);
// Add all table for toview items
//foreach ($toview as $key => $val) {
// $FROM .= Search::addLeftJoin($itemtype,$itemtable,$already_link_tables,
// $searchopt[$itemtype][$val]["table"],
// $searchopt[$itemtype][$val]["linkfield"]);
//}
foreach ($toview as $key => $val) {
$FROM .= self::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt[$itemtype][$val]["table"], $searchopt[$itemtype][$val]["linkfield"], 0, 0, $searchopt[$itemtype][$val]["joinparams"]);
}
// 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)) {
// $FROM .= Search::addLeftJoin($itemtype,$itemtable,$already_link_tables,
// $searchopt[$itemtype][$key]["table"],
// $searchopt[$itemtype][$key]["linkfield"]);
// }
// }