From 83bfb8d32d31dad2ce6278042b994a140e763f3e Mon Sep 17 00:00:00 2001 From: abijah Date: Tue, 2 Mar 2010 03:10:54 +0000 Subject: [PATCH] As the database has grown, the statement entry page query has finally ground to a halt. The query was kludged as simple as possible, and it now operates much quicker. A cleaner solution would be nice... git-svn-id: file:///svn-source/pmgr/branches/v0.2.0_work@936 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/controllers/statement_entries_controller.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/site/controllers/statement_entries_controller.php b/site/controllers/statement_entries_controller.php index c14333f..b931e75 100644 --- a/site/controllers/statement_entries_controller.php +++ b/site/controllers/statement_entries_controller.php @@ -47,7 +47,17 @@ class StatementEntriesController extends AppController { if (!empty($params['post']['custom']['statement_entry_id'])) { $link['ChargeEntry'] = array(); - $link['DisbursementEntry'] = array(); + // This query actually represents a union... + // Unpaid Charge/Surplus: ChargeID - NULL; DisbursementID - NULL + // Paid Charge/Refund: ChargeID - NULL; DisbursementID - !NULL + // Disbursement/Reversal: ChargeID - !NULL; DisbursementID - NULL + // : ChargeID - !NULL; DisbursementID - !NULL + // + // The query is really slow unless we add the `id` condition to the join. + // A cleaner query would be nice, but we must work within the Cake framework. + $link['DisbursementEntry'] = array('conditions' => + '`DisbursementEntry`.`id` = ' + . $params['post']['custom']['statement_entry_id']); } return array('link' => $link);