本文整理汇总了PHP中Search::addLeftJoin方法的典型用法代码示例。如果您正苦于以下问题:PHP Search::addLeftJoin方法的具体用法?PHP Search::addLeftJoin怎么用?PHP Search::addLeftJoin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search::addLeftJoin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showMinimalList
//.........这里部分代码省略.........
// 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
if ($item && $item->maybeDeleted()) {
$LINK = " AND ";
if ($first) {
$LINK = " ";
$first = false;
}
$COMMONWHERE .= $LINK . "`{$itemtable}`.`is_deleted` = '" . $p['is_deleted'] . "' ";
}
// Remove template items
if ($item && $item->maybeTemplate()) {
$LINK = " AND ";
if ($first) {
$LINK = " ";
$first = false;
}
$COMMONWHERE .= $LINK . "`{$itemtable}`.`is_template` = '0' ";
}
示例2: constructSQL
//.........这里部分代码省略.........
// 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()) {
$LINK = " AND ";
if ($first) {
$LINK = " ";
$first = false;
}
$COMMONWHERE .= $LINK . "`{$itemtable}`.`is_deleted` = '" . $p['is_deleted'] . "' ";
}
// Remove template items
if ($item && $item->maybeTemplate()) {
$LINK = " AND ";
if ($first) {
$LINK = " ";
$first = false;
}
$COMMONWHERE .= $LINK . "`{$itemtable}`.`is_template` = '0' ";
}
示例3: showMinimalList
//.........这里部分代码省略.........
// 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
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) {
示例4: showMinimalList
//.........这里部分代码省略.........
// 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("User");
// Add select for all toview item
foreach ($toview as $key => $val) {
$query .= self::addSelect("PluginResourcesDirectory", $val, $key, 0);
}
$query .= "`glpi_plugin_resources_resources`.`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("PluginResourcesDirectory", $itemtable, $already_link_tables);
$query .= $COMMONLEFTJOIN;
$searchopt = array();
$searchopt["PluginResourcesDirectory"] =& Search::getOptions("PluginResourcesDirectory");
// Add all table for toview items
foreach ($toview as $key => $val) {
$query .= Search::addLeftJoin($itemtype, $itemtable, $already_link_tables, $searchopt["PluginResourcesDirectory"][$val]["table"], $searchopt["PluginResourcesDirectory"][$val]["linkfield"], 0, 0, $searchopt["PluginResourcesDirectory"][$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["PluginResourcesDirectory"][$key]["table"], $searchopt["PluginResourcesDirectory"][$key]["linkfield"], 0, 0, $searchopt["PluginResourcesDirectory"][$key]["joinparams"]);
}
}
}
$ASSIGN = " `glpi_plugin_resources_resources`.`is_leaving` = 0 AND `glpi_users`.`is_active` = 1 AND ";
//// 3 - WHERE
// default string
$COMMONWHERE = Search::addDefaultWhere($itemtype);
$first = empty($COMMONWHERE);
// Add deleted if item have it
if ($PluginResourcesResource && $PluginResourcesResource->maybeDeleted()) {
$LINK = " AND ";
if ($first) {
$LINK = " ";
$first = false;
}
$COMMONWHERE .= $LINK . "`glpi_plugin_resources_resources`.`is_deleted` = '" . $p['is_deleted'] . "' ";
}
// Remove template items
if ($PluginResourcesResource && $PluginResourcesResource->maybeTemplate()) {
$LINK = " AND ";
if ($first) {
$LINK = " ";
$first = false;
}
$COMMONWHERE .= $LINK . "`glpi_plugin_resources_resources`.`is_template` = '0' ";
示例5: plugin_connections_addLeftJoin
function plugin_connections_addLeftJoin($type, $ref_table, $new_table, $linkfield, &$already_link_tables)
{
switch ($new_table) {
case "glpi_plugin_connections_connections_items":
return " LEFT JOIN `{$new_table}` ON (`{$ref_table}`.`id` = `{$new_table}`.`plugin_connections_connections_id`) ";
break;
case "glpi_plugin_connections_connections":
$out = " LEFT JOIN `glpi_plugin_connections_connections_items` ON (`{$ref_table}`.`id` = `glpi_plugin_connections_connections_items`.`items_id` AND `glpi_plugin_connections_connections_items`.`itemtype` = '{$type}') ";
$out .= " LEFT JOIN `glpi_plugin_connections_connections` ON (`glpi_plugin_connections_connections`.`id` = `glpi_plugin_connections_connections_items`.`plugin_connections_connections_id`) ";
return $out;
break;
case "glpi_plugin_connections_connectiontypes":
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_connections_connections", $linkfield);
$out .= " LEFT JOIN `glpi_plugin_connections_connectiontypes` ON (`glpi_plugin_connections_connectiontypes`.`id` = `glpi_plugin_connections_connections`.`plugin_connections_connectiontypes_id`) ";
return $out;
case "glpi_plugin_connections_connectionrates":
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_connections_connections", $linkfield);
$out .= " LEFT JOIN `glpi_plugin_connections_connectionrates` ON (`glpi_plugin_connections_connectionrates`.`id` = `glpi_plugin_connections_connections`.`plugin_connections_connectionrates_id`) ";
return $out;
case "glpi_plugin_connections_guaranteedconnectionrates":
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_connections_connections", $linkfield);
$out .= " LEFT JOIN `glpi_plugin_connections_guaranteedconnectionrates` ON (`glpi_plugin_connections_guaranteedconnectionrates`.`id` = `glpi_plugin_connections_connections`.`plugin_connections_guaranteedconnectionrates_id`) ";
return $out;
}
return "";
}
示例6: plugin_example_addDefaultJoin
function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables)
{
// Example of default JOIN clause
// No need of the function if you do not have specific cases
switch ($type) {
// case "PluginExampleExample" :
case "MyType":
return Search::addLeftJoin($type, $ref_table, $already_link_tables, "newtable", "linkfield");
}
return "";
}
示例7: plugin_racks_addLeftJoin
function plugin_racks_addLeftJoin($type, $ref_table, $new_table, $linkfield, &$already_link_tables)
{
switch ($new_table) {
case "glpi_plugin_racks_racks_items":
return " LEFT JOIN `glpi_plugin_racks_racks_items` \r\n ON (`{$ref_table}`.`id` = `glpi_plugin_racks_racks_items`.`items_id`\r\n AND `glpi_plugin_racks_racks_items`.`itemtype`= '" . $type . "Model') ";
break;
case "glpi_plugin_racks_racks":
// From items
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_racks_racks_items", "plugin_racks_racks_id");
$out .= " LEFT JOIN `glpi_plugin_racks_racks`\r\n ON (`glpi_plugin_racks_racks`.`id` = `glpi_plugin_racks_racks_items`.`plugin_racks_racks_id`) ";
return $out;
break;
}
return "";
}
示例8: plugin_resources_addLeftJoin
function plugin_resources_addLeftJoin($type, $ref_table, $new_table, $linkfield, &$already_link_tables)
{
// Rename table for meta left join
$AS = "";
$AS_device = "";
$nt = "glpi_plugin_resources_resources";
$nt_device = "glpi_plugin_resources_resources_items";
// Multiple link possibilies case
if ($new_table == "glpi_plugin_resources_locations" || $new_table == "glpi_plugin_resources_managers" || $new_table == "glpi_plugin_resources_recipients" || $new_table == "glpi_plugin_resources_recipients_leaving") {
$AS = " AS glpi_plugin_resources_resources_" . $linkfield;
$AS_device = " AS glpi_plugin_resources_resources_items_" . $linkfield;
$nt .= "_" . $linkfield;
$nt_device .= "_" . $linkfield;
}
switch ($new_table) {
case "glpi_plugin_resources_resources_items":
return " LEFT JOIN `glpi_plugin_resources_resources_items` ON (`{$ref_table}`.`id` = `glpi_plugin_resources_resources_items`.`items_id` AND `glpi_plugin_resources_resources_items`.`itemtype`= '{$type}') ";
break;
case "glpi_plugin_resources_taskplannings":
return " LEFT JOIN `glpi_plugin_resources_taskplannings` ON (`glpi_plugin_resources_taskplannings`.`plugin_resources_tasks_id` = `{$ref_table}`.`id`) ";
break;
case "glpi_plugin_resources_tasks_items":
return " LEFT JOIN `glpi_plugin_resources_tasks_items` ON (`{$ref_table}`.`id` = `glpi_plugin_resources_tasks_items`.`items_id` AND `glpi_plugin_resources_tasks_items`.`itemtype`= '{$type}') ";
break;
case "glpi_plugin_resources_resources":
// From items
$out = " ";
if ($type != "PluginResourcesDirectory" && $type != "PluginResourcesRecap") {
if ($ref_table != 'glpi_plugin_resources_tasks' && $ref_table != 'glpi_plugin_resources_resourcerestings' && $ref_table != 'glpi_plugin_resources_resourceholidays' && $ref_table != 'glpi_plugin_resources_employments') {
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_resources_resources_items", "plugin_resources_resources_id");
$out .= " LEFT JOIN `glpi_plugin_resources_resources` ON (`glpi_plugin_resources_resources`.`id` = `glpi_plugin_resources_resources_items`.`plugin_resources_resources_id` AND `glpi_plugin_resources_resources_items`.`itemtype` = '{$type}') ";
} else {
$out = " LEFT JOIN `glpi_plugin_resources_resources` ON (`{$ref_table}`.`plugin_resources_resources_id` = `glpi_plugin_resources_resources`.`id`) ";
}
}
return $out;
break;
case "glpi_plugin_resources_contracttypes":
// From items
if ($type != "PluginResourcesDirectory" && $type != "PluginResourcesRecap") {
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_resources_resources", "plugin_resources_resources_id");
$out .= " LEFT JOIN `glpi_plugin_resources_contracttypes` ON (`glpi_plugin_resources_resources`.`plugin_resources_contracttypes_id` = `glpi_plugin_resources_contracttypes`.`id`) ";
} else {
$out = " LEFT JOIN `glpi_plugin_resources_contracttypes` ON (`glpi_plugin_resources_resources`.`plugin_resources_contracttypes_id` = `glpi_plugin_resources_contracttypes`.`id`) ";
}
return $out;
break;
case "glpi_plugin_resources_managers":
// From items
$out = " LEFT JOIN `glpi_plugin_resources_resources_items` {$AS_device} ON (`{$ref_table}`.`id` = `{$nt_device}`.`items_id`) ";
$out .= " LEFT JOIN `glpi_plugin_resources_resources` {$AS} ON (`{$nt}`.`id` = `{$nt_device}`.`plugin_resources_resources_id` AND `{$nt_device}`.`itemtype` = '{$type}') ";
if ($type == "PluginResourcesDirectory") {
$out .= " LEFT JOIN `glpi_users` AS `glpi_plugin_resources_managers` ON (`glpi_plugin_resources_resources`.`users_id` = `glpi_plugin_resources_managers`.`id`) ";
} else {
$out .= " LEFT JOIN `glpi_users` AS `glpi_plugin_resources_managers` ON (`{$nt}`.`users_id` = `glpi_plugin_resources_managers`.`id`) ";
}
return $out;
break;
case "glpi_plugin_resources_recipients":
// From items
$out = " LEFT JOIN `glpi_plugin_resources_resources_items` {$AS_device} ON (`{$ref_table}`.`id` = `{$nt_device}`.`items_id`) ";
$out .= " LEFT JOIN `glpi_plugin_resources_resources` {$AS} ON (`{$nt}`.`id` = `{$nt_device}`.`plugin_resources_resources_id` AND `{$nt_device}`.`itemtype` = '{$type}') ";
$out .= " LEFT JOIN `glpi_users` AS glpi_plugin_resources_recipients ON (`{$nt}`.`users_id_recipient` = `glpi_plugin_resources_recipients`.`id`) ";
return $out;
break;
case "glpi_plugin_resources_recipients_leaving":
// From items
$out = " LEFT JOIN `glpi_plugin_resources_resources_items` {$AS_device} ON (`{$ref_table}`.`id` = `{$nt_device}`.`items_id`) ";
$out .= " LEFT JOIN `glpi_plugin_resources_resources` {$AS} ON (`{$nt}`.`id` = `{$nt_device}`.`plugin_resources_resources_id` AND `{$nt_device}`.`itemtype` = '{$type}') ";
$out .= " LEFT JOIN `glpi_users` AS glpi_plugin_resources_recipients_leaving ON (`{$nt}`.`users_id_recipient_leaving` = `glpi_plugin_resources_recipients_leaving`.`id`) ";
return $out;
break;
case "glpi_plugin_resources_locations":
// From items
$out = " LEFT JOIN `glpi_plugin_resources_resources_items` {$AS_device} ON (`{$ref_table}`.`id` = `{$nt_device}`.`items_id`) ";
$out .= " LEFT JOIN `glpi_plugin_resources_resources` {$AS} ON (`{$nt}`.`id` = `{$nt_device}`.`plugin_resources_resources_id` AND `{$nt_device}`.`itemtype` = '{$type}') ";
$out .= " LEFT JOIN `glpi_locations` AS glpi_plugin_resources_locations ON (`{$nt}`.`locations_id` = `glpi_plugin_resources_locations`.`id`) ";
return $out;
break;
case "glpi_plugin_resources_departments":
// From items
if ($type != "PluginResourcesDirectory" && $type != "PluginResourcesRecap") {
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_resources_resources", "plugin_resources_resources_id");
$out .= " LEFT JOIN `glpi_plugin_resources_departments` ON (`glpi_plugin_resources_resources`.`plugin_resources_departments_id` = `glpi_plugin_resources_departments`.`id`) ";
} else {
$out = " LEFT JOIN `glpi_plugin_resources_departments` ON (`glpi_plugin_resources_resources`.`plugin_resources_departments_id` = `glpi_plugin_resources_departments`.`id`) ";
}
return $out;
break;
case "glpi_plugin_resources_resourcestates":
// From items
if ($type != "PluginResourcesDirectory" && $type != "PluginResourcesRecap") {
$out = Search::addLeftJoin($type, $ref_table, $already_link_tables, "glpi_plugin_resources_resources", "plugin_resources_resources_id");
$out .= " LEFT JOIN `glpi_plugin_resources_resourcestates` ON (`glpi_plugin_resources_resources`.`plugin_resources_resourcestates_id` = `glpi_plugin_resources_resourcestates`.`id`) ";
} else {
$out = " LEFT JOIN `glpi_plugin_resources_resourcestates` ON (`glpi_plugin_resources_resources`.`plugin_resources_resourcestates_id` = `glpi_plugin_resources_resourcestates`.`id`) ";
}
return $out;
break;
case "glpi_plugin_resources_employees":
//.........这里部分代码省略.........