Piwik\DataTable::getRowFromId PHP 메소드

getRowFromId() 공개 메소드

Returns a row by ID. The ID is either the index of the row or {@link ID_SUMMARY_ROW}.
public getRowFromId ( integer $id ) : Row | false
$id integer The row ID.
리턴 Piwik\DataTable\Row | false The Row or false if not found.
    public function getRowFromId($id)
    {
        if (!isset($this->rows[$id])) {
            if ($id == self::ID_SUMMARY_ROW && !is_null($this->summaryRow)) {
                return $this->summaryRow;
            }
            return false;
        }
        return $this->rows[$id];
    }

Usage Example

예제 #1
0
 /**
  * Another example method that returns a data table.
  * @param int    $idSite
  * @param string $period
  * @param string $date
  * @param bool|string $segment
  * @return DataTable
  */
 public function getClusterSummary($idSite, $period, $date, $cluster_id, $cluster_type = 'bundle')
 {
     $table = new DataTable();
     $params = array('idSite' => $idSite, 'period' => $period, 'date' => $date, 'segment' => 'customVariablePageName2==' . $cluster_type . 's;customVariablePageValue2=@' . $cluster_id);
     $data = \Piwik\API\Request::processRequest('API.get', $params);
     $tarray = $this->getTypes($params);
     $data->getRowFromId(0)->addColumns($tarray);
     $table->addRow($data->getRowFromId(0));
     // Get country ISO2 code
     $hr_url = 'https://www.humanitarianresponse.info/api/v1.0/' . $cluster_type . 's/' . $cluster_id;
     if ($space_raw = @file_get_contents($hr_url)) {
         $space = json_decode($space_raw);
         $table->getRowFromId(0)->addColumn('label', $space->data[0]->label);
         if (isset($space->data[0]->operation[0]->country)) {
             $iso2 = $space->data[0]->operation[0]->country->pcode;
             $cparams = $params;
             $cparams['segment'] = $params['segment'] . ';countryCode==' . $iso2;
             $cdata = \Piwik\API\Request::processRequest('API.get', $cparams);
             $cdata->getRowFromId(0)->addColumn('label', $space->data[0]->label . ' - in country');
             $ctarray = $this->getTypes($cparams);
             $cdata->getRowFromId(0)->addColumns($ctarray);
             $table->addRow($cdata->getRowFromId(0));
         }
     }
     return $table;
 }
All Usage Examples Of Piwik\DataTable::getRowFromId