]> git.mxchange.org Git - core.git/blobdiff - inc/classes/main/database/databases/class_LocalFileDatabase.php
Some 'static' array elements rewritten to constant, other cleanups
[core.git] / inc / classes / main / database / databases / class_LocalFileDatabase.php
index 083729efdac4e3812565dae4bc7c5ca1acc88389..37dca8fcc4f2c3fa83c6e0a199b69db411a02477 100644 (file)
@@ -359,8 +359,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
 
                        // Initialize the result data, this need to be rewritten e.g. if a local file cannot be read
                        $resultData = array(
-                               'status'        => LocalfileDatabase::RESULT_OKAY,
-                               'rows'          => array()
+                               BaseDatabaseFrontend::RESULT_INDEX_STATUS => LocalfileDatabase::RESULT_OKAY,
+                               BaseDatabaseFrontend::RESULT_INDEX_ROWS   => array()
                        );
 
                        // Initialize limit/skip
@@ -369,7 +369,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $idx = 1;
 
                        // Read the directory with some exceptions
-                       while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
+                       while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', 'info.' . $this->getFileExtension()))) && (($limitFound < $criteriaInstance->getLimit()) || ($criteriaInstance->getLimit() == 0))) {
                                // Does the extension match?
                                if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
                                        // Skip this file!
@@ -387,8 +387,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                                $criteria = $criteriaInstance->getCriteriaElemnent($key);
 
                                                // Is the criteria met?
+                                               //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: criteria[' . gettype($criteria) . ']=' . $criteria . ',()=' . strlen($criteria) . ',value=' . $value . ',()=' . strlen($value));
                                                if ((!is_null($criteria)) && ($criteria == $value))  {
-
                                                        // Shall we skip this entry?
                                                        if ($criteriaInstance->getSkip() > 0) {
                                                                // We shall skip some entries
@@ -403,7 +403,8 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                                                        $dataArray[$this->getIndexKey()] = $idx;
 
                                                        // Entry found!
-                                                       $resultData['rows'][] = $dataArray;
+                                                       //* NOISY-DEBUG: */ $this->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true));
+                                                       $resultData[BaseDatabaseFrontend::RESULT_INDEX_ROWS][] = $dataArray;
 
                                                        // Count found entries up
                                                        $limitFound++;
@@ -428,14 +429,14 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                } catch (PathIsNoDirectoryException $e) {
                        // Path not found means "table not found" for real databases...
                        $this->lastException = $e;
-                       $this->lastError = $e->getMessage();
+                       $this->lastError     = $e->getMessage();
 
                        // So throw an SqlException here with faked error message
                        throw new SqlException (array($this, sprintf("Table &#39;%s&#39; not found", $tableName), self::DB_CODE_TABLE_MISSING), self::EXCEPTION_SQL_QUERY);
                } catch (FrameworkException $e) {
                        // Catch all exceptions and store them in last error
                        $this->lastException = $e;
-                       $this->lastError = $e->getMessage();
+                       $this->lastError     = $e->getMessage();
                }
 
                // Return the gathered result
@@ -469,7 +470,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $this->lastError     = $e->getMessage();
 
                        // Throw an SQL exception
-                       throw new SqlException (array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
+                       throw new SqlException(array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
                }
        }
 
@@ -560,7 +561,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend
                        $this->lastError = $e->getMessage();
 
                        // Throw an SQL exception
-                       throw new SqlException (array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
+                       throw new SqlException(array($this, sprintf("Cannot write data to table &#39;%s&#39;, is the table created?", $dataSetInstance->getTableName()), self::DB_CODE_TABLE_UNWRITEABLE), self::EXCEPTION_SQL_QUERY);
                }
        }