/**
* Element for index
*/
- private $indexKey = "__idx";
+ private $indexKey = '__idx';
/**
* The protected constructor. Do never instance from outside! You need to
* 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
$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 {
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
*
*/
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(
*/
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 {