]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/database/backend/class_CachedLocalFileDatabase.php
imported FileNotFoundException
[core.git] / framework / main / classes / database / backend / class_CachedLocalFileDatabase.php
index a2f65b40110774aa5a1b2b2bb312b0e2ec1ea9ac..e8a8555a03220a65b9db947efb7cd99938f86146 100644 (file)
@@ -9,6 +9,7 @@ use CoreFramework\Criteria\Storing\StoreableCriteria;
 use CoreFramework\Database\Backend\BaseDatabaseBackend;
 use CoreFramework\Database\Backend\DatabaseBackend;
 use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Filesystem\FileNotFoundException;
 use CoreFramework\Generic\FrameworkException;
 
 /**
@@ -58,7 +59,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        /**
         * Whether the "connection is already up
         */
-       private $alreadyConnected = FALSE;
+       private $alreadyConnected = false;
 
        /**
         * Table information array
@@ -189,11 +190,11 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                $serializedData = $this->getCompressorChannel()->getCompressor()->decompressStream($compressedData);
 
                // Unserialize it
-               $dataArray = json_decode($serializedData, TRUE);
+               $dataArray = json_decode($serializedData, true);
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Read ' . count($dataArray) . ' elements from database file ' . $fqfn . '.');
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, true));
 
                // Finally return it
                return $dataArray;
@@ -209,7 +210,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
        private function writeDataArrayToFqfn ($fqfn, array $dataArray) {
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: Flushing ' . count($dataArray) . ' elements to database file ' . $fqfn . ' ...');
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataArray=' . print_r($dataArray, true));
 
                // Serialize and compress it
                $compressedData = $this->getCompressorChannel()->getCompressor()->compressStream(json_encode($dataArray));
@@ -257,7 +258,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
         */
        private function generateFqfnFromDataSet (Criteria $dataSetInstance, $rowName) {
                // This is the FQFN
-               $fqfn = $this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . '/' . $rowName . '.' . $this->getFileExtension();
+               $fqfn = $this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR . $rowName . '.' . $this->getFileExtension();
 
                // Return it
                return $fqfn;
@@ -319,7 +320,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                $infoArray = $this->getContentsFromTableInfoFile($dataSetInstance);
 
                // Is the primary key there?
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: tableInfo=' . print_r($this->tableInfo, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: tableInfo=' . print_r($this->tableInfo, true));
                if (!isset($this->tableInfo[$tableName]['primary'])) {
                        // Then create the info file
                        $this->createTableInfoFile($dataSetInstance);
@@ -359,7 +360,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                $resultData = NULL;
 
                // Create full path name
-               $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $tableName . '/';
+               $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
 
                /*
                 * A 'select' query is not that easy on local files, so first try to
@@ -393,12 +394,12 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
 
                                // Read the file
                                $dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, TRUE));
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, true));
 
                                // Is this an array?
                                if (is_array($dataArray)) {
                                        // Default is nothing found
-                                       $isFound = TRUE;
+                                       $isFound = true;
 
                                        // Search in the criteria with FMFW (First Matches, First Wins)
                                        foreach ($dataArray as $key => $value) {
@@ -406,13 +407,13 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                                                assert(!is_bool($value));
 
                                                // Found one entry?
-                                               $isFound = (($isFound === TRUE) && ($searchInstance->isCriteriaMatching($key, $value)));
+                                               $isFound = (($isFound === true) && ($searchInstance->isCriteriaMatching($key, $value)));
                                                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: key=' . $key . ',value=' . $value . ',isFound=' . intval($isFound));
                                        } // END - foreach
 
                                        // Is all found?
                                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: isFound=' . intval($isFound) . ',limitFound=' . $limitFound . ',limit=' . $searchInstance->getLimit());
-                                       if ($isFound === TRUE) {
+                                       if ($isFound === true) {
                                                // Shall we skip this entry?
                                                if ($searchInstance->getSkip() > 0) {
                                                        // We shall skip some entries
@@ -427,7 +428,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                                                $dataArray[$this->getIndexKey()] = $idx;
 
                                                // Entry found!
-                                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, TRUE));
+                                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: indexKey=' . $this->getIndexKey() . ',idx=' . $idx . ',dataArray=' . print_r($dataArray, true));
                                                array_push($resultData[BaseDatabaseBackend::RESULT_INDEX_ROWS], $dataArray);
 
                                                // Count found entries up
@@ -502,7 +503,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
         */
        public function queryUpdateDataSet (StoreableCriteria $dataSetInstance) {
                // Create full path name
-               $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . '/';
+               $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $dataSetInstance->getTableName() . DIRECTORY_SEPARATOR;
 
                // Try all the requests
                try {
@@ -531,12 +532,12 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
 
                                // Open this file for reading
                                $dataArray = $this->getDataArrayFromFile($pathName . $dataFile);
-                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, TRUE));
+                               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: dataFile=' . $dataFile . ',dataArray='.print_r($dataArray, true));
 
                                // Is this an array?
                                if (is_array($dataArray)) {
                                        // Default is nothing found
-                                       $isFound = TRUE;
+                                       $isFound = true;
 
                                        // Search in the criteria with FMFW (First Matches, First Wins)
                                        foreach ($dataArray as $key => $value) {
@@ -544,12 +545,12 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                                                assert(!is_bool($value));
 
                                                // Found one entry?
-                                               $isFound = (($isFound === TRUE) && ($searchInstance->isCriteriaMatching($key, $value)));
+                                               $isFound = (($isFound === true) && ($searchInstance->isCriteriaMatching($key, $value)));
                                        } // END - foreach
 
                                        // Is all found?
                                        //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: isFound=' . intval($isFound));
-                                       if ($isFound === TRUE) {
+                                       if ($isFound === true) {
                                                // Shall we skip this entry?
                                                if ($searchInstance->getSkip() > 0) {
                                                        // We shall skip some entries
@@ -632,7 +633,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                unset($data[$this->indexKey]);
 
                // Return it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: data[' . gettype($data) . ']='.print_r($data, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: data[' . gettype($data) . ']='.print_r($data, true));
                return $data;
        }
 
@@ -646,7 +647,7 @@ class CachedLocalFileDatabase extends BaseDatabaseBackend implements DatabaseBac
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE: tableName=' . $tableName . ' - CALLED!');
 
                // Create full path name
-               $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $tableName . '/';
+               $pathName = $this->getConfigInstance()->getConfigEntry('local_database_path') . $tableName . DIRECTORY_SEPARATOR;
 
                // Try all the requests
                try {