menatwork/MultiColumnWizard — Issue #20: Helper Funktionen funktionieren nicht
Author: menatwork-dev
Created: 2012-01-04 15:02:54+00:00
State: open
Labels: Completed, Defect

Huhu!

Die Helper-Funktionen müssten noch angepasst werden, weil die Daten nicht gleich wie bei meinem MultiSelectWizard gespeichert werden.

Das wäre z.B. die korrekte Variante für die getByKey:

```
/**
* Static helper method to get all the data from a certain key for all the rows
* `param string
* `param string
* `return array
*/
public static function getByKey($strSerialized, $strKey)
{
$arrData = deserialize($strSerialized, true);
$arrReturnData = array();

foreach($arrData as $rowKey => $rowData)
{
$arrReturnData[] = $rowData[$strKey];
}

return $arrReturnData;
}
```

Die getFilteredByKey, habe ich nicht getestet aber ich tippe mal auf:

```
/**
* Static helper method to get all the data from a certain key for all the rows that match a certain other row key
* `param string
* `param string
* `param array
* @return array
*/
public static function getFilteredByKey($strSerialized, $strKey, $arrConditions)
{
$arrData = deserialize($strSerialized);
$intCountConditions = count($arrConditions);

$arrReturnData = array();

foreach($arrData as $rowKey => $rowData)
{
$intMeetCondition = 0;

// check data for every filter
foreach($arrConditions as $column => $value)
{
if($rowData[$column] == $value)
{
$intMeetCondition++;
}
}

// check if the value meets ALL conditions (AND condition)
if($intMeetCondition == $intCountConditions)
{
$arrReturnData[] = $rowData[$strKey];
}
}

return $arrReturnData;
}
```

*--- Originally created by Yanick Witschi on 07.09.2011 20:55.*