Continued CSV parsing:
[core.git] / inc / classes / main / database / databases / class_LocalFileDatabase.php
index dd1f5b745990c5d6d90f148a913626948ccead42..7f23e2adb07c17d1a4f302a2f9d8367209f522e8 100644 (file)
@@ -10,7 +10,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2013 Core Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Core Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -206,7 +206,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing ' . strlen($compressedData) . ' bytes ...');
 
                // Write this data BASE64 encoded to the file
-               $this->getFileIoInstance()->saveFile($fqfn, $compressedData, $this);
+               $this->getFileIoInstance()->saveStreamToFile($fqfn, $compressedData, $this);
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file completed.');
@@ -340,14 +340,19 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
         * @throws      SqlException                                    If an 'SQL error' occurs
         */
        public function querySelect ($tableName, LocalSearchCriteria $searchInstance) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: tableName=' . $tableName . ' - CALLED!');
+
                // The result is null by any errors
                $resultData = NULL;
 
                // Create full path name
                $pathName = $this->getConfigInstance()->getConfigEntry('local_db_path') . $tableName . '/';
 
-               // A 'select' query is not that easy on local files, so first try to
-               // find the 'table' which is in fact a directory on the server
+               /*
+                * A 'select' query is not that easy on local files, so first try to
+                * find the 'table' which is in fact a directory on the server
+                */
                try {
                        // Get a directory pointer instance
                        $directoryInstance = ObjectFactory::createObjectByConfiguredName('directory_class', array($pathName));
@@ -365,6 +370,9 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
 
                        // Read the directory with some exceptions
                        while (($dataFile = $directoryInstance->readDirectoryExcept(array('.htaccess', 'info.' . $this->getFileExtension()))) && (($limitFound < $searchInstance->getLimit()) || ($searchInstance->getLimit() == 0))) {
+                               // Debug message
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',this->getFileExtension()=' . $this->getFileExtension());
+
                                // Does the extension match?
                                if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
                                        // Skip this file!
@@ -528,12 +536,14 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
                                        } // END - foreach
 
                                        // Is all found?
+                                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: isFound=' . intval($isFound));
                                        if ($isFound === TRUE) {
                                                // Shall we skip this entry?
                                                if ($searchInstance->getSkip() > 0) {
                                                        // We shall skip some entries
                                                        if ($skipFound < $searchInstance->getSkip()) {
                                                                // Skip this entry
+                                                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Found entry, but skipping ...');
                                                                $skipFound++;
                                                                break;
                                                        } // END - if
@@ -551,6 +561,7 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
                                                } // END - foreach
 
                                                // Write the data to a local file
+                                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DATABASE: Writing dataArray()=' . count($dataArray) . ' to ' . $dataFile . ' ...');
                                                $this->writeDataArrayToFqfn($pathName . $dataFile, $dataArray);
 
                                                // Count found entries up