Example #1
0
 public function get_host($pid)
 {
     $pid = intval($pid);
     $hosts = Model_Host::data_access()->filter(Model_Host::PID, $pid)->find();
     return $hosts;
 }
Example #2
0
 public function get_all_list($name_prefix)
 {
     $da = Model_Project::data_access()->filter(Model_Project::IS_REMOVED, 0);
     if (!empty($name_prefix)) {
         $da->filter(Model_Project::NAME_PREFIX, $name_prefix);
     }
     $list = $da->sort(Model_Project::ID)->find();
     if (empty($list)) {
         return array();
     }
     $pids = array();
     foreach ($list as $r) {
         $pids[] = $r->id;
     }
     $hosts = Model_Host::data_access()->filter_by_op(Model_Host::PID, 'in', $pids)->find();
     $kv_hosts = array();
     foreach ($hosts as $v) {
         $kv_hosts[$v->pid][] = $v->hostname;
     }
     foreach ($list as $k => $r) {
         if (array_key_exists($r->id, $kv_hosts)) {
             $list[$k]->hosts = $kv_hosts[$r->id];
         } else {
             $list[$k]->hosts = array();
         }
     }
     //$kv_exclude = Biz_Exclude::get_instance()->get_exclude_by_pids($pids);
     //foreach($list as $k => $r){
     //    if(array_key_exists($r->id,$kv_exclude) ){
     //        $list[$k]->excludes = $kv_exclude[$r->id];
     //    }else{
     //        $list[$k]->excludes  = array();
     //    }
     //}
     return $list;
 }