ILIAS  release_7 Revision v7.30-3-g800a261c036
ilXMLResultSet Class Reference
+ Collaboration diagram for ilXMLResultSet:

Public Member Functions

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

Private Attributes

 $colspecs = array()
 
 $rows = array()
 

Detailed Description

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

Member Function Documentation

◆ addArray()

ilXMLResultSet::addArray (   $array,
  $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
boolean$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 147 of file class.ilXMLResultSet.php.

148 {
149 if ($overwrite) {
150 $this->clear();
151 }
152 foreach ($array as $row) {
153 if ($overwrite) {
154 // add column names from first row
155 $columnNames = array_keys($row);
156 foreach ($columnNames as $columnName) {
157 $this->addColumn($columnName);
158 }
159 $overwrite = false;
160 }
161 $xmlRow = new ilXMLResultSetRow();
162 $xmlRow->setValues($row);
163 $this->addRow($xmlRow);
164 }
165 }
addRow(&$row)
add row object
clear()
Clear resultset (colspecs and row values)
addColumn($columnname)
create a new column with columnname and attach it to column list

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

Referenced by setArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addColumn()

ilXMLResultSet::addColumn (   $columnname)

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

Parameters
String$columname

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

56 {
57 $this->colspecs [count($this->colspecs)] = new ilXMLResultSetColumn(count($this->colspecs), $columnname);
58 }

Referenced by addArray().

+ Here is the caller graph for this function:

◆ addRow()

ilXMLResultSet::addRow ( $row)

add row object

Parameters
ilXMLResultSetRow$row

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

116 {
117 $this->rows [] = $row;
118 }

Referenced by addArray().

+ Here is the caller graph for this function:

◆ clear()

ilXMLResultSet::clear ( )

Clear resultset (colspecs and row values)

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

172 {
173 $this->rows = array();
174 $this->colspecs = array();
175 }

Referenced by addArray().

+ Here is the caller graph for this function:

◆ getColSpecs()

ilXMLResultSet::getColSpecs ( )

return array of ilXMLResultSetColumn

Returns
array

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

96 {
97 return $this->colspecs;
98 }

References $colspecs.

◆ getColumnCount()

ilXMLResultSet::getColumnCount ( )

return column count

Returns
int column count

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

183 {
184 return count($this->colspecs);
185 }

◆ getColumnName()

ilXMLResultSet::getColumnName (   $index)

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

43 {
44 if (is_numeric($index) && ($index < 0 || $index > count($this->colspecs))) {
45 return null;
46 }
47 return $this->colspecs[$index] instanceof ilXMLResultSetColumn ? $this->colspecs[$index]->getName() : null;
48 }
$index
Definition: metadata.php:128

References $index, and ilXMLResultSetColumn\getName().

+ Here is the call graph for this function:

◆ getIndexForColumn()

ilXMLResultSet::getIndexForColumn (   $columnname)

return index for column name

Parameters
string$columnname
Returns
int

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

67 {
68 $idx = 0;
69 foreach ($this->colspecs as $colspec) {
70 if (strcasecmp($columnname, $colspec->getName()) == 0) {
71 return $idx;
72 }
73 $idx++;
74 }
75 return -1;
76 }

Referenced by getValue(), and hasColumn().

+ Here is the caller graph for this function:

◆ getRow()

ilXMLResultSet::getRow (   $idx)

return row for index idx

Parameters
$idxindex
Returns
ilXMLResultSetRow

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

203 {
204 if ($idx < 0 || $idx >= $this->getRowCount()) {
205 throw new Exception("Index too small or too big!");
206 }
207 return $this->rows[$idx];
208 }
getRowCount()
return row count

References getRowCount().

Referenced by getValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRowCount()

ilXMLResultSet::getRowCount ( )

return row count

Returns
int row count

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

193 {
194 return count($this->rows);
195 }

Referenced by getRow().

+ Here is the caller graph for this function:

◆ getRows()

ilXMLResultSet::getRows ( )

return array of ilXMLResultSetRow

Returns
array

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

106 {
107 return $this->rows;
108 }

References $rows.

◆ getValue()

ilXMLResultSet::getValue (   $rowIdx,
  $colIdx 
)

return column value at colidx and rowidx

Parameters
int$rowIdx
mixed$colIdx
Returns
string

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

218 {
219 $row = $this->getRow($rowIdx);
220
221 if (!is_numeric($colIdx)) {
222 $colIdx = $this->getIndexForColumn($colIdx);
223 }
224
225 return $row->getValue($colIdx);
226 }
getRow($idx)
return row for index idx
getIndexForColumn($columnname)
return index for column name

References getIndexForColumn(), and getRow().

+ Here is the call graph for this function:

◆ hasColumn()

ilXMLResultSet::hasColumn (   $columnname)

has column name

Parameters
string$columnname
Returns
boolean

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

86 {
87 return $this->getIndexForColumn($columnname) != -1;
88 }

References getIndexForColumn().

+ Here is the call graph for this function:

◆ setArray()

ilXMLResultSet::setArray (   $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

Parameters
array$array2 dimensional array

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

132 {
133 $this->addArray($array, true);
134 }
addArray($array, $overwrite=false)
Add table values.

References addArray().

+ Here is the call graph for this function:

Field Documentation

◆ $colspecs

ilXMLResultSet::$colspecs = array()
private

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

Referenced by getColSpecs().

◆ $rows

ilXMLResultSet::$rows = array()
private

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

Referenced by getRows().


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