Reuse Cdbcommand Created

Hi!

I want to have a product listing method in my controller that may receive 0-4 params (what i call ‘filters’).

And I want to have pagination, so I also have to make a query of ‘count(*)’.

What i really want to do is to construct the query once, checking for the existence of params and adding ‘ANDWHERE’ clauses,

and when I want to get the information, I want to reuse the query already built, and just change the ‘SELECT’ clause.

I tried to construct and execute the count(*) query, and then just do

$cmd->select(‘info_i_want_to_list’);

$dataProvider = new CSqlDataProvider( $cmd, array(

            'totalItemCount'=>$count,


            'pagination'=>array(


                'pageSize' => 24,


                )


            )


        );

But it creates the select count(*) query again…

Any thoughts?