The qs() Method

Miles Rausch edited this page Feb 26, 2015 · 3 revisions

To make the management of query strings easier, we added the qs() method. This method allows us to pass in a structure of updates we need to make to our URL. The method will then normalize the order and appearance of URL keys and update or add any values that we've sent to it. Optionally, you can also pass a structure or custom query string to run the updates against if you don't want to use the CGI's query string.

Allows three arguments:

  • struct update -- the structure of query string updates you're making
  • array ignore -- the array of keys you wish to ignore when creating the query string
  • (struct or string) querySource -- the query string or structure to update against (default: cgi.query_string)

Example:

<cfscript>
    writeOutput( qs({ page = 3 }) ); // ?page=3
    url.count = 10;
    url.page = 2;
    writeOutput( qs({ page = 3 }) ); // ?count=10&amp;page=3
</cfscript>
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.