ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
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
 getIndexForColumn ($columnname)
 return index for column name
 hasColumn ($columnname)
 has column name
 getColSpecs ()
 return array of ilXMLResultSetColumn
 getRows ()
 return array of ilXMLResultSetRow
 addRow (&$row)
 add row object
 setArray ($array)
 Clear table value and sets them based on array.
 addArray ($array, $overwrite=false)
 Add table values.
 clear ()
 Clear resultset (colspecs and row values)
 getColumnCount ()
 return column count
 getRowCount ()
 return row count
 getRow ($idx)
 return row for index idx
 getValue ($rowIdx, $colIdx)
 return column value at colidx and rowidx

Private Attributes

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

Detailed Description

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

Member Function Documentation

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.

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

Referenced by setArray().

{
if ($overwrite) {
$this->clear();
}
foreach ($array as $row) {
if ($overwrite)
{
// add column names from first row
$columnNames = array_keys($row);
foreach ($columnNames as $columnName)
{
$this->addColumn($columnName);
}
$overwrite = false;
}
$xmlRow = new ilXMLResultSetRow();
$xmlRow->setValues ($row);
$this->addRow($xmlRow);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Referenced by addArray().

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

+ Here is the caller graph for this function:

ilXMLResultSet::addRow ( $row)

add row object

Parameters
ilXMLResultSetRow$row

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

Referenced by addArray().

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

+ Here is the caller graph for this function:

ilXMLResultSet::clear ( )

Clear resultset (colspecs and row values)

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

Referenced by addArray().

{
$this->rows = array();
$this->colspecs = array();
}

+ Here is the caller graph for this function:

ilXMLResultSet::getColSpecs ( )

return array of ilXMLResultSetColumn

Returns
array

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

References $colspecs.

{
}
ilXMLResultSet::getColumnCount ( )

return column count

Returns
int column count

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

{
return count($this->colspecs);
}
ilXMLResultSet::getColumnName (   $index)

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

References ilXMLResultSetColumn\getName().

{
if (is_numeric($index) && ($index < 0 || $index > count($this->colspecs)))
{
return null;
}
return $this->colspecs[$index] instanceof ilXMLResultSetColumn ? $this->colspecs[$index]->getName() : null;
}

+ Here is the call graph for this function:

ilXMLResultSet::getIndexForColumn (   $columnname)

return index for column name

Parameters
string$columnname
Returns
int

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

Referenced by getValue(), and hasColumn().

{
$idx = 0;
foreach ($this->colspecs as $colspec) {
if (strcasecmp($columnname, $colspec->getName()) == 0)
return $idx;
$idx++;
}
return -1;
}

+ Here is the caller graph for this function:

ilXMLResultSet::getRow (   $idx)

return row for index idx

Parameters
$idxindex
Returns
ilXMLResultSetRow

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

References getRowCount().

Referenced by getValue().

{
if ($idx < 0 || $idx >= $this->getRowCount())
throw new Exception ("Index too small or too big!");
return $this->rows[$idx];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilXMLResultSet::getRowCount ( )

return row count

Returns
int row count

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

Referenced by getRow().

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

+ Here is the caller graph for this function:

ilXMLResultSet::getRows ( )

return array of ilXMLResultSetRow

Returns
array

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

References $rows.

{
return $this->rows;
}
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.

References getIndexForColumn(), and getRow().

{
$row = $this->getRow($rowIdx);
if (!is_numeric($colIdx))
$colIdx = $this->getIndexForColumn($colIdx);
return $row->getValue ($colIdx);
}

+ Here is the call graph for this function:

ilXMLResultSet::hasColumn (   $columnname)

has column name

Parameters
string$columnname
Returns
boolean

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

References getIndexForColumn().

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

+ Here is the call graph for this function:

ilXMLResultSet::ilXMLResultSet ( )

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

{
}
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.

References addArray().

{
$this->addArray($array, true);
}

+ Here is the call graph for this function:

Field Documentation

ilXMLResultSet::$colspecs = array()
private

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

Referenced by getColSpecs().

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: