ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 27 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 115 of file class.ilXMLResultSet.php.

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

Referenced by setArray().

115  : void
116  {
117  if ($overwrite) {
118  $this->clear();
119  }
120  foreach ($array as $row) {
121  if ($overwrite) {
122  // add column names from first row
123  $columnNames = array_keys($row);
124  foreach ($columnNames as $columnName) {
125  $this->addColumn($columnName);
126  }
127  $overwrite = false;
128  }
129  $xmlRow = new ilXMLResultSetRow();
130  $xmlRow->setValues($row);
131  $this->addRow($xmlRow);
132  }
133  }
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 43 of file class.ilXMLResultSet.php.

Referenced by addArray().

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

◆ addRow()

ilXMLResultSet::addRow ( ilXMLResultSetRow  $row)

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

Referenced by addArray().

89  : void
90  {
91  $this->rows[] = $row;
92  }
+ Here is the caller graph for this function:

◆ clear()

ilXMLResultSet::clear ( )

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

Referenced by addArray().

135  : void
136  {
137  $this->rows = array();
138  $this->colspecs = array();
139  }
+ Here is the caller graph for this function:

◆ getColSpecs()

ilXMLResultSet::getColSpecs ( )

return array of ilXMLResultSetColumn

Returns
ilXMLResultSetColumn[]

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

References $colspecs.

75  : array
76  {
77  return $this->colspecs;
78  }

◆ getColumnCount()

ilXMLResultSet::getColumnCount ( )

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

141  : int
142  {
143  return count($this->colspecs);
144  }

◆ getColumnName()

ilXMLResultSet::getColumnName ( int  $index)

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

References ilXMLResultSetColumn\getName(), and null.

32  : ?string
33  {
34  if ($index < 0 || $index > count($this->colspecs)) {
35  return null;
36  }
37  return $this->colspecs[$index] instanceof ilXMLResultSetColumn ? $this->colspecs[$index]->getName() : null;
38  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 51 of file class.ilXMLResultSet.php.

Referenced by getValue(), and hasColumn().

51  : int
52  {
53  $idx = 0;
54  foreach ($this->colspecs as $colspec) {
55  if (strcasecmp($columnname, $colspec->getName()) === 0) {
56  return $idx;
57  }
58  $idx++;
59  }
60  return -1;
61  }
+ Here is the caller graph for this function:

◆ getRow()

ilXMLResultSet::getRow (   $idx)

return row for index idx

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

References getRowCount().

Referenced by getValue().

155  {
156  if ($idx < 0 || $idx >= $this->getRowCount()) {
157  throw new DomainException("Index too small or too big: " . $idx);
158  }
159  return $this->rows[$idx];
160  }
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 146 of file class.ilXMLResultSet.php.

Referenced by getRow().

146  : int
147  {
148  return count($this->rows);
149  }
+ Here is the caller graph for this function:

◆ getRows()

ilXMLResultSet::getRows ( )

return array of ilXMLResultSetRow

Returns
ilXMLResultSetRow[]

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

References $rows.

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

◆ getValue()

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

return column value at colidx and rowidx

Parameters
int$rowIdx
int | string$colIdx
Returns
string

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

References getIndexForColumn(), and getRow().

168  : string
169  {
170  $row = $this->getRow($rowIdx);
171 
172  if (!is_numeric($colIdx)) {
173  $colIdx = $this->getIndexForColumn($colIdx);
174  }
175  return $row->getValue($colIdx);
176  }
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 66 of file class.ilXMLResultSet.php.

References getIndexForColumn().

66  : bool
67  {
68  return $this->getIndexForColumn($columnname) !== -1;
69  }
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 101 of file class.ilXMLResultSet.php.

References addArray().

101  : void
102  {
103  $this->addArray($array, true);
104  }
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 29 of file class.ilXMLResultSet.php.

Referenced by getColSpecs().

◆ $rows

array ilXMLResultSet::$rows = []
private

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

Referenced by getRows().


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