ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 144 of file class.ilXMLResultSet.php.

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

113 {
114 $this->rows [] = $row;
115 }

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

169 {
170 $this->rows = array();
171 $this->colspecs = array();
172 }

Referenced by addArray().

+ Here is the caller graph for this function:

◆ getColSpecs()

ilXMLResultSet::getColSpecs ( )

return array of ilXMLResultSetColumn

Returns
array

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

93 {
94 return $this->colspecs;
95 }

References $colspecs.

◆ getColumnCount()

ilXMLResultSet::getColumnCount ( )

return column count

Returns
int column count

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

179 {
180 return count($this->colspecs);
181 }

◆ getColumnName()

ilXMLResultSet::getColumnName (   $index)

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

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

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

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

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

197 {
198 if ($idx < 0 || $idx >= $this->getRowCount())
199 throw new Exception ("Index too small or too big!");
200 return $this->rows[$idx];
201 }
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 188 of file class.ilXMLResultSet.php.

188 {
189 return count($this->rows);
190 }

Referenced by getRow().

+ Here is the caller graph for this function:

◆ getRows()

ilXMLResultSet::getRows ( )

return array of ilXMLResultSetRow

Returns
array

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

103 {
104 return $this->rows;
105 }

References $rows.

◆ getValue()

ilXMLResultSet::getValue (   $rowIdx,
  $colIdx 
)

return column value at colidx and rowidx

Parameters
int$rowIdx
mixed$colIdx
Returns
string

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

210 {
211 $row = $this->getRow($rowIdx);
212
213 if (!is_numeric($colIdx))
214 $colIdx = $this->getIndexForColumn($colIdx);
215
216 return $row->getValue ($colIdx);
217 }
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 83 of file class.ilXMLResultSet.php.

83 {
84 return $this->getIndexForColumn($columnname) != -1;
85 }

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

129 {
130 $this->addArray($array, true);
131 }
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: