- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:activerecord:getactiverecordsclass

# getActiveRecordsClass

##### Syntax

    void getActiveRecordsClass(
     string $class,
     string $tableName,
     optional string  $where=false,
     optional mixed[] $bindarr=false,
     optional mixed[] $primaryKeyArray=false,
     optional mixed[] $queryExtras=array(),
     optional mixed[] $relationsData=array()
    )

## Description

This allows you to retrieve an array of objects derived from ADOdb_Active_Records. Returns false if an error occurs.

## Parameters

### $class

This string represents the class of the current active record

### $table

Table used by the active record object

### $whereOrderBy

Where, order, by clause

### $bindarr

For more information on the use of `Bind` variables, see execute

### $primaryKeyArray

### $queryExtras

Query extras: limit, offset…

### $relationsData

### Usage

    class Product extends ADOdb_Active_Record{};
    $table = 'products';
    $whereOrderBy = "name LIKE 'A%' ORDER BY Name";
    $activeRecArr = $db->GetActiveRecordsClass('Product',
                                                $table,
                                                $whereOrderBy);

    /*
    * the objects in $activeRecArr are of class 'Product'
    */
    foreach($activeRecArr as $rec) {
    	$rec->id = rand();
    	$rec->save();
    }

To use bind variables (assuming ? is the place-holder for your database):

    $activeRecArr = $db->GetActiveRecordsClass($className,$tableName, 'name LIKE ?',
    						array('A%'));
    /*
    * You can also define the primary keys of the table by passing an array of field names:
    */

    $activeRecArr = $db->GetActiveRecordsClass($className,$tableName, 'name LIKE ?',
    						array('A%'), array('id'));

[Active Record]
v5/activerecord/getactiverecordsclass.txt · Last modified: 2016/01/18 20:02 by 66.249.75.209

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top