Yii Framework Forum: Specific Commandbuilder And Limit Function - Yii Framework Forum

Jump to content

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

Specific Commandbuilder And Limit Function Rate Topic: -----

#1 User is offline   Denis Roussel 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 28-October 11

Posted 20 November 2012 - 10:40 AM

Hi,


I want to put here my question which was already partially discussed (on my own...) on this topic.

But as it is more specific than the above topic, I created a new one here (with a more explicit title).


The aim is to implement a good 'applyLimit' function (on a new CommandBuilder for IBM DB's).

As IBM DB's don't implement an offset on limits, the trick is to use the IBM intern ROW_NUMBER() function to retrieve ... the row number as a new query field.

So, it's quite easy to filter results with a WHERE <the_row_number> BETWEEN <offset + 1> AND <limit + offset>.

But it fails when you want to order AND filter (with GridView for instance) because the ROW_NUMBER() (which is really 'ROW_NUMBER() OVER()') asks the 'ORDER BY' part as the OVER() parameter...

So the query should be builded in the applyLimit function as : 'SELECT t.*, ROW_NUMBER() OVER(ORDER BY id DESC) AS row FROM (<the sql query> ORDER BY id DESC) WHERE row BETWEEN <x> AND <y>'.

A simple query on a table without relations is ok as the 'createFindCommand' is part of the new CommandBuilder.

But when it involves relations, the applyLimit function is called from outside the CommandBuilder and it becomes less easy to build the query correctly (in the createFindCommand, we have access to the CdbCriteria object).


As I don't know the whole framework (especially the classes to build the joins), can someone help me?


Many thanks.
0

Share this topic:


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

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users