Code Duplication    Length = 41-41 lines in 2 locations

Alpha/Model/ActiveRecordProviderMySQL.php 1 location

@@ 302-342 (lines=41) @@
299
     *
300
     * @see Alpha\Model\ActiveRecordProviderInterface::loadAllOldVersions()
301
     */
302
    public function loadAllOldVersions($OID)
303
    {
304
        self::$logger->debug('>>loadAllOldVersions(OID=['.$OID.'])');
305
306
        $config = ConfigProvider::getInstance();
307
308
        if (!$this->BO->getMaintainHistory()) {
309
            throw new RecordFoundException('loadAllOldVersions method called on an active record where no history is maintained!');
310
        }
311
312
        $sqlQuery = 'SELECT version_num FROM '.$this->BO->getTableName().'_history WHERE OID = \''.$OID.'\' ORDER BY version_num;';
313
314
        $this->BO->setLastQuery($sqlQuery);
315
316
        if (!$result = self::getConnection()->query($sqlQuery)) {
317
            throw new RecordNotFoundException('Failed to load object versions, MySQL error is ['.self::getLastDatabaseError().'], query ['.$this->BO->getLastQuery().']');
318
            self::$logger->debug('<<loadAllOldVersions [0]');
319
320
            return array();
321
        }
322
323
        // now build an array of objects to be returned
324
        $objects = array();
325
        $count = 0;
326
        $RecordClass = get_class($this->BO);
327
328
        while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
329
            try {
330
                $obj = new $RecordClass();
331
                $obj->load($OID, $row['version_num']);
332
                $objects[$count] = $obj;
333
                ++$count;
334
            } catch (ResourceNotAllowedException $e) {
335
                // the resource not allowed will be absent from the list
336
            }
337
        }
338
339
        self::$logger->debug('<<loadAllOldVersions ['.count($objects).']');
340
341
        return $objects;
342
    }
343
344
    /**
345
     * (non-PHPdoc).

Alpha/Model/ActiveRecordProviderSQLite.php 1 location

@@ 302-342 (lines=41) @@
299
     *
300
     * @see Alpha\Model\ActiveRecordProviderInterface::loadAllOldVersions()
301
     */
302
    public function loadAllOldVersions($OID)
303
    {
304
        self::$logger->debug('>>loadAllOldVersions(OID=['.$OID.'])');
305
306
        $config = ConfigProvider::getInstance();
307
308
        if (!$this->BO->getMaintainHistory()) {
309
            throw new RecordFoundException('loadAllOldVersions method called on an active record where no history is maintained!');
310
        }
311
312
        $sqlQuery = 'SELECT version_num FROM '.$this->BO->getTableName().'_history WHERE OID = \''.$OID.'\' ORDER BY version_num;';
313
314
        $this->BO->setLastQuery($sqlQuery);
315
316
        if (!$result = self::getConnection()->query($sqlQuery)) {
317
            throw new RecordNotFoundException('Failed to load object versions, SQLite error is ['.self::getLastDatabaseError().'], query ['.$this->BO->getLastQuery().']');
318
            self::$logger->debug('<<loadAllOldVersions [0]');
319
320
            return array();
321
        }
322
323
        // now build an array of objects to be returned
324
        $objects = array();
325
        $count = 0;
326
        $RecordClass = get_class($this->BO);
327
328
        while ($row = $result->fetchArray()) {
329
            try {
330
                $obj = new $RecordClass();
331
                $obj->load($OID, $row['version_num']);
332
                $objects[$count] = $obj;
333
                ++$count;
334
            } catch (ResourceNotAllowedException $e) {
335
                // the resource not allowed will be absent from the list
336
            }
337
        }
338
339
        self::$logger->warn('<<loadAllOldVersions ['.count($objects).']');
340
341
        return $objects;
342
    }
343
344
    /**
345
     * (non-PHPdoc).