Reformat rowset into a usable array.
@param Garp_Db_Table_Rowset $data
@return Array
496557
protected function _reformatData(Garp_Db_Table_Rowset $data) {
        $out = array();
        foreach ($data as $datum) {
            $out[$datum->identifier] = $datum->text;
        }
        return $out;
    }
112742
public function formatInput($data)
    {
        if ($data) {
            if (is_numeric(key($data))) {
                foreach ($data as $k => $v){
                    if (is_numeric($k) && is_array($v)) {
                        $data[$k] = static::formatInputRecord($v);
                    }
                }
            } else {
                $data = static::formatInputRecord($data);
            }
        }
        return $data;
    }
1028049
private function prepareContent($data)
    {
        $content = '';

        foreach ($data as $row) {
            $content .= $this->convertToJson($row) . static::ROW_DELIMITER;
        }

        return $content;
    }
1258794
public function redislizeArray(array $data)
    {
        $result = [];
        foreach ($data as $key => $value) {
            if (!is_array($value)) {
                $result[$key] = $this->redislize($value);
            }
        }

        return $result;
    }
151275
public function toArray($var = null, $key = null, $rows = [], $cb = null) {
        if (!$this->performed) {
            $this->select();
        }
        $rows = is_array($rows) ? $rows : [];
        if (is_array($var)) {
            $rows = $var;
            $var  = null;
        }
        if ($var == null && $key == null) {
            if ($rows) {
                foreach ($rows as $row) {
                    if (is_array($row)) {
                        array_unshift($this->resultSets, $row);
                    }
                }
            }

            return $this->resultSets;
        } else if ($var != null) {
            if ($cb instanceof \Closure) {
                foreach ($this->resultSets as $row) {
                    $value = $row [ $var ];
                    if ($key != null && isset ($row [ $key ])) {
                        $id           = $row [ $key ];
                        $rows [ $id ] = $cb($value, $id);
                    } else {
                        $rows [] = $cb($value);
                    }
                }
            } else {
                foreach ($this->resultSets as $row) {
                    $value = $row [ $var ];
                    if ($key != null && isset ($row [ $key ])) {
                        $id           = $row [ $key ];
                        $rows [ $id ] = $value;
                    } else {
                        $rows [] = $value;
                    }
                }
            }

            return $rows;
        } else if ($key != null) {
            if ($cb instanceof \Closure) {
                foreach ($this->resultSets as $row) {
                    $id           = $row [ $key ];
                    $rows [ $id ] = $cb($row);
                }
            } else {
                foreach ($this->resultSets as $row) {
                    $id           = $row [ $key ];
                    $rows [ $id ] = $row;
                }
            }

            return $rows;
        }

        return [];
    }
214163
protected function formatData($data)
    {
        $return = [];
        foreach ($data as $key => $item) {
            if (is_scalar($item)) {
                $value = $item;
                $color = $this->defaultColor;
            } elseif (is_array($item) && !empty($item)) {
                if (isset($item['value'])) {
                    $value = strval($item['value']);
                    $color = empty($item['color']) ? $this->defaultColor : strval($item['color']);
                } elseif (count($item) < 2) {
                    $value = array_shift($item);
                    $color = $this->defaultColor;
                } else {
                    list($value, $color) = $item;
                }
            } else {
                $value = 'error data item.';
                $color = $this->defaultColor;
            }
            $return[$key] = [
                'value' => $value,
                'color' => $color,
            ];
        }
        return $return;
    }
932260
public function updateRows(array $rows): array
    {
        if (null === $this->data) {
            $this->buildIndex();
        }

        $list = [];
        foreach ($rows as $key => $row) {
            $key = (string)$key;
            if ($this->hasKey($key)) {
                $this->data[$key] = $list[$key] = $row;
            }
        }

        if ($list) {
            $this->save();
        }

        return $list;
    }
792403
public function format($data)
    {
        $data->loopThrough(function ($key, $value) use ($data) {
            if (!in_array($key, $this->fields)) {
                $data->setProperty($key, null);
            }
        });

        $data->unsetNull();

        return $data;
    }
8786
public function insert(array $data) : array
    {
        $table = $this->definition->getName();
        $columns = $this->definition->getFullColumns();
        $insert = [];
        foreach ($data as $column => $value) {
            if (isset($columns[$column])) {
                $insert[$column] = $this->normalizeValue($columns[$column], $value);
            }
        }
        if (!count($insert)) {
            throw new DBException('No valid columns to insert');
        }
        $sql = 'INSERT INTO '.$table.' ('.implode(', ', array_keys($insert)).') VALUES (??)';
        $par = [$insert];
        $primary = $this->definition->getPrimaryKey();
        if (!count($primary)) {
            $this->db->query($sql, $par);
            return [];
        }
        if ($this->db->driverName() === 'oracle') {
            $ret = [];
            foreach ($primary as $k) {
                $ret[$k] = str_repeat(' ', 255);
                $par[] = &$ret[$k];
            }
            $sql .= ' RETURNING ' . implode(',', $primary) . ' INTO ' . implode(',', array_fill(0, count($primary), '?'));
            $this->db->query($sql, $par);
            return $ret;
        } else {
            $ret = [];
            $ins = $this->db->query($sql, $par)->insertID();
            foreach ($primary as $k) {
                $ret[$k] = $data[$k] ?? $ins;
            }
            return $ret;
        }
    }
1180040
public function fromDbTableRows(Collection $data)
    {
        $iterator = new \ArrayIterator();
        foreach ($data as $item) {
            $iterator->append($this->fromDbTableRow($item));
        }

        return $iterator;
    }
777918
private function dataToJson($data)
        {
            $cols = $this->getColumns($data);

            $rows = [];

            foreach ($data as $key => $row) {
                if ($key != 0 || !$this->_skipFirstRow) {
                    $c = [];

                    foreach ($row as $v) {
                        $c[] = ['v' => $v];
                    }

                    $rows[] = ['c' => $c];
                }
            }

            return json_encode(['cols' => $cols, 'rows' => $rows]);
        }
461312
public static function filterStripDbRowData(array $rowData, $dbTableAlias, $skipStrip = false)
    {
        $columnPrefix = $dbTableAlias . '_';

        $filteredAndStrippedRowData = [];
        foreach ($rowData as $key => $val) {
            if (strpos($key, $columnPrefix) === 0) {
                $strippedKey = $skipStrip ? $key : Str::stripLeft($key, $columnPrefix);
                $filteredAndStrippedRowData[$strippedKey] = $val;
            }
        }

        return $filteredAndStrippedRowData;
    }
1131771
public function replaceRows(array $rows): array
    {
        if (null === $this->data) {
            $this->buildIndex();
        }

        $list = [];
        foreach ($rows as $key => $row) {
            if (strpos($key, '@@')) {
                $key = $this->getNewKey();
            }
            $this->data[$key] = $list[$key] = $row;
        }

        if ($list) {
            $this->save();
        }

        return $list;
    }
122457
protected function _prepareRowForDb(array $rowData)
    {
        $rowData = parent::_prepareRowForDb($rowData);
        if (Import::BEHAVIOR_DELETE == $this->getBehavior()) {
            return $rowData;
        }

        if (self::SCOPE_DEFAULT == $this->getRowScope($rowData)) {
            $rowData[CategoryModel::KEY_NAME] = $this->getCategoryName($rowData);

            if (!isset($rowData[CategoryModel::KEY_POSITION])) {
                // diglin - prevent warning message
                $rowData[CategoryModel::KEY_POSITION] = 10000;
            }
        }

        return $rowData;
    }
1105283
protected function rename(array $data): array
    {
        $result = [];
        foreach ($data as $dataItem) {
            list($keyId, $dataTmp) = $this->getKeyValue($dataItem);

            if ($keyId === null) {
                $result[] = $dataTmp;
            } else {
                $result[$keyId] = $dataTmp;
            }
        }

        return $result;
    }
635003
protected function toArrayRecursive($data)
    {

        if ($data instanceof RecordFieldValue) {
            return $data->toArrayRecursive($data);
        } else {
            return parent::toArrayRecursive($data);
        }
    }
933834
public function format(Garp_Model $model, array $rowset) {
        $out = '';
        foreach ($rowset as $i => $row) {
            $out .= $this->_formatRow($row);
            if ($i < (count($rowset)-1)) {
                $out .= "\n\n";
            }
        }
        return $out;
    }