UID of the given warehouse * @id_machine_cluster UID of the given machine_cluster * * @return etrees The list of etrees * FALSE on error * =========================================================*/ public static function getForMachineCluster($id_warehouse, $id_machine_cluster){ /* (1) On récupère le ETREE de la machine ---------------------------------------------------------*/ $module = Table::get('module') ->select('id_module') ->select('name'); $etree = Table::get('etree') ->select('id_etree') ->select('daemon') ->join('id_module', $module); $merge = Table::get('module_merge') ->join('id_etree', $etree) ->whereIdWarehouse($id_warehouse) ->whereIdMachineCluster($id_machine_cluster); return $merge->fetch(); } /* [2] Parses an e-tree full name (mod_name-etree_name) * * @full_name Full name to parse * * @return info The useful data (id_module, id_etree) * FALSE on error * =========================================================*/ public static function parse($full_name){ /* (1) On vérifie le format (permet l'extraction des données) */ if( !preg_match('@^(.+)-(.+)$@', $full_name, $matches) ) return false; /* (2) On recherche le module */ $module = Table::get('module') ->select('id_module') ->select('name') ->unique() ->whereName($matches[1]) ->fetch(); /* (3) Si on ne trouve pas de module -> error */ if( !is_array($module) || !isset($module['id_module']) ) return false; /* (5) On cherche l'e-tree */ $etree = Table::get('etree') ->select('id_etree') ->select('daemon') ->whereIdModule($module['id_module']) ->whereDaemon($matches[2]) ->unique() ->fetch(); /* (6) Si erreur */ if( !is_array($etree) || !isset($etree['id_etree']) ) return false; /* (7) Si tout ok, on retourne les données */ return [ 'id_module' => $module['id_module'], 'module_name' => $module['name'], 'id_etree' => $etree['id_etree'], 'etree_name' => $etree['daemon'] ]; } } ?>