]> git.mxchange.org Git - shipsimu.git/blobdiff - inc/classes/main/database/databases/class_LocalFileDatabase.php
Again, a commit! ;-)
[shipsimu.git] / inc / classes / main / database / databases / class_LocalFileDatabase.php
index 25cf9389f68b7708182e3767fedece739e04d8ec..96b5c2291eab729c88552c13a6db66c0ce6af999 100644 (file)
@@ -153,13 +153,12 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
        /**
         * Setter for the last read file
         *
-        * @param               $fqfn   The FQFN of the last read file
+        * @param       $fqfn   The FQFN of the last read file
         * @return      void
         */
        private final function setLastFile ($fqfn) {
-               // Cast string
-               $fqfn = (string) $fqfn;
-               $this->lastFile = $fqfn;
+               // Cast string and set it
+               $this->lastFile = (string) $fqfn;
        }
 
        /**
@@ -188,9 +187,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
         * @param               $contents               An array with header and data elements
         * @return      void
         */
-       private final function setLastFileContents ($contents) {
-               // Cast array
-               $contents = (array) $contents;
+       private final function setLastFileContents (array $contents) {
+               // Set array
                $this->lastContents = $contents;
        }
 
@@ -370,6 +368,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        // Initialize limit/skip
                        $limitFound = 0;
                        $skipFound = 0;
+                       $idx = 1;
 
                        // Read the directory with some exceptions
                        while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
@@ -377,7 +376,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
                                        // Skip this file!
                                        continue;
-                               }
+                               } // END - if
 
                                // Read the file
                                $dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
@@ -402,8 +401,13 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                                                } // END - if
                                                        } // END - if
 
+                                                       // Set id number
+                                                       $dataArray['__idx'] = $idx;
+
                                                        // Entry found!
                                                        $resultData['rows'][] = $dataArray;
+
+                                                       // Count found entries up
                                                        $limitFound++;
                                                        break;
                                                } // END - if
@@ -412,6 +416,9 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                        // Throw an exception here
                                        throw new SqlException(array($this, sprintf("File &#39;%s&#39; contains invalid data.", $dataFile), self::DB_CODE_DATA_FILE_CORRUPT), self::EXCEPTION_SQL_QUERY);
                                }
+
+                               // Count entry up
+                               $idx++;
                        } // END - while
 
                        // Close directory and throw the instance away