// 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
- /* 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);
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('BASE-WRAPPER: result[]=' . gettype($result));
// Cache the result if not null
if (!is_null($result)) {
* @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 . '/';
- // 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));
// 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!
/**
* 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
- $current = FALSE;
+ $currentEntry = FALSE;
// 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
- return $current;
+ return $currentEntry;
}
/**
return $this->readRawDirectory();
} // END - if
+ // Init raw line
+ $rawLine = NULL;
+
// 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?
- 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);
- 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;
}
/**
// 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;
* @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;
}
/**