correct location of orderBys clause

Forum for users and developers of Bullhorn's Webservices API suite

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
Alliance
User
Posts: 40
Joined: Mon Feb 18, 2013 12:16 pm

correct location of orderBys clause

Post by Alliance » Wed Apr 10, 2013 10:47 am

I have seen conflicting examples on these forums on where to use the orderBys clause. Where is the proper place to put the orderBys clause when performing a query() call?

Should it be in the query array:

Code: Select all

 $query_array = array(
            'distinct'      =>  "false",
            'entityName'    =>  $entity,
            'where'         =>  $where,
            'parameters'    =>  array(),
            'orderBys'      => $order_by,     // correct location?
);
Or, should it be in the parameters array:

Code: Select all

 $query_array = array(
            'distinct'      =>  "false",
            'entityName'    =>  $entity,
            'where'         =>  $where,
            'parameters'    =>  array(
                'orderBys'  => $order_by,   // or is this correct?
            ),
);
I was able to get "id" to work properly using the second method of putting orderBys in the parameters array. When I try to order by "title", however, the results are not ordered alphabetically. When I try to order by "dateAdded", the results return out of order based on dateAdded. When I try to order by "address.zip", results return out of order based on zip.

When I use the first method, putting orderBys in the query_array, I get errors when trying to order by "title".

Code: Select all

-99999: org.hibernate.exception.GenericJDBCException: could not execute query
The documentation for query() suggests the orderBys clause belongs in the query_array (first method). If that is correct, then why am I getting errors when I try to order by anything other than "id"?

Alliance
User
Posts: 40
Joined: Mon Feb 18, 2013 12:16 pm

Re: correct location of orderBys clause

Post by Alliance » Thu Apr 18, 2013 5:05 pm

Solved it myself.

The orderBys should be in the query_array (not in parameters), and the reason I was getting an error is because 'distinct' was set to "false" (interpreted as a string) instead of false (a boolean).

Post Reply