How to sort a query object in ColdFusion 7?

I have a query object, with, say, fifteen lines. In all senses and purposes, I cannot change the SQL that the query object generates, but I need to sort this query object by column. Is there a way to do this in ColdFusion 7 without resorting to an external library?

Edit: I have to add: I ran the request in this request object and made a proposal ORDER BYin this request request. Is there any other way to do this?

+3
source share
3 answers

No, requesting a request is how you do it. There are other ways you could secure data, but they are all kludgey and will not be as direct as QoQ.

One of the capabilities of QoQ (the so-called in-memory queries) is that it can be used for a query returned by any tag that returns a query object, such as CFDIRECTORY and CFPOP.

For people interested in how to execute a Query query, this is simple:

<cfquery name="resortQuery" dbtype="query">
    SELECT *
    FROM myQueryFromSomewhereElse
    WHERE
        COLUMN_NAME=<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#myFilterValue#" />
    ORDER BY
        SOME_OTHER_COLUMN_NAME ASC
</cfquery>
+12
source

Even when this issue has already been resolved, I want to add that you can also use the basic Java method sort (), which just needs a single line, and you do not need to add UDF for this. Then the code will look like this:

<cfset qQuery.sort(qQuery.findColumn("nameOfSortColumn"), TRUE)>

findColumn() , sort() , . : TRUE = , FALSE = .

: , QoQ

:

Java-. . :

Lucee ( 4.5 5.2) :

<cfset qQuery.sort("nameOfSortColumn", "asc")>

, ...

+12

, URL

http://www.coldfusioncookbook.com/entries/How-do-I-resort-a-query.html

<cfquery name="original" datasource="foo" >
  select name, age, rank
  from people
  order by age asc
</cfquery>

<!--- Resort by name --->
<cfquery name="newQuery" dbtype="query">
  select name, age, rank
  from original
  order by name asc
</cfquery>
0

Source: https://habr.com/ru/post/1713258/


All Articles