getSearchOptionByField() public method

Return a search option by looking for a value of a specific field and maybe a specific table
public getSearchOptionByField ( $field, $value, $table = '' ) : then
$field the field in which looking for the value (for example : table, name, etc)
$value the value to look for in the field
$table the table (default '')
return then search option array, or an empty array if not found
コード例 #1
0
 /**
  * Contruct parameters restriction for listInventoryObjects sql request
  *
  * @param $params          the input parameters
  * @param $item            CommonDBTM object
  * @param $table
  * @param $already_joined
  **/
 static function listInventoryObjectsRequestLeftJoins($params, CommonDBTM $item, $table, $already_joined)
 {
     $join = "";
     $already_joined = array();
     foreach ($params as $key => $value) {
         //Key representing the FK associated with the _name value
         $key_transformed = preg_replace("/_name/", "s_id", $key);
         $option = $item->getSearchOptionByField('field', $key_transformed);
         if (!empty($option) && !isset($option['common']) && $table != $option['table'] && !in_array($option['table'], $already_joined)) {
             $join .= " \nINNER JOIN `" . Toolbox::addslashes_deep($option['table']) . "`\n                           ON (`" . Toolbox::addslashes_deep($table) . "`.`" . Toolbox::addslashes_deep($option['linkfield']) . "`\n                                 = `" . Toolbox::addslashes_deep($option['table']) . "`.`id`) ";
             $already_joined[] = $option['table'];
         }
     }
     return $join;
 }