Some fixes.
authorRoland Haeder <roland@mxchange.org>
Tue, 22 Jul 2014 20:14:07 +0000 (22:14 +0200)
committerRoland Haeder <roland@mxchange.org>
Tue, 22 Jul 2014 20:14:07 +0000 (22:14 +0200)
Signed-off-by: Roland Häder <roland@mxchange.org>
inc/classes/main/database/class_BaseDatabaseWrapper.php
inc/classes/main/database/databases/class_LocalFileDatabase.php
inc/classes/main/file_directories/directory/class_FrameworkDirectoryPointer.php
inc/classes/main/result/class_DatabaseResult.php

index da4fa274322b02beb56d38ea1af863128af981a0..733fda69e85cbb0939f5d8c9cbd51e160988d084 100644 (file)
@@ -151,16 +151,17 @@ class BaseDatabaseWrapper extends BaseFrameworkSystem {
                // Does this key exists in cache?
                if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
                        // Debug message
                // Does this key exists in cache?
                if (($this->getConfigInstance()->getConfigEntry('database_cache_enabled') === TRUE) && ($this->cacheInstance->offsetExists($cacheKey, BaseDatabaseBackend::RESULT_INDEX_ROWS, 1))) {
                        // Debug message
-                       /DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE));
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Cache used for cacheKey=' . $cacheKey . ':' . print_r($this->cacheInstance->offsetGet($cacheKey), TRUE));
 
                        // Then use this result
                        $result = $this->cacheInstance->offsetGet($cacheKey);
                } else {
                        // Debug message
 
                        // Then use this result
                        $result = $this->cacheInstance->offsetGet($cacheKey);
                } else {
                        // Debug message
-                       /DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: Quering database, cacheKey=' . $cacheKey);
 
                        // Now it's time to ask the database layer for this select statement
                        $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
 
                        // Now it's time to ask the database layer for this select statement
                        $result = $this->getDatabaseInstance()->doSelectByTableCriteria($this->getTableName(), $criteriaInstance);
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: result[]=' . gettype($result));
 
                        // Cache the result if not null
                        if (!is_null($result)) {
 
                        // Cache the result if not null
                        if (!is_null($result)) {
index 16e6bee0047b3c1e01de9a23b6b5ab3be1c444aa..881831054de5d5241ca2806420d09e2058b8cda6 100644 (file)
@@ -340,14 +340,19 @@ class LocalFileDatabase extends BaseDatabaseBackend implements DatabaseBackend {
         * @throws      SqlException                                    If an 'SQL error' occurs
         */
        public function querySelect ($tableName, LocalSearchCriteria $searchInstance) {
         * @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 . '/';
 
                // 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));
                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))) {
 
                        // 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!
                                // Does the extension match?
                                if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
                                        // Skip this file!
index 7fe69cb80feabeb3a2ae6c606107f9c278976bc2..a267c63f075eb6d0f6174aa88bb5808754e32ee2 100644 (file)
@@ -116,26 +116,26 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
        /**
         * Read raw lines of data from a directory pointer and return the data
         *
        /**
         * Read raw lines of data from a directory pointer and return the data
         *
-        * @return      $current        Current entry from encapsulated iterator
+        * @return      $currentEntry   Current entry from encapsulated iterator
         */
        public function readRawDirectory () {
                // Can the next entry be read?
                assert($this->getDirectoryInstance()->valid());
 
                // Default is FALSE
         */
        public function readRawDirectory () {
                // Can the next entry be read?
                assert($this->getDirectoryInstance()->valid());
 
                // Default is FALSE
-               $current = FALSE;
+               $currentEntry = FALSE;
 
                // Is it a dot directory?
                if (!$this->getDirectoryInstance()->isDot()) {
                        // Read data from the directory pointer and return it
 
                // Is it a dot directory?
                if (!$this->getDirectoryInstance()->isDot()) {
                        // Read data from the directory pointer and return it
-                       $current = $this->getDirectoryInstance()->current();
+                       $currentEntry = $this->getDirectoryInstance()->current();
                } // END - if
 
                // Advance to next entry
                $this->getDirectoryInstance()->next();
 
                // Return found entry
                } // END - if
 
                // Advance to next entry
                $this->getDirectoryInstance()->next();
 
                // Return found entry
-               return $current;
+               return $currentEntry;
        }
 
        /**
        }
 
        /**
@@ -152,24 +152,30 @@ class FrameworkDirectoryPointer extends BaseFrameworkSystem {
                        return $this->readRawDirectory();
                } // END - if
 
                        return $this->readRawDirectory();
                } // END - if
 
+               // Init raw line
+               $rawLine = NULL;
+
                // Read a raw line...
                // Read a raw line...
-               $rawLine = $this->readRawDirectory();
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
+               $currentEntry = $this->readRawDirectory();
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: currentEntry[]=' . gettype($currentEntry));
 
                // Shall we exclude directories?
 
                // Shall we exclude directories?
-               if ((!is_null($rawLine)) && ($rawLine !== FALSE) && (!in_array($rawLine, $except))) {
-                       // Return read data
+               if (is_object($currentEntry)) {
+                       // Get file name
+                       $rawLine = $currentEntry->getFilename();
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
-                       return $rawLine;
-               } elseif ((!is_null($rawLine)) && ($rawLine !== FALSE)) {
-                       // Exclude this part
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!');
-                       return $this->readDirectoryExcept($except);
-               }
 
 
-               // End pointer reached
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: Returning NULL!');
-               return NULL;
+                       // Is it not excluded?
+                       if (in_array($rawLine, $except)) {
+                               // Exclude this part
+                               $rawLine = $this->readDirectoryExcept($except);
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawline[' . gettype($rawLine) . ']=' . $rawLine . ' - Recursive call!');
+                       } // END - if
+               } // END - if
+
+               // Return read line
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECTORY[' . __METHOD__ . ':' . __LINE__ . ']: rawLine[' . gettype($rawLine) . ']=' . $rawLine);
+               return $rawLine;
        }
 
        /**
        }
 
        /**
index 1d7b9305fa3b91e922cef7aec9388324eb5dd744..4b2c073b5a685398f731ede03de978cba0a50079 100644 (file)
@@ -183,7 +183,10 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
                // By default nothing is valid
                $isValid = FALSE;
 
                // By default nothing is valid
                $isValid = FALSE;
 
-               // Check if 
+               // Debug message
+               //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] this->currentPos=' . $this->currentPos);
+
+               // Check if all is fine ...
                if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][0]))) {
                        // All fine!
                        $isValid = TRUE;
                if (($this->ifStatusIsOkay()) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][($this->currentPos + 1)])) && (isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_ROWS][0]))) {
                        // All fine!
                        $isValid = TRUE;
@@ -209,7 +212,9 @@ class DatabaseResult extends BaseFrameworkSystem implements SearchableResult, Up
         * @return      $ifStatusOkay   Whether the status of the query was okay
         */
        public function ifStatusIsOkay () {
         * @return      $ifStatusOkay   Whether the status of the query was okay
         */
        public function ifStatusIsOkay () {
-               return ((isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS] === BaseDatabaseBackend::RESULT_OKAY));
+               $ifStatusOkay = ((isset($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS])) && ($this->resultArray[BaseDatabaseBackend::RESULT_INDEX_STATUS] === BaseDatabaseBackend::RESULT_OKAY));
+               //*NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] ifStatusOkay=' . intval($ifStatusOkay));
+               return $ifStatusOkay;
        }
 
        /**
        }
 
        /**