COPY TO ARRAYOFOBJECTS

From Lianjapedia
Jump to: navigation, search

Purpose

Copy records to an array of objects

Syntax

COPY TO ARRAYOFOBJECTS <array>

[<scope>]

[FIELDS <field list>]

[FOR <condition>]

[WHILE <condition>]

See Also

AAVERAGE(), ACOPY(), ADEL(), ADIR(), AFIELDS(), AFILL(), AINS(), ALEN(), AMAX(), AMIN(), APPEND FROM ARRAY, ASCAN(), ASORT(), ASUM(), AVERAGE, COPY, COPY TO ARRAY, GATHER, IN_ARRAY(), IS_ARRAY(), Lianja Arrays, SCATTER

Description

The COPY TO ARRAYOFOBJECTS command allows all or part of the active table to be copied to the specified array, <array>. The target array will be created or resized to accommodate the field list/records from the table as an array of objects.

<scope>

If no <scope> is specified, then the default is ALL.

FIELDS <field list>

The optional FIELDS clause restricts the operation to those fields listed in <field list>. The <field list> contains a comma-separated list of field names.

FOR <condition>

The optional FOR clause restricts the operation to those records that match the specified <condition>.

WHILE <condition>

The WHILE clause will copy records so long as the <condition> is true (.T.), and is used to restrict the range of records processed. When used in conjunction with the SEEK or LOCATE commands, it allows a quick way of copying selected records. When the WHILE clause is used, the <scope> will default to REST.

COPY TO ARRAYOFOBJECTS supported from Lianja v3.3.

Example

open database southwind
use shippers
copy to arrayofobjects aShipObjects for shipperid < 3
? aShipObjects
 
Array (refcnt=1)
(
    [1] = Dynarray
        (
            [shipperid] => 1
            [companyname] => Speedy Express                          
            [phone] => (503) 555-9831          
        )
    [2] = Dynarray
        (
            [shipperid] => 2
            [companyname] => United Package                          
            [phone] => (503) 555-3199          
        )
)