3 namespace Org\Mxchange\CoreFramework\Database\Backend\Lfdb;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Criteria\Criteria;
7 use Org\Mxchange\CoreFramework\Criteria\Local\LocalSearchCriteria;
8 use Org\Mxchange\CoreFramework\Criteria\Storing\StoreableCriteria;
9 use Org\Mxchange\CoreFramework\Database\Backend\BaseDatabaseBackend;
10 use Org\Mxchange\CoreFramework\Database\Backend\DatabaseBackend;
11 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
12 use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
13 use Org\Mxchange\CoreFramework\Generic\FrameworkException;
19 * Database backend class for storing objects in locally created files.
21 * This class serializes arrays stored in the dataset instance and saves them
22 * to local files. Every file (except 'info') represents a single line. Every
23 * directory within the 'db' (base) directory represents a table.
25 * A configurable 'file_io_class' is being used as "storage backend".
27 * @author Roland Haeder <webmaster@shipsimu.org>
29 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team
30 * @license GNU GPL 3.0 or any newer version
31 * @link http://www.shipsimu.org
33 * This program is free software: you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation, either version 3 of the License, or
36 * (at your option) any later version.
38 * This program is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
43 * You should have received a copy of the GNU General Public License
44 * along with this program. If not, see <http://www.gnu.org/licenses/>.
46 class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
48 * The file's extension
50 private $fileExtension = 'serialized';
53 * The last read file's name
55 private $lastFile = '';
58 * The last read file's content including header information
60 private $lastContents = array();
63 * Whether the "connection is already up
65 private $alreadyConnected = false;
68 * Table information array
70 private $tableInfo = array();
75 private $indexKey = '__idx';
78 * The protected constructor. Do never instance from outside! You need to
79 * set a local file path. The class will then validate it.
83 protected function __construct () {
84 // Call parent constructor
85 parent::__construct(__CLASS__);
89 * Create an object of CachedLocalFileDatabase and set the save path from
90 * configuration for local files.
92 * @return $databaseInstance An instance of CachedLocalFileDatabase
94 public static final function createCachedLocalFileDatabase () {
96 $databaseInstance = new CachedLocalFileDatabase();
98 // Get a new compressor channel instance
99 $compressorInstance = ObjectFactory::createObjectByConfiguredName('compressor_channel_class');
101 // Set the compressor channel
102 $databaseInstance->setCompressorChannel($compressorInstance);
104 // Get a file IO handler
105 $fileIoInstance = ObjectFactory::createObjectByConfiguredName('file_io_class');
108 $databaseInstance->setFileIoInstance($fileIoInstance);
110 // "Connect" to the database
111 $databaseInstance->connectToDatabase();
113 // Return database instance
114 return $databaseInstance;
118 * Setter for the last read file
120 * @param $infoInstance The FQFN of the last read file
123 private final function setLastFile (SplFileInfo $infoInstance) {
124 // Cast string and set it
125 $this->lastFile = $infoInstance;
129 * Getter for last read file
131 * @return $lastFile The last read file's name with full path
133 public final function getLastFile () {
134 return $this->lastFile;
138 * Setter for contents of the last read file
140 * @param $contents An array with header and data elements
143 private final function setLastFileContents (array $contents) {
145 $this->lastContents = $contents;
149 * Getter for last read file's content as an array
151 * @return $lastContent The array with elements 'header' and 'data'.
153 public final function getLastContents () {
154 return $this->lastContents;
158 * Getter for file extension
160 * @return $fileExtension The array with elements 'header' and 'data'.
162 public final function getFileExtension () {
163 return $this->fileExtension;
167 * Getter for index key
169 * @return $indexKey Index key
171 public final function getIndexKey () {
172 return $this->indexKey;
176 * Reads a local data file and returns it's contents in an array
178 * @param $infoInstance An instance of a SplFileInfo class
181 private function getDataArrayFromFile (SplFileInfo $infoInstance) {
182 // Init compressed data
183 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Reading elements from database file ' . $infoInstance . ' ...');
184 $compressedData = $this->getFileIoInstance()->loadFileContents($infoInstance);
185 $compressedData = $compressedData['data'];
188 $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData);
191 $dataArray = json_decode($serializedData, true);
194 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Read ' . count($dataArray) . ' elements from database file ' . $infoInstance . '.');
195 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: dataArray=' . print_r($dataArray, true));
200 * Writes data array to local file
202 * @param $infoInstance An instance of a SplFileInfo class
203 * @param $dataArray An array with all the data we shall write
206 private function writeDataArrayToFqfn (SplFileInfo $infoInstance, array $dataArray) {
207 // Serialize and compress it
208 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Flushing ' . count($dataArray) . ' elements to database file ' . $infoInstance . ' ...');
209 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: dataArray=' . print_r($dataArray, true));
210 $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(json_encode($dataArray));
212 // Write this data BASE64 encoded to the file
213 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Writing ' . strlen($compressedData) . ' bytes ...');
214 $this->getFileIoInstance()->saveStreamToFile($infoInstance, $compressedData, $this);
217 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Flushing ' . count($dataArray) . ' elements to database file completed.');
221 * Getter for table information file contents or an empty if info file was not created
223 * @param $dataSetInstance An instance of a database set class
224 * @return $infoArray An array with all table informations
226 private function getContentsFromTableInfoFile (StoreableCriteria $dataSetInstance) {
227 // Default content is no data
228 $infoArray = array();
230 // Create FQFN for getting the table information file
231 $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
233 // Get the file contents
235 $infoArray = $this->getDataArrayFromFile($infoInstance);
236 } catch (FileNotFoundException $e) {
237 // Not found, so ignore it here
245 * Generates a file info class from given dataset instance and string
247 * @param $dataSetInstance An instance of a database set class
248 * @param $rowName Name of the row
249 * @return $infoInstance An instance of a SplFileInfo class
251 private function generateFileFromDataSet (Criteria $dataSetInstance, $rowName) {
252 // Instanciate new file object
253 $infoInstance = new SplFileInfo($this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR . $rowName . '.' . $this->getFileExtension());
256 return $infoInstance;
260 * Creates the table info file from given dataset instance
262 * @param $dataSetInstance An instance of a database set class
265 private function createTableInfoFile (StoreableCriteria $dataSetInstance) {
266 // Create FQFN for creating the table information file
267 $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
269 // Get the data out from dataset in a local array
270 $this->tableInfo[$dataSetInstance->getTableName()] = array(
271 'primary' => $dataSetInstance->getPrimaryKey(),
273 'last_updated' => time()
276 // Write the data to the file
277 $this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$dataSetInstance->getTableName()]);
281 * Updates the table info file from given dataset instance
283 * @param $dataSetInstance An instance of a database set class
286 private function updateTableInfoFile (StoreableCriteria $dataSetInstance) {
287 // Get table name from criteria
288 $tableName = $dataSetInstance->getTableName();
290 // Create FQFN for creating the table information file
291 $infoInstance = $this->generateFileFromDataSet($dataSetInstance, 'info');
293 // Get the data out from dataset in a local array
294 $this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey();
295 $this->tableInfo[$tableName]['last_updated'] = time();
297 // Write the data to the file
298 $this->writeDataArrayToFqfn($infoInstance, $this->tableInfo[$tableName]);
302 * Updates the primary key information or creates the table info file if not found
304 * @param $dataSetInstance An instance of a database set class
307 private function updatePrimaryKey (StoreableCriteria $dataSetInstance) {
308 // Get table name from criteria
309 $tableName = $dataSetInstance->getTableName();
311 // Get the information array from lower method
312 $infoArray = $this->getContentsFromTableInfoFile($dataSetInstance);
314 // Is the primary key there?
315 /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableInfo=' . print_r($this->tableInfo, true));
316 if (!isset($this->tableInfo[$tableName]['primary'])) {
317 // Then create the info file
318 $this->createTableInfoFile($dataSetInstance);
319 } elseif (($this->getConfigInstance()->getConfigEntry('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo[$tableName]['primary'])) {
320 // Set the array element
321 $this->tableInfo[$tableName]['primary'] = $dataSetInstance->getPrimaryKey();
324 $this->updateTableInfoFile($dataSetInstance);
329 * Makes sure that the database connection is alive
332 * @todo Do some checks on the database directory and files here
334 public function connectToDatabase () {
338 * Starts a SELECT query on the database by given return type, table name
339 * and search criteria
341 * @param $tableName Name of the database table
342 * @param $searchInstance Local search criteria class
343 * @return $resultData Result data of the query
344 * @throws UnsupportedCriteriaException If the criteria is unsupported
345 * @throws SqlException If an 'SQL error' occurs
347 public function querySelect ($tableName, LocalSearchCriteria $searchInstance) {
348 // The result is null by any errors
349 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: tableName=%s,searchInstance=%s - CALLED!', $tableName, $searchInstance->__toString()));
352 // Create full path name
353 $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
356 * A 'select' query is not that easy on local files, so first try to
357 * find the 'table' which is in fact a directory on the server
360 // Get a directory pointer instance
361 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Getting directory_class for pathName=%s ...', $pathName));
362 $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName));
364 // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read
366 BaseDatabaseBackend::RESULT_INDEX_STATUS => self::RESULT_OKAY,
367 BaseDatabaseBackend::RESULT_INDEX_ROWS => array()
370 // Initialize limit/skip
375 // Read the directory with some exceptions
376 while (($fileInfoInstance = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) {
377 // Does the extension match?
378 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: fileInfoInstance->extension=%s,this->fileExtension=%s', $fileInfoInstance->getExtension(), $this->getFileExtension()));
379 if ($fileInfoInstance->getExtension() !== $this->getFileExtension()) {
381 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Skipping fileInfoInstance->filename=%s ...', $fileInfoInstance->getFilename()));
382 $directoryInstance->getDirectoryIteratorInstance()->next();
387 $dataArray = $this->getDataArrayFromFile($fileInfoInstance);
390 //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.pathname=' . $fileInfoInstance->getPathname() . ',dataArray='.print_r($dataArray, true));
391 if (is_array($dataArray)) {
392 // Default is nothing found
395 // Search in the criteria with FMFW (First Matches, First Wins)
396 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: dataArray()=%d', count($dataArray)));
397 foreach ($dataArray as $key => $value) {
398 // Make sure value is not bool
399 assert(!is_bool($value));
402 $isFound = (($isFound === true) && ($searchInstance->isCriteriaMatching($key, $value)));
403 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: key=%s,value[%s]=%s,isFound=%s', $key, gettype($value), $value, intval($isFound)));
407 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: isFound=%d,limitFound=%d,limit=%d', intval($isFound), $limitFound, $searchInstance->getLimit()));
408 if ($isFound === true) {
409 // Shall we skip this entry?
410 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: searchInstance->skip=%d', $searchInstance->getSkip()));
411 if ($searchInstance->getSkip() > 0) {
412 // We shall skip some entries
413 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: skipFound=%s', $skipFound));
414 if ($skipFound < $searchInstance->getSkip()) {
422 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: Setting dataArray[%s]=%d', $this->getIndexKey(), $idx));
423 $dataArray[$this->getIndexKey()] = $idx;
426 array_push($resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS], $dataArray);
428 // Count found entries up
429 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: resultData[%s]()=%d', BaseDatabaseBackend::RESULT_INDEX_ROWS, count($resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS])));
433 // Throw an exception here
434 throw new SqlException(array($this, sprintf('File '%s' contains invalid data.', $fileInfoInstance->getPathname()), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY);
440 // Advance to next entry
441 $directoryInstance->getDirectoryIteratorInstance()->next();
444 // Close directory and throw the instance away
445 $directoryInstance->closeDirectory();
446 unset($directoryInstance);
448 // Reset last exception
449 $this->resetLastException();
450 } catch (PathIsNoDirectoryException $e) {
451 // Path not found means "table not found" for real databases...
452 $this->setLastException($e);
454 // So throw an SqlException here with faked error message
455 throw new SqlException (array($this, sprintf('Table '%s' not found', $tableName), self::DB_CODE_TABLE_MISSING), self::EXCEPTION_SQL_QUERY);
456 } catch (FrameworkException $e) {
457 // Catch all exceptions and store them in last error
458 $this->setLastException($e);
461 // Return the gathered result
466 * "Inserts" a data set instance into a local file database folder
468 * @param $dataSetInstance A storeable data set
470 * @throws SqlException If an SQL error occurs
472 public function queryInsertDataSet (StoreableCriteria $dataSetInstance) {
473 // Try to save the request away
474 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CACHED-LFDB: dataSetInstance=%s - CALLED!', $dataSetInstance->__toString()));
476 // Create full path name
477 $infoInstance = $this->generateFileFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue()));
479 // Write the data away
480 $this->writeDataArrayToFqfn($infoInstance, $dataSetInstance->getCriteriaArray());
482 // Update the primary key
483 $this->updatePrimaryKey($dataSetInstance);
485 // Reset last exception
486 $this->resetLastException();
487 } catch (FrameworkException $e) {
488 // Catch all exceptions and store them in last error
489 $this->setLastException($e);
491 // Throw an SQL exception
492 throw new SqlException(array(
494 sprintf('Cannot write data to table '%s', is the table created?', $dataSetInstance->getTableName()),
495 self::DB_CODE_TABLE_UNWRITEABLE
497 self::EXCEPTION_SQL_QUERY
502 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: EXIT!');
506 * "Updates" a data set instance with a database layer
508 * @param $dataSetInstance A storeable data set
510 * @throws SqlException If an SQL error occurs
512 public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) {
513 // Create full path name
514 $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR;
516 // Try all the requests
518 // Get a file pointer instance
519 $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName));
521 // Initialize limit/skip
525 // Get the criteria array from the dataset
526 $searchArray = $dataSetInstance->getCriteriaArray();
528 // Get search criteria
529 $searchInstance = $dataSetInstance->getSearchInstance();
531 // Read the directory with some exceptions
532 while (($fileInfoInstance = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) {
533 // Does the extension match?
534 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance->extension=' . $fileInfoInstance->getExtension() . ',this->getFileExtension()=' . $this->getFileExtension());
535 if ($fileInfoInstance->getExtension() !== $this->getFileExtension()) {
537 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.extension=' . $fileInfoInstance->getExtension() . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!');
538 $directoryInstance->getDirectoryIteratorInstance()->next();
542 // Open this file for reading
543 $dataArray = $this->getDataArrayFromFile($fileInfoInstance);
544 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.pathname=' . $fileInfoInstance->getPathname() . ',dataArray='.print_r($dataArray, true));
547 if (is_array($dataArray)) {
548 // Default is nothing found
551 // Search in the criteria with FMFW (First Matches, First Wins)
552 foreach ($dataArray as $key => $value) {
553 // Make sure value is not bool
554 assert(!is_bool($value));
557 $isFound = (($isFound === true) && ($searchInstance->isCriteriaMatching($key, $value)));
561 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: isFound=' . intval($isFound));
562 if ($isFound === true) {
563 // Shall we skip this entry?
564 if ($searchInstance->getSkip() > 0) {
565 // We shall skip some entries
566 if ($skipFound < $searchInstance->getSkip()) {
568 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Found entry, but skipping ...');
574 // Entry found, so update it
575 foreach ($searchArray as $searchKey => $searchValue) {
576 // Make sure the value is not bool again
577 assert(!is_bool($searchValue));
578 assert($searchKey != $this->indexKey);
580 // Debug message + add/update it
581 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: criteriaKey=' . $searchKey . ',criteriaValue=' . $searchValue);
582 $dataArray[$searchKey] = $searchValue;
585 // Write the data to a local file
586 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: Writing dataArray()=' . count($dataArray) . ' to ' . $fileInfoInstance->getPathname() . ' ...');
587 $this->writeDataArrayToFqfn($fileInfoInstance, $dataArray);
589 // Count found entries up
594 // Advance to next entry
595 $directoryInstance->getDirectoryIteratorInstance()->next();
598 // Close the file pointer
599 $directoryInstance->closeDirectory();
601 // Update the primary key
602 $this->updatePrimaryKey($dataSetInstance);
604 // Reset last exception
605 $this->resetLastException();
606 } catch (FrameworkException $e) {
607 // Catch all exceptions and store them in last error
608 $this->setLastException($e);
610 // Throw an SQL exception
611 throw new SqlException(array($this, sprintf('Cannot write data to table '%s', is the table created? Exception: %s, message:%s', $dataSetInstance->getTableName(), $e->__toString(), $e->getMessage()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
616 * Getter for primary key of specified table or if not found null will be
617 * returned. This must be database-specific.
619 * @param $tableName Name of the table we need the primary key from
620 * @return $primaryKey Primary key column of the given table
621 * @todo Rename method to getPrimaryKeyFromTableInfo()
623 public function getPrimaryKeyOfTable ($tableName) {
624 // Default key is null
627 // Does the table information exist?
628 if (isset($this->tableInfo[$tableName])) {
629 // Then return the primary key
630 $primaryKey = $this->tableInfo[$tableName]['primary'];
638 * Removes non-public data from given array.
640 * @param $data An array with possible non-public data that needs to be removed.
641 * @return $data A cleaned up array with only public data.
642 * @todo Add more generic non-public data for removal
644 public function removeNonPublicDataFromArray (array $data) {
646 unset($data[$this->indexKey]);
649 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: data[' . gettype($data) . ']='.print_r($data, true));
654 * Counts total rows of given table
656 * @param $tableName Table name
657 * @return $count Total rows of given table
659 public function countTotalRows($tableName) {
660 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableName=' . $tableName . ' - CALLED!');
662 // Create full path name
663 $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
665 // Try all the requests
667 // Get a file pointer instance
668 $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName));
670 // Initialize counter
673 // Read the directory with some exceptions
674 while ($fileInfoInstance = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) {
675 // Does the extension match?
676 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance->extension=' . $fileInfoInstance->getExtension() . ',this->getFileExtension()=' . $this->getFileExtension());
677 if ($fileInfoInstance->getExtension() !== $this->getFileExtension()) {
679 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.extension=' . $fileInfoInstance->getExtension() . ',getFileExtension()=' . $this->getFileExtension() . ' - SKIPPED!');
685 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: fileInfoInstance.pathname=' . $fileInfoInstance->getPathname() . ',getFileExtension()=' . $this->getFileExtension() . ' - COUNTED!');
688 } catch (FrameworkException $e) {
689 // Catch all exceptions and store them in last error
690 $this->setLastException($e);
692 // Throw an SQL exception
693 throw new SqlException(array($this, sprintf('Cannot count on table '%s', is the table created?', $dataSetInstance->getTableName()), self::DB_CODE_TABLE_NOT_FOUND), self::EXCEPTION_SQL_QUERY);
697 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CACHED-LFDB: tableName=' . $tableName . ',count=' . $count . ' - EXIT!');