The WebAbility® Network Developers - Documentation
WebAbility Site
\dominion\DB_Record Reference

I. Structure:


- Direct Superclass:
WAClass

- Direct known subclasses:
none

II. Description:


This object is used to store the representation of a row of data from a database, sheet, table, etc.

The record object is iterable, countable and has array access.

You can print directly the record:
print $rec;
This will print a set representation of the record
[field_value,field_value,field_value]


2.1. Using the class:


A record is empty when it is created.

$rec = new DB_Record();

When the record has been created, you can add all the fields you need to it.
There are many ways to add a field:

- Like an array:

$rec['fieldname'] = value;

- Like an object:

$rec->fieldname = value;

- By a function:

$rec->setArray(array_of_values);

- With the constructor:

$rec = new DB_Record(array_of_values);

Example:


$T = new DB_Record();
$T->setSecond(100)->setMicrosecond(10000);



2.2. Error messages:


If you want to translate the libraries you should consider into the WAMessage XML translation file the following entries:
- DB_uTime.badinit: The initialization time is not recognized.
- DB_uTime.badutimeobject: The parameter is not a DB_uTime object.


III. Reference:


3.1. Contructor:

DB_uTime(mixed $time)
$time contains the information of the time to initialize the instance.
If $time is null, the instance will be initialized with zero (no time).
If $time is 'N', it will be initialized with the actual time (now).
If $time is a DB_uTime object, it will be copied in the new instance.

3.2. Attributes:

none

3.3. Methods:


public DB_uTime getClone()
Returns a clone copy of this microtime with the same timestamp. This method is the same as PHP clone operator:
$T = new DB_uTime();
$U = clone $T;
$U = $T->getClone(); // identical to clone

public void initTime(mixed $time)
$time contains the information of the time to initialize the instance.
If $time is null, the instance will be initialized with zero (no time).
If $time is 'N', it will be initialized with the actual time (now).
If $time is a DB_uTime object, it will be copied in the new instance.

public void copy(DB_uTime $time)
Will copy the value of $time into this time instance.
$time: instance of DB_uTime.
If $time is not an instance of DB_uTime, an exception will be thrown: DB_uTimeException.
Returns the object reference to chain the methods.

public void setNow()
Set the instance to the current timestamp.
Returns the object reference to chain the methods.

public void setSecond(integer $second)
Sets the quantity of seconds to the instance.
  • $second: Integer. The quantity of seconds to to assign. If the value is not an integer, only the integer part will be used.

public void setMicrosecond(integer $microsecond)
Sets the quantity of microseconds to the instance.
  • $microsecond: Integer, from 0 to 999999. The quantity of microseconds to assign. If the value is not an integer, only the integer part will be used.

public void setTime(float $time)
Sets the timestamp to the instance.
  • $time: Float. The integer part are the seconds, The decimal part are the microseconds (up to a 10-6 resolution).

public integer getSecond()
Returns the seconds part of the time into the instance.

public integer getMicrosecond()
Returns the microseconds part of the time into the instance.

public float getTime()
Returns the time value as a float format. Integer part are the seconds, decimal parts are the microseconds with a 10-6 resoluction.

public void startChronometer()
Start to count time from this moment with this instance. It is equivalent to call setNow() method.

public float getChronometer()
Return the time that have passed since the last startChronometer() call, or from the time in the instance, under the form of a floating number.
It is the difference between now() and the time into the instance.

public string __toString()
Returns the time under a string that is the floating number time with 6 decimals.