hiroshi
Posts: 1
|
Posted: 05/20/2004, 8:11 PM |
|
Hello,
I am using CCS Ver. 2.2.2.40 and mysql database.
I want to show a summary data of a certain transaction data table using a grid. Let's say my table name is t_sales has 3 fields : transaction_no, cust_id, and sales_amount .
My sql statement looks like below:
select cust_id, sum(sales_amount) as amount from t_sales group by cust_id .
My grid name is t_sales_grid, and I am restricting the records per page to 20.
The problem is, eventhough the result of the sql statement above is more than 20 rows, the navigator object does not behave correctly because it depends on the $this->ds->PageCount() to set the $this->Navigator->TotalPages.
$this->ds->PageCount() itself depends on $this->CountSQL that being calculated in $this->ds->open() method.
'Select count(*)' will give multiple result if 'group by' option is added, and I believe that CCS only takes the first row value as the result. Now I am doing workaround by 'wrapping' the $this->CountSQL in the grid BeforeExecuteSelect event as follows:
// -------------------------
global $t_sales_grid;
// Write your own code here.'
$t_sales_grid->ds->CountSQL = "select count(*) from (" . $t_sales_grid->ds->CountSQL . ") as tmp ";
// -------------------------
I think CCS should take care of counting the correct row when the sql statement contains group by option.
rgs,
hiroshi
|
|
|
peterr
Posts: 5971
|
Posted: 05/20/2004, 11:29 PM |
|
The CountSQL property was implemented in CCS specifically to resolve such issues. What you did looks like the correct way to set the count when CCS is unable to determine it.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
|