Exemple #1
0
 public function queryStatistics($fld, $recursive = true, $get_cb = array('RODSConnManager', 'getConn'), $rel_cb = array('RODSConnManager', 'releaseConn'))
 {
     $condition = new RODSGenQueConds();
     $select = new RODSGenQueSelFlds();
     $ret_data_index = '';
     switch ($fld) {
         case 'num_dirs':
             $select->add('COL_COLL_ID', 'count');
             $ret_data_index = 'COL_COLL_ID';
             if ($recursive === true) {
                 $condition->add('COL_COLL_NAME', 'like', $this->path_str . '/%');
             } else {
                 $condition->add('COL_COLL_PARENT_NAME', '=', $this->path_str);
             }
             break;
         case 'num_files':
             $select->add('COL_D_DATA_ID', 'count');
             $ret_data_index = 'COL_D_DATA_ID';
             if ($recursive === true) {
                 $condition->add('COL_COLL_NAME', 'like', $this->path_str . '/%', array(array('op' => '=', 'val' => $this->path_str)));
             } else {
                 $condition->add('COL_COLL_NAME', '=', $this->path_str);
             }
             break;
         default:
             throw new RODSException("Query field '{$fld}' not supported!", 'PERR_USER_INPUT_ERROR');
     }
     //$conn = RODSConnManager::getConn($this->account);
     $conn = call_user_func_array($get_cb, array(&$this->account));
     $results = $conn->query($select, $condition);
     //RODSConnManager::releaseConn($conn);
     call_user_func($rel_cb, $conn);
     $result_values = $results->getValues();
     if (isset($result_values[$ret_data_index][0])) {
         return intval($result_values[$ret_data_index][0]);
     } else {
         throw new RODSException("Query did not get value back with expected " . "index: {$ret_data_index}!", 'GENERAL_PRODS_ERR');
     }
 }