yana

phpDocumentor v 1.4.0

Class DatFile

Description

This class is an alternative to csv files.
Each line represents a row of data. Tags are used to mark up the fields.
The use of tag delimiters inside field values is not allowed. If a tag is found in a value it automatically gets removed.
The structure is not as strict as you might know from CSV files, which means the number and names of fields inside a row may vary from one row to another.
This provides you with more flexibility. For example: You may decide not to use a field for future entries or just add a new one and you don't have to change your previous entries inside the file.
This is also a good way around if you just don't know the structure of future entries yet.
  • access: public
Object
   |
   --FileSystemResource
      |
      --FileReadonly
         |
         --File
            |
            --DatFile
Method Summary
  • array get (int $lineNr)
  • bool insert (array $newEntry, [bool $append = false])
  • int length ()
  • bool remove (array $lineNr)
  • string toString ()
  • bool update (int $lineNr, array $newEntry)

Methods

retrieve a line of data from the file
array get (
int $lineNr
)
List of parameters:
Name Type Description
$lineNr int line to retrieve
Description:
This returns the dataset in line $lineNr as an associative array, or bool(false) on error.
Note that the keys are returned in capital letters.
  • access: public
  • uses: $datfile->get(0)

Redefinition of: FileReadonly::get()

insert (append) an entry to the file
bool insert (
array $newEntry, [bool $append = false]
)
List of parameters:
Name Type Description
$newEntry array associative array containing the new entry
$append bool true = append entry on end of file, false = insert entry on top of file
Description:
This appends the new entry to the file. Depending on the setting for argument $append, the entry is appended to the end, or inserted on top of the file.
The input array must not be multi-dimensional.
Returns bool(true) on success and bool(false) on error.
  • access: public
  • uses: $datfile->insert($new_entry)

Redefinition of: File::insert()

return the number of rows in the file
int length ()
Description:
  • access: public
  • uses: $datfile->length()

Redefinition of: File::length()

remove an entry from the file
bool remove (
array $lineNr
)
List of parameters:
Name Type Description
$lineNr array line to retrieve
Description:
Returns bool(true) on success and bool(false) on error.
  • access: public
  • uses: $datfile->insert($new_entry)

Redefinition of: File::remove()

return file content as string (if available)
string toString ()
Description:
  • access: public
  • uses: $datfile->toString()

Redefinition of: FileReadonly::toString()

update an entry of the file
bool update (
int $lineNr, array $newEntry
)
List of parameters:
Name Type Description
$lineNr int line number to update
$newEntry array associative array containing the new entry
Description:
Replaces an existing entry. If the entry does not exist, the function returns bool(false). The input array must not be multi-dimensional.
Returns bool(true) on success and bool(false) on error.
  • since: 2.9.6
  • access: public
  • uses: $datfile->insert($new_entry)
inherited from base classes

Inherited From File

Inherited From FileReadonly

Inherited From FileSystemResource

Inherited From Object

Documentation generated on Sat, 03 Jan 2009 22:22:14 +0100 by phpDocumentor 1.4.0

yana author: Thomas MeyerHomepage: www.yanaframework.net