The WebAbility® Network Developers - Documentation
WebAbility Site
\datasource\DataSource reference

I. Structure:


- namespace:
\datasource\

- Direct superclass:
\core\WAObject

- Direct known subclasses:
\datasource\FileSource
\datasource\SHMSource
\datasource\FastObjectSource
\datasource\LanguageSource
\datasource\TemplateSource

II. Description:


This is the basic class to create a standard data source object.
The source object is directly and fully loaded into memory at read, contrary to the streams.
The source can be any type of information, like text files, databases, XML files, memory objects, arrays, etc.

The \datasource\DataSource have 2 basic control methods:
- isValid() to know if the information in the object is valid (i.e. synchronized with its sources).
- getTimeStamp() to get the last write access time to the information.

and 3 basic access methods:
- read() to load and get the data
- write($data) to write a new set of data
- unlink() to deletes the data source

You should extend all your data sources directly or indirectly from \datasource\DataSource.

\datasource\DataSource is a basic object that have a unique source of data in an own property.


III. Reference:


3.1. Contructor:


\datasource\DataSource($data)
Creates the instance.
If $data is not null, then it will automatically 'write' the data into the object, with its timestamp as the creation time.
If $data is null, the object have no data and no timestamp yet. If you want to have the null value as data into the object and the object valid, you can use the method write(null): it will set the null value and validate the object.
  • $data: mixed, the data to write in the object.


3.2. Constants:

There is no constant into this class.


3.3. Attributes:


protected mixed $data
Is used to store the data of the object.

protected integer $timestamp
Is used to store the last write access to the data in the object.


3.4. Methods:


public boolean static isValid()
This method is used to know if the data into the DataSource is valid or not.
If there is no data set, the object is not valid. Otherwise it is valid.

public integer getTimeStamp()
This method is used to get the last write access to the data in the object.
If the object is invalid, it will return null.
Note: The returned value is a unix timestamp that you can format to a human readable date with date().

public mixed read()
This method is used to get the data in the object.
If the object is invalid, it will return null.

public void write($data)
This method is used to set the data in the object.
The timestamp will be set to actual time.
  • $data: mixed, the data to write in the object.

public void unlink()
This method is used to destroy any data in the object.
The timestamp is set to null and the object becomes invalid.