public static function toHStore($array)
    {
        $hstore = [];

        if (empty($array)
            || !is_array($array)
        ) {
            return "''";
        }

        foreach ($array as $paramID => $paramValue) {
            if (is_array($paramValue)) {
                $hstore[] = sprintf(
                    "hstore('%s', %s)",
                    self::quote($paramID),
                    '(' . self::toHStore($paramValue) . ')::text'
                ) . PHP_EOL;
            } else {
                $hstore[] = sprintf(
                    "hstore('%s', '%s')",
                    self::quote($paramID),
                    self::quote($paramValue)
                );
            }
        }

        return implode(' || ', $hstore);
    }