public function getNumberOfRecordsWithSameOrderId($orderId, $transType, $periodInHours, $parentTransId, $visitDateTime) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add("count(transid)", "count"); $select->from->add(Pap_Db_Table_Transactions::getName()); if($orderId == '') { $condition = new Gpf_SqlBuilder_CompoundWhereCondition(); $condition->add(Pap_Db_Table_Transactions::ORDER_ID, '=', '', 'OR'); $condition->add(Pap_Db_Table_Transactions::ORDER_ID, '=', null, 'OR'); $select->where->addCondition($condition); } else { $select->where->add(Pap_Db_Table_Transactions::ORDER_ID, "=", $orderId); } $select->where->add(Pap_Db_Table_Transactions::R_TYPE, "=", $transType); $select->where->add(Pap_Db_Table_Transactions::TIER, "=", "1"); $select->where->add(Pap_Db_Table_Transactions::R_STATUS, "<>", Pap_Common_Constants::STATUS_DECLINED); if($periodInHours > 0) { $dateFrom = new Gpf_DateTime($visitDateTime); $dateFrom->addHour(-1*$periodInHours); $select->where->add(Pap_Db_Table_Transactions::DATE_INSERTED, ">", $dateFrom->toDateTime()); } if($parentTransId != null && $parentTransId != '') { $select->where->add(Pap_Db_Table_Transactions::PARRENT_TRANSACTION_ID, "<>", $parentTransId); } $recordSet = new Gpf_Data_RecordSet(); $recordSet->load($select); foreach($recordSet as $record) { return $record->get("count"); } return 0; }