public function fetchAssocList(\PDOStatement $res, $assign_by = null)
    {
        $result = array();
        try {
            while ($row = $res->fetch(\PDO::FETCH_ASSOC)) {
                if (!empty($assign_by) && !is_array($assign_by)) {
                    $result[$row[$assign_by]] = (array)$row;
                } elseif (!empty($assign_by) && is_array($assign_by)) {
                    $key = array();
                    foreach ($assign_by as $key_w) {
                        if (isset($row[$key_w])) {
                            $key[] = $row[$key_w];
                        }
                    }

                    if (empty($key)) {
                        $result[] = (object)$row;
                    } else {
                        // removes the first '- '
                        $key          = implode('-', $key);
                        $result[$key] = (object)$row;
                    }
                } else {
                    $result[] = (array)$row;
                }
            }
        } catch (DatabaseException $e) {
            throw $e;
        }

        return $result;
    }