* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class LocalFileDatabase extends BaseDatabaseFrontend implements DatabaseFrontendInterface {
-
// Constants for MySQL backward-compatiblity (PLEASE FIX THEM!)
const DB_CODE_TABLE_MISSING = 0x100;
const DB_CODE_TABLE_UNWRITEABLE = 0x101;
const DB_CODE_DATA_FILE_CORRUPT = 0x102;
+ // Status results
+ const RESULT_OKAY = 'ok';
+
/**
* Save path for "file database"
*/
/**
* The file's extension
*/
- private $fileExtension = "serialized";
+ private $fileExtension = 'serialized';
/**
* The last read file's name
if (!isset($this->tableInfo['primary'])) {
// Then create the info file
$this->createTableInfoFile($dataSetInstance);
- } elseif (($this->getConfigInstance()->readConfig('db_update_primary_forced') === "Y") && ($dataSetInstance->getPrimaryKey() != $this->tableInfo['primary'])) {
+ } elseif (($this->getConfigInstance()->readConfig('db_update_primary_forced') == 'Y') && ($dataSetInstance->getPrimaryKey() != $this->tableInfo['primary'])) {
// Set the array element
$this->tableInfo[$dataSetInstance->getTableName()]['primary'] = $dataSetInstance->getPrimaryKey();
* Starts a SELECT query on the database by given return type, table name
* and search criteria
*
- * @param $resultType Result type ("array", "object" and "indexed" are valid)
+ * @param $resultType Result type ('array', 'object' and 'indexed' are valid)
* @param $tableName Name of the database table
* @param $criteria Local search criteria class
* @return $resultData Result data of the query
* @throws UnsupportedCriteriaException If the criteria is unsupported
- * @throws SqlException If an "SQL error" occurs
+ * @throws SqlException If an 'SQL error' occurs
*/
public function querySelect ($resultType, $tableName, LocalSearchCriteria $criteriaInstance) {
// The result is null by any errors
// Create full path name
$pathName = $this->getSavePath() . $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 = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($pathName);
// Initialize the result data, this need to be rewritten e.g. if a local file cannot be read
$resultData = array(
- 'status' => "ok",
+ 'status' => LocalfileDatabase::RESULT_OKAY,
'rows' => array()
);
$idx = 1;
// Read the directory with some exceptions
- while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
+ while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', "info." . $this->getFileExtension()))) && ($limitFound < $criteriaInstance->getLimit())) {
// Does the extension match?
if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
// Skip this file!
$searchInstance = $dataSetInstance->getSearchInstance();
// Read the directory with some exceptions
- while (($dataFile = $directoryInstance->readDirectoryExcept(array(".", "..", ".htaccess", ".svn", "info." . $this->getFileExtension()))) && ($limitFound < $searchInstance->getLimit())) {
+ while (($dataFile = $directoryInstance->readDirectoryExcept(array('.', '..', '.htaccess', '.svn', "info." . $this->getFileExtension()))) && ($limitFound < $searchInstance->getLimit())) {
// Does the extension match?
if (substr($dataFile, -(strlen($this->getFileExtension()))) !== $this->getFileExtension()) {
// Skip this file!