ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilXMLResultSet Class Reference
+ Collaboration diagram for ilXMLResultSet:

Public Member Functions

 getColumnName (int $index)
 
 addColumn (string $columnname)
 create a new column with columnname and attach it to column list More...
 
 getIndexForColumn (string $columnname)
 return index for column name More...
 
 hasColumn (string $columnname)
 has column name More...
 
 getColSpecs ()
 return array of ilXMLResultSetColumn More...
 
 getRows ()
 return array of ilXMLResultSetRow More...
 
 addRow (ilXMLResultSetRow $row)
 
 setArray (array $array)
 Clear table value and sets them based on array. More...
 
 addArray (array $array, bool $overwrite=false)
 Add table values. More...
 
 clear ()
 
 getColumnCount ()
 
 getRowCount ()
 
 getRow ($idx)
 return row for index idx More...
 
 getValue (int $rowIdx, $colIdx)
 return column value at colidx and rowidx More...
 

Private Attributes

array $colspecs = []
 
array $rows = []
 

Detailed Description

Definition at line 36 of file class.ilXMLResultSet.php.

Member Function Documentation

◆ addArray()

ilXMLResultSet::addArray ( array  $array,
bool  $overwrite = false 
)

Add table values.

Exspects a 2-dimension array. Column indeces of second dimensions in first row are column names. e.g. array (array("first" => "val1_1", "second" => "val1_2), array ("first" => "val2_1", "second" => "val2_2")) results in Table first second val1_1 va11_2 val2_1 val2_2

Parameters
array$array2 dimensional array
bool$overwriteif false, column names won't be changed, rows will be added,true: result set will be reset to null and data will be added.

Definition at line 124 of file class.ilXMLResultSet.php.

References addColumn(), addRow(), and clear().

Referenced by setArray().

124  : void
125  {
126  if ($overwrite) {
127  $this->clear();
128  }
129  foreach ($array as $row) {
130  if ($overwrite) {
131  // add column names from first row
132  $columnNames = array_keys($row);
133  foreach ($columnNames as $columnName) {
134  $this->addColumn($columnName);
135  }
136  $overwrite = false;
137  }
138  $xmlRow = new ilXMLResultSetRow();
139  $xmlRow->setValues($row);
140  $this->addRow($xmlRow);
141  }
142  }
Row Class for XMLResultSet.
addColumn(string $columnname)
create a new column with columnname and attach it to column list
addRow(ilXMLResultSetRow $row)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addColumn()

ilXMLResultSet::addColumn ( string  $columnname)

create a new column with columnname and attach it to column list

Definition at line 52 of file class.ilXMLResultSet.php.

Referenced by addArray().

52  : void
53  {
54  $this->colspecs[] = new ilXMLResultSetColumn(count($this->colspecs), $columnname);
55  }
Column Class for XMLResultSet.
+ Here is the caller graph for this function:

◆ addRow()

ilXMLResultSet::addRow ( ilXMLResultSetRow  $row)

Definition at line 98 of file class.ilXMLResultSet.php.

Referenced by addArray().

98  : void
99  {
100  $this->rows[] = $row;
101  }
+ Here is the caller graph for this function:

◆ clear()

ilXMLResultSet::clear ( )

Definition at line 144 of file class.ilXMLResultSet.php.

Referenced by addArray().

144  : void
145  {
146  $this->rows = array();
147  $this->colspecs = array();
148  }
+ Here is the caller graph for this function:

◆ getColSpecs()

ilXMLResultSet::getColSpecs ( )

return array of ilXMLResultSetColumn

Returns
ilXMLResultSetColumn[]

Definition at line 84 of file class.ilXMLResultSet.php.

References $colspecs.

84  : array
85  {
86  return $this->colspecs;
87  }

◆ getColumnCount()

ilXMLResultSet::getColumnCount ( )

Definition at line 150 of file class.ilXMLResultSet.php.

150  : int
151  {
152  return count($this->colspecs);
153  }

◆ getColumnName()

ilXMLResultSet::getColumnName ( int  $index)

Definition at line 41 of file class.ilXMLResultSet.php.

References ilXMLResultSetColumn\getName().

41  : ?string
42  {
43  if ($index < 0 || $index > count($this->colspecs)) {
44  return null;
45  }
46  return $this->colspecs[$index] instanceof ilXMLResultSetColumn ? $this->colspecs[$index]->getName() : null;
47  }
Column Class for XMLResultSet.
+ Here is the call graph for this function:

◆ getIndexForColumn()

ilXMLResultSet::getIndexForColumn ( string  $columnname)

return index for column name

Definition at line 60 of file class.ilXMLResultSet.php.

Referenced by getValue(), and hasColumn().

60  : int
61  {
62  $idx = 0;
63  foreach ($this->colspecs as $colspec) {
64  if (strcasecmp($columnname, $colspec->getName()) === 0) {
65  return $idx;
66  }
67  $idx++;
68  }
69  return -1;
70  }
+ Here is the caller graph for this function:

◆ getRow()

ilXMLResultSet::getRow (   $idx)

return row for index idx

Definition at line 163 of file class.ilXMLResultSet.php.

References getRowCount().

Referenced by getValue().

164  {
165  if ($idx < 0 || $idx >= $this->getRowCount()) {
166  throw new DomainException("Index too small or too big: " . $idx);
167  }
168  return $this->rows[$idx];
169  }
Row Class for XMLResultSet.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRowCount()

ilXMLResultSet::getRowCount ( )

Definition at line 155 of file class.ilXMLResultSet.php.

Referenced by getRow().

155  : int
156  {
157  return count($this->rows);
158  }
+ Here is the caller graph for this function:

◆ getRows()

ilXMLResultSet::getRows ( )

return array of ilXMLResultSetRow

Returns
ilXMLResultSetRow[]

Definition at line 93 of file class.ilXMLResultSet.php.

References $rows.

93  : array
94  {
95  return $this->rows;
96  }

◆ getValue()

ilXMLResultSet::getValue ( int  $rowIdx,
  $colIdx 
)

return column value at colidx and rowidx

Parameters
int$rowIdx
int | string$colIdx
Returns
string

Definition at line 177 of file class.ilXMLResultSet.php.

References getIndexForColumn(), and getRow().

177  : string
178  {
179  $row = $this->getRow($rowIdx);
180 
181  if (!is_numeric($colIdx)) {
182  $colIdx = $this->getIndexForColumn($colIdx);
183  }
184  return $row->getValue($colIdx);
185  }
getRow($idx)
return row for index idx
getIndexForColumn(string $columnname)
return index for column name
+ Here is the call graph for this function:

◆ hasColumn()

ilXMLResultSet::hasColumn ( string  $columnname)

has column name

Definition at line 75 of file class.ilXMLResultSet.php.

References getIndexForColumn().

75  : bool
76  {
77  return $this->getIndexForColumn($columnname) !== -1;
78  }
getIndexForColumn(string $columnname)
return index for column name
+ Here is the call graph for this function:

◆ setArray()

ilXMLResultSet::setArray ( array  $array)

Clear table value and sets them based on array.

Exspects a 2-dimension array. Column indeces of second dimensions in first row are column names. e.g. array (array("first" => "val1_1", "second" => "val1_2), array ("first" => "val2_1", "second" => "val2_2")) results in Table first second val1_1 va11_2 val2_1 val2_2

Definition at line 110 of file class.ilXMLResultSet.php.

References addArray().

110  : void
111  {
112  $this->addArray($array, true);
113  }
addArray(array $array, bool $overwrite=false)
Add table values.
+ Here is the call graph for this function:

Field Documentation

◆ $colspecs

array ilXMLResultSet::$colspecs = []
private

Definition at line 38 of file class.ilXMLResultSet.php.

Referenced by getColSpecs().

◆ $rows

array ilXMLResultSet::$rows = []
private

Definition at line 39 of file class.ilXMLResultSet.php.

Referenced by getRows().


The documentation for this class was generated from the following file: