ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilXMLResultSet Class Reference
+ Collaboration diagram for ilXMLResultSet:

Public Member Functions

 ilXMLResultSet ()
 
 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 149 of file class.ilXMLResultSet.php.

149 {
150 if ($overwrite) {
151 $this->clear();
152 }
153 foreach ($array as $row) {
154 if ($overwrite)
155 {
156 // add column names from first row
157 $columnNames = array_keys($row);
158 foreach ($columnNames as $columnName)
159 {
160 $this->addColumn($columnName);
161 }
162 $overwrite = false;
163 }
164 $xmlRow = new ilXMLResultSetRow();
165 $xmlRow->setValues ($row);
166 $this->addRow($xmlRow);
167 }
168 }
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 $row, 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 60 of file class.ilXMLResultSet.php.

61 {
62 $this->colspecs [count($this->colspecs)] = new ilXMLResultSetColumn (count($this->colspecs), $columnname);
63 }

Referenced by addArray().

+ Here is the caller graph for this function:

◆ addRow()

ilXMLResultSet::addRow ( $row)

add row object

Parameters
ilXMLResultSetRow$row

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

118 {
119 $this->rows [] = $row;
120 }

References $row.

Referenced by addArray().

+ Here is the caller graph for this function:

◆ clear()

ilXMLResultSet::clear ( )

Clear resultset (colspecs and row values)

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

174 {
175 $this->rows = array();
176 $this->colspecs = array();
177 }

Referenced by addArray().

+ Here is the caller graph for this function:

◆ getColSpecs()

ilXMLResultSet::getColSpecs ( )

return array of ilXMLResultSetColumn

Returns
array

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

98 {
99 return $this->colspecs;
100 }

References $colspecs.

◆ getColumnCount()

ilXMLResultSet::getColumnCount ( )

return column count

Returns
int column count

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

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

◆ getColumnName()

ilXMLResultSet::getColumnName (   $index)

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

47 {
48 if (is_numeric($index) && ($index < 0 || $index > count($this->colspecs)))
49 {
50 return null;
51 }
52 return $this->colspecs[$index] instanceof ilXMLResultSetColumn ? $this->colspecs[$index]->getName() : null;
53 }

References 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 71 of file class.ilXMLResultSet.php.

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

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.

202 {
203 if ($idx < 0 || $idx >= $this->getRowCount())
204 throw new Exception ("Index too small or too big!");
205 return $this->rows[$idx];
206 }
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 193 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 107 of file class.ilXMLResultSet.php.

108 {
109 return $this->rows;
110 }

References $rows.

◆ getValue()

ilXMLResultSet::getValue (   $rowIdx,
  $colIdx 
)

return column value at colidx and rowidx

Parameters
int$rowIdx
mixed$colIdx
Returns
string

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

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

References $row, 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 88 of file class.ilXMLResultSet.php.

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

References getIndexForColumn().

+ Here is the call graph for this function:

◆ ilXMLResultSet()

ilXMLResultSet::ilXMLResultSet ( )

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

44 {
45 }

◆ 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 133 of file class.ilXMLResultSet.php.

134 {
135 $this->addArray($array, true);
136 }
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: