From 0567c3a1bb112844a02a18986e99e77e5de55f63 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 3 Aug 2009 21:23:58 +0000 Subject: [PATCH] FQFN is now generated by new private method getFqfnFromDataSetInstance() --- .../databases/class_LocalFileDatabase.php | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/inc/classes/main/database/databases/class_LocalFileDatabase.php b/inc/classes/main/database/databases/class_LocalFileDatabase.php index 78375f66..5ba5e22f 100644 --- a/inc/classes/main/database/databases/class_LocalFileDatabase.php +++ b/inc/classes/main/database/databases/class_LocalFileDatabase.php @@ -75,7 +75,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend /** * Element for index */ - private $indexKey = "__idx"; + private $indexKey = '__idx'; /** * The protected constructor. Do never instance from outside! You need to @@ -96,10 +96,10 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend * Create an object of LocalFileDatabase and set the save path for local files. * This method also validates the given file path. * - * @param $savePath The local file path string - * @param $ioInstance The input/output handler. This - * should be FileIoHandler - * @return $dbInstance An instance of LocalFileDatabase + * @param $savePath The local file path string + * @param $ioInstance The input/output handler. This + * should be FileIoHandler + * @return $dbInstance An instance of LocalFileDatabase */ public final static function createLocalFileDatabase ($savePath, FileIoHandler $ioInstance) { // Get an instance @@ -285,7 +285,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend $infoArray = array(); // Create FQFN for getting the table information file - $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/info.' . $this->getFileExtension(); + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); // Get the file contents try { @@ -298,6 +298,21 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend return $infoArray; } + /** + * Generates an FQFN from given dataset instance and string + * + * @param $dataSetInstance An instance of a database set class + * @param $rowName Name of the row + * @return $fqfn The FQFN for this row + */ + private function generateFqfnFromDataSet (StorableCriteria $dataSetInstance, $rowName) { + // This is the FQFN + $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/' . $rowName . '.' . $this->getFileExtension(); + + // Return it + return $fqfn; + } + /** * Creates the table info file from given dataset instance * @@ -306,7 +321,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend */ private function createTableInfoFile (StoreableCriteria $dataSetInstance) { // Create FQFN for creating the table information file - $fqfn = $this->getSavePath() . $dataSetInstance->getTableName() . '/info.' . $this->getFileExtension(); + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, 'info'); // Get the data out from dataset in a local array $this->tableInfo[$dataSetInstance->getTableName()] = array( @@ -469,12 +484,7 @@ class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontend */ public function queryInsertDataSet (StoreableCriteria $dataSetInstance) { // Create full path name - $fqfn = sprintf("%s%s/%s.%s", - $this->getSavePath(), - $dataSetInstance->getTableName(), - md5($dataSetInstance->getUniqueValue()), - $this->getFileExtension() - ); + $fqfn = $this->generateFqfnFromDataSet($dataSetInstance, md5($dataSetInstance->getUniqueValue())); // Try to save the request away try { -- 2.39.5