/** * (non-PHPdoc). * * @see Alpha\Model\ActiveRecordProviderInterface::getHistoryCount() */ public function getHistoryCount() { self::$logger->debug('>>getHistoryCount()'); if (!$this->BO->getMaintainHistory()) { throw new AlphaException('getHistoryCount method called on a DAO where no history is maintained!'); } $sqlQuery = 'SELECT COUNT(OID) AS object_count FROM ' . $this->BO->getTableName() . '_history WHERE OID=' . $this->BO->getOID(); $this->BO->setLastQuery($sqlQuery); $result = self::getConnection()->query($sqlQuery); if ($result) { $row = $result->fetch_array(MYSQLI_ASSOC); self::$logger->debug('<<getHistoryCount [' . $row['object_count'] . ']'); return $row['object_count']; } else { throw new AlphaException('Failed to get the history count for the business object [' . $this->BO->getOID() . '] from the table [' . $this->BO->getTableName() . '_history], query is [' . $this->BO->getLastQuery() . ']'); self::$logger->debug('<<getHistoryCount [0]'); return 0; } }