Forums: Dynamically Add Group By and/or HAVING clause to before sql query - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Dynamically Add Group By and/or HAVING clause to before sql query

#1 User is offline   FunkDaddy 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 167
  • Joined: 17-March 10

Posted 28 November 2016 - 08:07 PM

Need to add the "GROUP BY" dd/or "HAVING" clause to a query dynamically?

Simply access the $pageObject in the before SQL query event and modify those arguments as follows:

$pageObject->gsqlGroupBy = " GROUP BY ProductID "; //Here we explicitly use the word GROUP BY
$pageObject->gsqlHaving = " FIND_IN_SET('" . $_GET['cat']. "', ProductID)";//Notice here we don't actually include word "HAVING"... we include only the statement that would come after it.



You could of course just alter the $strOrderBy variable available to you in list page events, however, if you include your GROUP BY or HAVING clauses in there, then columns will not sort correctly when you click on their headers. Hence to take advantage of the built in column sorts offered by phpr, use the pageObject to alter group by and having.

Cheers,

Marcelo
Marcelo Ramagem

- Don't second guess your customer, instead listen, iterate, and deliver!
0

#2 User is offline   jomppa10 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 45
  • Joined: 12-February 07

Posted 12 September 2017 - 07:54 AM

Hi,


gsqlHaving or gsqlGroupBy are not valid in PHPRunner 9.8 anymore. When adding group by to $strOrderBy causes paging, sorting etc. stop working correctly. Does anyone know how to use dynamically group by in before sql query or after table initialized?


regards
Jouni
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic